【openmv】microPython实现多个口罩识别追踪检测


import sensor, image, time

# 颜色追踪的例子,一定要控制环境的光,保持光线是稳定的。
light_blue_threshold   = (63, 90, -20, -5, -15, 10)
object_num = 0
point_cx_sum = 0
point_cy_sum = 0
i = 0
point_cx = [0 for x in range(100)]
point_cy = [0 for x in range(100)]
sensor.reset() # 初始化摄像头
sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565.
sensor.set_framesize(sensor.VGA)
sensor.set_windowing((400,320)) # 由于像素过多必须设置ROI
sensor.skip_frames(time = 2000) # 跳过2000s,使新设置生效,并自动调节白平衡
sensor.set_auto_gain(False) # 关闭自动自动增益。默认开启的,在颜色识别中,一定要关闭白平衡。
sensor.set_auto_whitebal(False)#关闭白平衡。白平衡是默认开启的,在颜色识别中,一定要关闭白平衡。
clock = time.clock() # 追踪帧率

while(True):
    clock.tick() # Track elapsed milliseconds between snapshots().
    img1 = sensor.snapshot() # 从感光芯片获得一张图像
    i = i + 1
    blobs1 = img1.find_blobs([light_blue_threshold],x_stride=50,y_stride=50,merge=True,pixels_threshold=10000)
    if blobs1:
    #如果找到了目标颜色
        for b1 in blobs1:
        #迭代找到的目标颜色区域
            object_num = object_num + 1
            point_cx[object_num-1] += b1[5]
            point_cy[object_num-1] += b1[6]
        if i%3!=0:
            object_num = 0
    if i%3==0: # 三张图取平均
        i=0
        for j in range(object_num):
            point_cx[j] = int(point_cx[j]/3)
            point_cy[j] = int(point_cy[j]/3) 
            img1.draw_cross(point_cx[j], point_cy[j],size=10,color=(0,0,0))
            point_cx[j] = 0
            point_cy[j] = 0
        object_num = 0

在这里插入图片描述

  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Greif_Hairline

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值