logo

openmv先判断颜色在判断是否移动

2022-10-27 11:18
C
sryv
image
image
image
if red_blobs:
    #如果找到了目标颜色
        for a in red_blobs:
        #迭代找到的目标颜色区域
            # Draw a rect around the blob.
            img.draw_rectangle(a[0:4],color=(255,0,0)) # rect
            #用矩形标记出目标颜色区域
            img.draw_cross(a[5], a[6]) # cx, cy
            #在目标颜色区域的中心画十字形标记
            time.sleep_ms(10)
            if red_blobs:
    #如果找到了目标颜色
                for b in red_blobs:
        #迭代找到的目标颜色区域
            # Draw a rect around the blob.
                    img.draw_rectangle(b[0:4],color=(255,0,0))
            #用矩形标记出目标颜色区域
                    img.draw_cross(b[5], b[6]) # cx, cy
            #在目标颜色区域的中心画十字形标记
                    time.sleep_ms(10)
                    if a[5]-10<b[5]<a[5]+10 and a[6]-10<b[6]<a[6]+10:
                        for c in red_blobs:
        #迭代找到的目标颜色区域
            # Draw a rect around the blob.
                            img.draw_rectangle(c[0:4],color=(255,0,0)) # rect
            #用矩形标记出目标颜色区域
                            img.draw_cross(c[5], c[6]) # cx, cy
                            time.sleep_ms(1000)
                            if a[5]-10<c[5]<a[5]+10 and a[6]-10<c[6]<a[6]+10:
                                print('red:',a[5],a[6])
                                print('red:',b[5],b[6])
                                print('red:',c[5],c[6])
                                data="0"
                                data_out = json.dumps(set(data))
                                uart.write(data_out +'\n')
                                print('you send:',data_out)
    if green_blobs:
2022-10-27 21:07
I
网红小智智 星瞳科技

如果涉及代码,需要报错提示与全部代码文本