颜色识别
-
我只想让我的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())
颜色识别我始终不知道为什么它会圈出别的区域
-
按照教程操作,你的代码要按照教程编写。