
#sensor.set_gainceiling(16)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
# Load template.
# Template should be a small (eg. 32x32 pixels) grayscale image.
template = image.Image("/template.pgm")
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
if img.format() != sensor.GRAYSCALE:
imge = img.to_grayscale() #默认False , True内存溢出
r = imge.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
if r:
img.draw_rectangle(r,color = (0, 0, 0), thickness = 1, fill = False)
else:
ROI_X=50
ROI_Y=13
ROI_W=60
ROI_H=80
ROI=(ROI_X,ROI_Y,ROI_W ,ROI_H)
img.draw_rectangle(ROI,color = (0, 0, 0), thickness = 1, fill = False)
print(clock.fps())4c49-bfb2-4d9b7fe2e12d.png)

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