在识别圆形里出现多个大小相近的圆,我应该如何筛选出半径最大的那一个
-
![0_1682347563892_1.bmp](正在上传 100%)
我在识别仪器仪表的时候,出现了两个大小相近的圆,我想让程序可以自己识别出半径最大的那一个圆并继续进行操作,我应该怎么编写代码呢?
-
写for循环遍历一下:
import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.RGB565) # grayscale is faster sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) clock = time.clock() while(True): clock.tick() img = sensor.snapshot().lens_corr(1.8) max_circle = None for c in img.find_circles(threshold = 2000, x_margin = 10, y_margin = 10, r_margin = 10, r_min = 2, r_max = 100, r_step = 2): if max_circle is None: max_circle = c elif c.r() > max_circle.r(): max_circle = c print(max_circle) if max_circle: img.draw_circle(max_circle.x(), max_circle.y(), max_circle.r(), color = (255, 0, 0)) print("FPS %f" % clock.fps())