星瞳实验室APP,快速收到回复
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 出现莫名起码的报错,不知道为什么报错



    • import sensor, time, image,pyb
      from pyb import Pin, Timer
      from pyb import LED
      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)
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False)
      sensor.set_auto_whitebal(False)
      p1 = Pin("P7", Pin.OUT_PP)
      p2 = Pin("P8", Pin.OUT_PP)
      p3 = Pin("P4", Pin.OUT_PP)
      led1 = pyb.LED(1)
      led2 = pyb.LED(2)
      led3 = pyb.LED(3)
      kpts3 = image.load_descriptor("/a3.orb")
      kpts4 = image.load_descriptor("/a4.orb")
      kpts5 = image.load_descriptor("/a5.orb")
      kpts51 = image.load_descriptor("/a51.orb")
      kpts6 = image.load_descriptor("/a6.orb")
      kpts61 = image.load_descriptor("/a61.orb")
      kpts7 = image.load_descriptor("/a7.orb")
      kpts71 = image.load_descriptor("/a71.orb")
      kpts8 = image.load_descriptor("/a8.orb")
      kpts81 = image.load_descriptor("/a81.orb")
      clock = time.clock()
      light = Timer(2, freq=50000).channel(1, Timer.PWM, pin=Pin("P6"))
      light.pulse_width_percent(1)
      while (True):
          clock.tick()
          time.sleep(1)
          img = sensor.snapshot()
          if (kpts3 == None):
              kpts3 = img.find_keypoints(max_keypoints=150, threshold=10, scale_factor=1.2)
          else:
              kpts2 = img.find_keypoints(max_keypoints=150, threshold=10, normalized=True)
              if (kpts2):
                  match3 = image.match_descriptor(kpts3, kpts2, threshold=85)
                  match4 = image.match_descriptor(kpts4, kpts2, threshold=85)
                  match5 = image.match_descriptor(kpts5, kpts2, threshold=85)
                  match51 = image.match_descriptor(kpts51, kpts2, threshold=85)
                  match6 = image.match_descriptor(kpts6, kpts2, threshold=85)
                  match61 = image.match_descriptor(kpts61, kpts2, threshold=85)
                  match7 = image.match_descriptor(kpts7, kpts2, threshold=85)
                  match71 = image.match_descriptor(kpts71, kpts2, threshold=85)
                  match8 = image.match_descriptor(kpts8, kpts2, threshold=85)
                  match81 = image.match_descriptor(kpts81, kpts2, threshold=85)
                  if (match3.count()>15):
                      img.draw_rectangle(match3.rect())
                      img.draw_cross(match3.cx(), match3.cy(), size=10)
                      print("3")
                      p1.high()
                      p2.low()
                      p3.low()
                  if (match4.count()>15):
                      img.draw_rectangle(match4.rect())
                      img.draw_cross(match4.cx(), match4.cy(), size=10)
                      print("4")
                      p1.low()
                      p2.high()
                      p3.low()
                  if (match5.count()>15):
                      img.draw_rectangle(match5.rect())
                      img.draw_cross(match5.cx(), match5.cy(), size=10)
                      print("5")
                      p1.low()
                      p2.low()
                      p3.high()
                  if (match51.count()>15):
                      img.draw_rectangle(match51.rect())
                      img.draw_cross(match51.cx(), match51.cy(), size=10)
                      print("51")
                      p1.low()
                      p2.low()
                      p3.high()
                  if (match6.count()>15):
                      img.draw_rectangle(match6.rect())
                      img.draw_cross(match6.cx(), match6.cy(), size=10)
                      print("6")
                      p1.high()
                      p2.high()
                      p3.low()
                  if (match61.count()>15):
                      img.draw_rectangle(match61.rect())
                      img.draw_cross(match61.cx(), match61.cy(), size=10)
                      print("61")
                      p1.high()
                      p2.high()
                      p3.low()
                  if (match7.count()>15):
                      img.draw_rectangle(match7.rect())
                      img.draw_cross(match7.cx(), match7.cy(), size=10)
                      print("7")
                      p1.low()
                      p2.high()
                      p3.high()
                  if (match71.count()>15):
                      img.draw_rectangle(match71.rect())
                      img.draw_cross(match71.cx(), match71.cy(), size=10)
                      print("71")
                      p1.low()
                      p2.high()
                      p3.high()
                  if (match8.count()>15):
                      img.draw_rectangle(match8.rect())
                      img.draw_cross(match8.cx(), match8.cy(), size=10)
                      print("8")
                      p1.high()
                      p2.low()
                      p3.high()
                  if (match81.count()>15):
                      img.draw_rectangle(match81.rect())
                      img.draw_cross(match81.cx(), match81.cy(), size=10)
                      print("81")
                      p1.high()
                      p2.low()
                      p3.high()
      

      0_1625305306317_1NZY8MWXMJ079~2S25$0@)6.jpg
      用的plus



    • 0_1625305374552_1NZY8MWXMJ079~2S25$0@)6.jpg



    • 报错图片在评论的啊



    • 不要一开始把所有的全部load进来,在for循环里lord。

      for循环里也不要把所有match_descriptor的对象复制到变量里,内存爆了。

      参考:https://book.openmv.cc/image/mulity-template-match.html