如何将已经用矩形圈出的区域设置为roi的范围,并在其中寻找圆形
-
如何将已经用矩形圈出的区域设置为roi的范围,并在其中寻找圆形
-
import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.RGB565) # 灰度更快(160x120 max on OpenMV-M7) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) clock = time.clock() while(True): clock.tick() img = sensor.snapshot() rects = img.find_rects(threshold = 30000) circles = [] for r in rects: circles += img.find_circles(roi=r.rect(), threshold = 3500) print(rects) print(circles) for r in rects: img.draw_rectangle(r.rect(), color = (255, 0, 0)) for c in circles: img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0)) print("FPS %f" % clock.fps())