openmv识别色块,并返回坐标值
-
sensor.skip_frames(10) sensor.set_auto_whitebal(False) clock = time.clock() global max_size1 global max_size2 while(True): clock.tick() img = sensor.snapshot() roi1=[0,0,54,120] roi2=[105,0,50,120] global max_size1 global max_size2 blobs1 = img.find_blobs([green_threshold],roi=roi1,x_stride=10, y_stride=40) blobs2 = img.find_blobs([green_threshold],roi=roi2,x_stride=10, y_stride=40) if blobs1: for b in blobs1: max_size=0 if b[2]*b[3] > max_size: max_size1 = b[2]*b[3] if max_size1>2000: max_size1=max_size1 img.draw_rectangle(b[0:4], color = (0, 0, 0)) img.draw_cross(b[5], b[6], color = (0, 0, 0)) print(b[5], b[6]) global max_size1 if blobs2: for b in blobs2 : max_size=0 if b[2]*b[3] > max_size: max_size2 = b[2]*b[3] if max_size2>2000: max_size2 = max_size2 img.draw_rectangle(b[0:4], color = (0, 0, 255)) img.draw_cross(b[5], b[6], color = (0, 0, 255)) print(b[5], b[6]) global max_size2
在程序中,我想识别两个区域的色块的面积,最后在程序结尾进行判断一下两个区域的色块面积,如何从两个if判断中返回色块面积的值
-
你这个程序有什么问题吗?