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



    • 0_1627642685723_微信图片_20210730185559.png

      # MAVLink OpticalFlow Script.
      #
      # This script sends out OpticalFlow detections using the MAVLink protocol to
      # an LIGHT/PixHawk UAV controller for position control using your OpenMV Cam.
      #
      # P4 = TXD 115200,8,N,1
      
      
      import sensor, image, time, pyb, struct, math
      
      sensor.reset() # Initialize the camera sensor.
      sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.GRAYSCALE
      sensor.set_framesize(sensor.QQQQVGA) # or B40x30 or B64x64
      clock = time.clock() # Tracks FPS.
      
      old = sensor.snapshot()
      
      uart = pyb.UART(3, 115200, timeout_char = 1000)
      
      def send_optical_flow_packet(x, y, c):
          temp = struct.pack("<bbiii",
                             0xAA,
                             0xAE,
                             int(x * 100000 ), # up sample by 4
                             int(y * 100000 ), # up sample by 4
                             int(c * 100000))
          uart.write(temp)
      
      
      while(True):
          clock.tick() # 获取时间
          img = sensor.snapshot() # 获取一帧图像
          [delta_x, delta_y, response] = old.find_displacement(img) #获取前面一张图像与刚捕获的图像之间的偏移
          old = img.copy()
          #print("%0.6fX   %0.6fY   %0.2fC   %0.2fFPS" % (delta_x, delta_y, response, clock.fps()))
          if (not (math.isnan(delta_x) or math.isnan(delta_y) or math.isnan(response))):
              send_optical_flow_packet(delta_x, delta_y, response)
      
      


    • https://book.openmv.cc/example/22-Optical-Flow/differential-translation.html
      参考这个正确代码。

      33行不能这么用。