关于多颜色识别blob.code()的问题
-
我的代码逻辑是这样的:多颜色识别,识别到对应颜色打印相应的判断字符 但是在openmv还没有识别到rgb任何一个颜色的时候为什么终端已经显示它找到了红色呢???
大神们求解答,万分感谢
-
如果涉及代码,需要报错提示与代码文本,不要贴代码图片
-
import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking clock = time.clock() rgb_circle=[(0, 72, -2, 127, 127, -128),(30, 100, -80, -128, -128, 127),(0, 100, 127, -128, -128, -7)] red_circle=[(0, 72, -2, 127, 127, -128)] green_circle=[(30, 100, -80, -128, -128, 127)] blue_circle=[(0, 100, 127, -128, -128, -7)] img=sensor.snapshot() red_blob=img.find_blobs(red_circle) green_blob=img.find_blobs(green_circle) blue_blob=img.find_blobs(blue_circle) while(True): img=sensor.snapshot() if(red_blob.code()==1):#001 print("r") img.draw_rectangle(blob.rect(),color=(0,0,255)) img.draw_cross(blob.cx(), blob.cy()) if(green_blob.code()==1): print("g")#010 img.draw_rectangle(blob.rect(),color=(255,255,255)) img.draw_cross(blob.cx(), blob.cy()) if(blue_blob.code()==1):#100 print("b") img.draw_rectangle(blob.rect(),color=(255,0,0)) img.draw_cross(blob.cx(), blob.cy())
-
red_blob 是一个列表,你应该遍历它
for b in red_blob: print(b.code())
所以你的这个变量名字不好,应该叫red_blobs
-
好的
-
大佬有没有解决颜色顺序识别?嘿嘿