识别单个色块却输出多个颜色
-
while(True):
clock.tick()
img_color = sensor.snapshot()blobs_r = img_color.find_blobs([red ], pixels_threshold = All_Pixel_Thr, merge = False, margin = 50) blobs_g = img_color.find_blobs([green], pixels_threshold = All_Pixel_Thr, merge = False, margin = 50) blobs_b = img_color.find_blobs([blue ], pixels_threshold = All_Pixel_Thr, merge = False, margin = 50) for blob_r in blobs_r: if( blob_r[4] > All_Pixel_Thr): img_color.draw_cross(blob_r.cx(), blob_r.cy(), color = (255, 0, 0), size = 10, thickness = 2) print("------Red = ", blob_r.pixels()) for blob_g in blobs_g: if( blob_g[4] > All_Pixel_Thr): img_color.draw_cross(blob_g.cx(), blob_g.cy(), color = (0, 255, 0), size = 10, thickness = 2) print("------Green = ", blob_g.pixels()) for blob_b in blobs_b: if( ( blob_b[4] > All_Pixel_Thr) and (Blod_Flag == 1) ): #第二次识别蓝色 img_color.draw_cross(blob_b.cx(), blob_b.cy(), color = (0, 0, 255), size = 10, thickness = 2) print("------Blue = ", blob_b.pixels())
像这样同样一个物体为什么会识别出三个颜色块的值呢,能不能只让他输出一个最符合的颜色
-
draw_cross会改变图像,会影响接下来的代码。删掉就行了。