为什么好多函数例如find_blobs等都不支持VGA格式的图像,如果想在VGA格式下使用这些函数有什么方法吗?可以设置ROI吗?或者其他办法
https://forum.singtown.com/topic/558/memory-error-fb-alloc-collision-%E5%86%85%E5%AD%98%E4%B8%8D%E5%A4%9F%E4%B8%8E%E5%83%8F%E7%B4%A0%E4%BD%8E
https://forum.singtown.com/topic/276/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8roi%E6%9D%A5%E8%AE%BE%E5%AE%9A%E6%9C%89%E6%95%88%E6%A3%80%E6%B5%8B%E5%8C%BA%E5%9F%9F/4
@kidswong999 所以我设置一个足够小的ROI之后,就可以在VGA的格式下进行一些函数的运算了吗?
对:umbrella:

@kidswong999
import sensor, image, time,pyb
yellow_threshold = ( 65, 75, 0, 22, 25, 45)
from pyb import UART
ROI1=(40,207,112,42)
sensor.reset() # 初始化摄像头
sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565.
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(10) # 跳过10帧,使新设置生效
sensor.set_auto_whitebal(False)# Create a clock object to track the FPS.
sensor.set_windowing(ROI1)
clock = time.clock()
uart = UART(3, 9600)
while(True):
img = sensor.snapshot() # Take a picture and return the image.
#img = image.lens_corr(strength=1.5)
blobs = img.find_blobs([yellow_threshold])
if blobs:
for b in blobs:
img.draw_rectangle(b[0:4])
uart.write('CX :')
uart.write(str(b[5]))
print('x:',str(b[5]))
uart.write('CY :')
uart.write(str(b[6]))
print('y:',str(b[6]))这是具体代码
这样是可以的,亲测有效
import sensor, image, time,pyb
yellow_threshold = ( 65, 75, 0, 22, 25, 45)
from pyb import UART
ROI1=(40,207,112,42)
sensor.reset() # 初始化摄像头
sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565.
sensor.set_framesize(sensor.VGA)
sensor.set_windowing(ROI1)
sensor.skip_frames(10) # 跳过10帧,使新设置生效
sensor.set_auto_whitebal(False)# Create a clock object to track the FPS.
clock = time.clock()
uart = UART(3, 9600)
while(True):
img = sensor.snapshot() # Take a picture and return the image.
#img = image.lens_corr(strength=1.5)
blobs = img.find_blobs([yellow_threshold])
if blobs:
for b in blobs:
img.draw_rectangle(b[0:4])
uart.write('CX :')
uart.write(str(b[5]))
print('x:',str(b[5]))
uart.write('CY :')
uart.write(str(b[6]))
print('y:',str(b[6]))@kidswong999 好吧,把set_windowing()函数放到skip_frames()函数前面就可以了,如果把set_windowing()放到最后就会出现我的那种情况,报格式错误。这有是什么原因呢?
skip_frames()的目的是使sensor的设置生效,所以skip_frames()应该放到sensor设置最后面。