这一行的代码是:print("W:", red_blobs[0][2] ,"H:", red_blobs[0][3])
3b1u
@3b1u
0
声望
8
楼层
378
资料浏览
0
粉丝
0
关注
3b1u 发布的帖子
-
颜色识别
我只想让我的openmv识别红色,为什么它还会圈出别的无关区域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=[(66, 27, 70, 13, 127, -128),(74, 35, -80, -2, 35, -3),(73, 0, -21, 127, -59, -3)] mid_roi=[20,20,280,200] while(True): img=sensor.snapshot() for blob in img.find_blobs(rgb_circle,roi=mid_roi,x_stride=110,y_stride=110,merge=False): print(blob.code()) if(blob.code()==1):#001 print("r") img.draw_rectangle(blob.rect(),color=(255,255,255)) img.draw_cross(blob.cx(), blob.cy()) if(blob.code()==2):#010 print("g") img.draw_rectangle(blob.rect(),color=(0,0,0)) img.draw_cross(blob.cx(), blob.cy()) if(blob.code()==4):#100 print("b") img.draw_rectangle(blob.rect(),color=(255,0,0)) img.draw_cross(blob.cx(), blob.cy())
颜色识别我始终不知道为什么它会圈出别的区域
-
RE: 关于多颜色识别blob.code()的问题
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())
-
关于多颜色识别blob.code()的问题
我的代码逻辑是这样的:多颜色识别,识别到对应颜色打印相应的判断字符 但是在openmv还没有识别到rgb任何一个颜色的时候为什么终端已经显示它找到了红色呢???
大神们求解答,万分感谢