导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. cwor
    C
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    cwor

    @cwor

    0
    声望
    1
    楼层
    340
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    cwor 关注

    cwor 发布的帖子

    • openmv4 cam H7Plus用不了示例25-tf_object_detection FOMO 人员检测显示?

      0_1742119550055_屏幕截图 2025-03-16 180247.png

      # TensorFlow Lite 目标点检测示例
      #
      # 本例程使用内置的FOMO模型检测人脸。
      
      import sensor
      import time
      import tf
      import math
      
      sensor.reset()  # 重置并初始化感光元件
      sensor.set_pixformat(sensor.RGB565)  # 设置图像格式为 RGB565 (或 GRAYSCALE)
      sensor.set_framesize(sensor.QVGA)  # 设置图像大小为 QVGA (320x240)
      sensor.set_windowing((240, 240))  # 设置图像为 240x240 窗口大小
      sensor.skip_frames(time=2000)  # 跳过几帧使设置生效
      
      min_confidence = 0.4
      
      # 加载内置的 FOMO 人脸检测模型
      labels, net = tf.load_builtin_model("fomo_face_detection")
      
      # 或者,模型文件也可以从文件系统存储中加载。
      # net = tf.load('<object_detection_network>', load_to_fb=True)
      # labels = [line.rstrip('\n') for line in open("labels.txt")]
      
      colors = [  # 可以添加更多标识圈的颜色,可以超过7种,不同种类目标物体用不同颜色圈表示
          (255, 0, 0),
          (0, 255, 0),
          (255, 255, 0),
          (0, 0, 255),
          (255, 0, 255),
          (0, 255, 255),
          (255, 255, 255),
      ]
      
      clock = time.clock()
      while True:
          clock.tick()
      
          img = sensor.snapshot()
      
          # detect() 返回图像中检测到的所有的物体 (已经按照种类分类好)
          # 跳过索引0, 因为第0个分类是 背景 
          # 然后在识别到的物体中央画出圆圈
      
          for i, detection_list in enumerate(
              net.detect(img, thresholds=[(math.ceil(min_confidence * 255), 255)])
          ):
              if i == 0:
                  continue  # 索引0是背景分类
              if len(detection_list) == 0:
                  continue  # 没有检测到这个种类的物体
      
              print("********** %s **********" % labels[i])
              for d in detection_list:
                  [x, y, w, h] = d.rect()
                  center_x = math.floor(x + (w / 2))
                  center_y = math.floor(y + (h / 2))
                  print(f"x {center_x}\ty {center_y}")
                  img.draw_circle((center_x, center_y, 12), color=colors[i], thickness=2)
      
          print(clock.fps(), "fps", end="\n")
      

      0_1742119571046_屏幕截图 2025-03-16 180247.png

      发布在 OpenMV Cam
      C
      cwor