find_circles函数比较慢,你应该把103行,和115行,合并在一起。
for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,
r_min = 2, r_max = 100, r_step = 2):
area = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r())
statistics = img.get_statistics(roi=area)
#像素颜色统计
if 75<statistics.l_mode()<100 and -27<statistics.a_mode()<96 and -7<statistics.b_mode()<31:
img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
#识别到的白色圆形用红色的圆框出来
print("白",c.x(),c.y())
if 30<statistics.l_mode()<100 and 5<statistics.a_mode()<73 and -42<statistics.b_mode()<32:
img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
#识别到的粉色圆形用红色的圆框出来
print("粉",c.x(),c.y())