• 免费好用的星瞳AI云服务上线!简单标注,云端训练,支持OpenMV H7和OpenMV H7 Plus。可以替代edge impulse。 https://forum.singtown.com/topic/9519
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 为什么对人脸追踪的程序只是加入了打印人脸坐标,每次循环的结果都是一样的没有变化?



    • # Face Tracking Example
      #
      # This example shows off using the keypoints feature of your OpenMV Cam to track
      # a face after it has been detected by a Haar Cascade. The first part of this
      # script finds a face in the image using the frontalface Haar Cascade.
      # After which the script uses the keypoints feature to automatically learn your
      # face and track it. Keypoints can be used to automatically track anything.
      import sensor, time, image
      
      # Reset sensor
      sensor.reset()
      sensor.set_contrast(3)
      sensor.set_gainceiling(16)
      sensor.set_framesize(sensor.VGA)
      sensor.set_windowing((320, 240))
      sensor.set_pixformat(sensor.GRAYSCALE)
      
      # Skip a few frames to allow the sensor settle down
      sensor.skip_frames(time = 2000)
      
      # Load Haar Cascade
      # By default this will use all stages, lower satges is faster but less accurate.
      face_cascade = image.HaarCascade("frontalface", stages=25)
      print(face_cascade)
      
      # First set of keypoints
      kpts1 = None
      
      # Find a face!
      while (kpts1 == None):
          img = sensor.snapshot()
          img.draw_string(0, 0, "Looking for a face...")
          # Find faces
          objects = img.find_features(face_cascade, threshold=0.5, scale=1.25)
          if objects:
              # Expand the ROI by 31 pixels in every direction
              face = (objects[0][0]-31, objects[0][1]-31,objects[0][2]+31*2, objects[0][3]+31*2)
              # Extract keypoints using the detect face size as the ROI
              kpts1 = img.find_keypoints(threshold=10, scale_factor=1.1, max_keypoints=100, roi=face)
              # Draw a rectangle around the first face
              img.draw_rectangle(objects[0])
             
      # Draw keypoints
      print(kpts1)
      img.draw_keypoints(kpts1, size=24)
      img = sensor.snapshot()
      time.sleep(2000)
      
      # FPS clock
      clock = time.clock()
      
      while (True):
          clock.tick()
          img = sensor.snapshot()
          # Extract keypoints from the whole frame
          kpts2 = img.find_keypoints(threshold=10, scale_factor=1.1, max_keypoints=100, normalized=True)
      
          if (kpts2):
              # Match the first set of keypoints with the second one
              c=image.match_descriptor(kpts1, kpts2, threshold=85)
              match = c[6] # C[6] contains the number of matches.
              if (match>5):
                  img.draw_rectangle(c[2:6])
                  img.draw_cross(c[0], c[1], size=10)
                  t=img.draw_rectangle(c[2:6])
                  print(kpts2, "matched:%d dt:%d"%(match, c[7]))
                  for face in objects:
                      print(face)
      
          # Draw FPS
          img.draw_string(0, 0, "FPS:%.2f"%(clock.fps()))
      


    • 只是加了这一句

      for face in objects:
      print(face)



    • 串口显示结果

      {"size":54, "threshold":10, "normalized":1} matched:18 dt:0
      (46, 8, 182, 182)
      {"size":50, "threshold":10, "normalized":1} matched:17 dt:0
      (46, 8, 182, 182)
      {"size":53, "threshold":10, "normalized":1} matched:18 dt:0
      (46, 8, 182, 182)
      {"size":52, "threshold":10, "normalized":1} matched:17 dt:0
      (46, 8, 182, 182)
      {"size":56, "threshold":10, "normalized":1} matched:18 dt:0
      (46, 8, 182, 182)
      {"size":62, "threshold":10, "normalized":1} matched:18 dt:0
      (46, 8, 182, 182)
      {"size":55, "threshold":10, "normalized":1} matched:15 dt:0
      (46, 8, 182, 182)
      {"size":70, "threshold":10, "normalized":1} matched:10 dt:0
      (46, 8, 182, 182)
      {"size":85, "threshold":10, "normalized":1} matched:11 dt:0
      (46, 8, 182, 182)
      {"size":61, "threshold":10, "normalized":1} matched:9 dt:0
      (46, 8, 182, 182)
      {"size":58, "threshold":10, "normalized":1} matched:8 dt:0
      (46, 8, 182, 182)
      {"size":49, "threshold":10, "normalized":1} matched:7 dt:0
      (46, 8, 182, 182)
      {"size":51, "threshold":10, "normalized":1} matched:8 dt:0
      (46, 8, 182, 182)
      {"size":30, "threshold":10, "normalized":1} matched:7 dt:0
      (46, 8, 182, 182)
      {"size":44, "threshold":10, "normalized":1} matched:6 dt:0
      (46, 8, 182, 182)
      {"size":45, "threshold":10, "normalized":1} matched:8 dt:0
      (46, 8, 182, 182)
      {"size":45, "threshold":10, "normalized":1} matched:9 dt:0
      (46, 8, 182, 182)
      {"size":37, "threshold":10, "normalized":1} matched:6 dt:15
      (46, 8, 182, 182)
      {"size":41, "threshold":10, "normalized":1} matched:6 dt:15
      (46, 8, 182, 182)
      {"size":45, "threshold":10, "normalized":1} matched:6 dt:270
      (46, 8, 182, 182)
      {"size":38, "threshold":10, "normalized":1} matched:8 dt:15
      (46, 8, 182, 182)
      {"size":46, "threshold":10, "normalized":1} matched:8 dt:15
      (46, 8, 182, 182)
      {"size":43, "threshold":10, "normalized":1} matched:7 dt:0
      (46, 8, 182, 182)
      {"size":40, "threshold":10, "normalized":1} matched:7 dt:15
      (46, 8, 182, 182)
      {"size":49, "threshold":10, "normalized":1} matched:9 dt:30
      (46, 8, 182, 182)
      {"size":38, "threshold":10, "normalized":1} matched:7 dt:0
      (46, 8, 182, 182)
      {"size":63, "threshold":10, "normalized":1} matched:8 dt:0
      (46, 8, 182, 182)
      {"size":53, "threshold":10, "normalized":1} matched:8 dt:0
      (46, 8, 182, 182)
      {"size":49, "threshold":10, "normalized":1} matched:9 dt:0
      (46, 8, 182, 182)
      {"size":43, "threshold":10, "normalized":1} matched:6 dt:0
      (46, 8, 182, 182)
      {"size":47, "threshold":10, "normalized":1} matched:7 dt:0
      (46, 8, 182, 182)
      {"size":42, "threshold":10, "normalized":1} matched:6 dt:0
      (46, 8, 182, 182)
      {"size":41, "threshold":10, "normalized":1} matched:7 dt:0
      (46, 8, 182, 182)
      {"size":34, "threshold":10, "normalized":1} matched:7 dt:0
      (46, 8, 182, 182)
      {"size":21, "threshold":10, "normalized":1} matched:8 dt:0
      (46, 8, 182, 182)
      {"size":29, "threshold":10, "normalized":1} matched:6 dt:0
      (46, 8, 182, 182)
      {"size":24, "threshold":10, "normalized":1} matched:9 dt:0
      (46, 8, 182, 182)
      {"size":29, "threshold":10, "normalized":1} matched:6 dt:0
      (46, 8, 182, 182)
      {"size":23, "threshold":10, "normalized":1} matched:7 dt:0
      (46, 8, 182, 182)
      {"size":29, "threshold":10, "normalized":1} matched:8 dt:0
      (46, 8, 182, 182)
      {"size":29, "threshold":10, "normalized":1} matched:6 dt:0
      (46, 8, 182, 182)
      
      Traceback (most recent call last):
        File "<stdin>", line 56, in <module>
      Exception: IDE interrupt
      MicroPython v1.9.4-4553-gb4eccdfe3 on 2019-05-02; OPENMV4 with STM32H743
      


    • 代码垃圾。逻辑完全不对。
      你的代码有两个while死循环,第二个死循环永远不会运行。



    • 我建议你从头开始看教程,把每一句代码的作用都搞懂。不要单纯的复制粘贴。


    已锁定