global flag
global send_num
if a=="r":
img = sensor.snapshot()
img.binary([ring_thresholds[0]])
img.dilate(1)
for blob in img.find_blobs(graythreshold,area_threshold=7000, pixels_threshold=100, area_threshold=2000, merge=True):
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(), blob.cy())
print("red:(",blob.cx(),",",blob.cy(),")")
if blob.area() >5000 :
print("RED")
代码需要完整的,不然我没办法运行测试。
找到原因了,和光线有关,颜色有时候容易错分