• 安装星瞳实验室APP,快速收到回复。扫描二维码或者点击 https://singtown.com/app/
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 一个提问,一个帖子,标题为问题的介绍
  • 请贴出具体的代码,与报错提示。
  • 代码一定要让别人可以运行的文本,不要贴图片
  • 当aduino发送123数据到openmv,如何让openmv读取123才开始检测并保存


    • 已封禁

      这是关键点检测与关键点保存的代码,我想问一下,当aduino发送123数据到openmv,如何让openmv读取123才开始检测并保存
      import sensor, time, image
      from pyb import UART

      sensor.reset()

      sensor.set_contrast(1)
      sensor.set_gainceiling(16)
      sensor.set_framesize(sensor.QQVGA)
      sensor.set_pixformat(sensor.GRAYSCALE)

      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False, value=100)

      FILE_NAME = "desc"
      def draw_keypoints(img, kpts):
      print(kpts)
      img.draw_keypoints(kpts)
      img = sensor.snapshot()
      time.sleep(1000)

      kpts1 = None

      clock = time.clock()
      uart = UART(3, 9600)
      uart.init(9600, bits=8, parity=None, stop=1)
      while (True):
      clock.tick()
      img = sensor.snapshot()
      if uart.any():
      tmp_data = uart.readline(123)
      if tmp_data == 123:
      if (kpts1 == None):
      kpts1 = img.find_keypoints(max_keypoints=150, threshold=10, scale_factor=1.2)
      image.save_descriptor(kpts1, "/%s.orb"%(FILE_NAME))
      img.save("/%s.pgm"%(FILE_NAME))

               draw_keypoints(img, kpts1)
           else:
               kpts3 = image.load_descriptor("/desc.orb")
               kpts2 = img.find_keypoints(max_keypoints=150, threshold=10, normalized=True)
           if (kpts2):
               match = image.match_descriptor( kpts3 , kpts2, threshold=85)
               if (match.count()>10):
      
                  img.draw_rectangle(match.rect())
                  img.draw_cross(match.cx(), match.cy(), size=10)
      
                  print(kpts2, "matched:%d dt:%d"%(match.count(), match.theta()))
      
                  img.draw_string(0, 0, "FPS:%.2f"%(clock.fps()))