想用VGA格式读一幅图像,但是内存不够,所以想把一幅图片分开扫描,但遇到很多问题,求指教
yellow_threshold = ( 70, 80, 10, 25, 30, 60)
from pyb import UART
from pyb import Timer
ROI1=(90,0,230,400)
ROI2=(90,400,230,80)
ROI3=(320,0,110,460)
ROIS=[ROI1,ROI2,ROI3]
def saomiao():
while(True):
for ROI in ROIS:
pyb.delay(1000)
sensor.reset()
#sensor.skip_frames(10)
return ROI
sensor.reset() # 初始化摄像头
sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565.
sensor.set_framesize(sensor.VGA)
sensor.set_windowing(saomiao())
sensor.skip_frames(1000)
sensor.set_auto_whitebal(False)# Create a clock object to track the FPS.
clock = time.clock()
uart = UART(3, 9600)
#start = pyb.millis()
while(True):
image = sensor.snapshot() # Take a picture and return the image.
img = image.lens_corr(strength=1.8)
blobs = img.find_blobs([yellow_threshold])
#img.draw_rectangle(ROI)
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]))

想问有没有人做过类似的,通过对set_windows()的变量进行不断变换和扫描的工作?
首先,你的代码逻辑不对。
而且,OpenMV这么用很蛋疼,效果并不好,速度很慢。
很蛋疼,但是下面的代码可以运行。
import sensor, image
ROI1=(90,0,230,400)
ROI2=(90,400,230,80)
ROI3=(320,0,110,460)
ROIS=[ROI1,ROI2,ROI3]
yellow_threshold = ( 70, 80, 10, 25, 30, 60)
sensor.reset() # 初始化摄像头
sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565.
sensor.set_framesize(sensor.VGA)
sensor.set_windowing(ROIS[0])
sensor.set_auto_whitebal(False)# Create a clock object to track the FPS.
sensor.skip_frames(10)
while(True):
for r in ROIS:
sensor.set_windowing(r)
print(r)
sensor.skip_frames(10)
img = sensor.snapshot() # Take a picture and return the image.
blobs = img.find_blobs([yellow_threshold])
if blobs:
for b in blobs:
img.draw_rectangle(b[0:4])
print('x:',str(b[5]))
print('y:',str(b[6]))@kidswong999 嗯嗯,我速度要求不是很高。非常感谢您的帮忙,感谢感谢。