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



    • import sensor, image, time, math, pyb, lcd
      from pyb import UART
      #import m_lcd as lcd
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA2)
      lcd.init()
      sensor.skip_frames(time = 1000)
      sensor.set_auto_gain(False)
      sensor.set_auto_whitebal(False)
      sensor.set_auto_whitebal(False)
      clock = time.clock()
      tag_families = 0
      tag_families |= image.TAG16H5
      tag_families |= image.TAG25H7
      tag_families |= image.TAG25H9
      tag_families |= image.TAG36H10
      tag_families |= image.TAG36H11
      tag_families |= image.ARTOOLKIT
      
      def family_name(tag):
          if(tag.family() == image.TAG16H5):
              return "TAG16H5"
          if(tag.family() == image.TAG25H7):
              return "TAG25H7"
          if(tag.family() == image.TAG25H9):
              return "TAG25H9"
          if(tag.family() == image.TAG36H10):
              return "TAG36H10"
          if(tag.family() == image.TAG36H11):
              return "TAG36H11"
          if(tag.family() == image.ARTOOLKIT):
              return "ARTOOLKIT"
      
      def Wait_Ok():
          global uartSendFlag
          if uart.any():
              cmd = uart.readline().decode().strip()
              if(int(cmd) == 'K'):
                  uartSendFlag = True
      
      led1 = pyb.LED(1)
      led2 = pyb.LED(2)
      uart = pyb.UART(3, 9600)
      
      
      
      cCount = 0
      def workMode1():
          global uartSendFlag
          global aCount
          global bCount
          global cCount
          clock.tick()
          img = sensor.snapshot()
          rect_tuple = (0,160-22,128,22)
          img.draw_rectangle(rect_tuple, color=(255,0,0))
          img.draw_line((64,160-22,64,160), color=(255,0,0))
          img.draw_string(5, 160-20, "id:", color=(0, 255, 0), scale=1.6)
          img.draw_string(65, 160-20, "C:", color=(0, 255, 0), scale=1.6)
          for tag in img.find_apriltags(families=tag_families):
              led1.on()
              img.draw_rectangle(tag.rect(), color = (255, 0, 0))
              img.draw_cross(tag.cx(), tag.cy(), color = (0, 255, 0))
              print_args = (family_name(tag), tag.id(), (180 * tag.rotation()) / math.pi)
          #    print("Tag Family %s, Tag ID %d, rotation %f (degrees)" % print_args)
              id = print_args[1]
              cls = ''
              if id == 1:
                  cls = 'A'
                  img.draw_string(85, 160-20, str(aCount), color=(0, 255, 0), scale=1.6)
              elif id == 2:
                  cls = 'B'
                  img.draw_string(85, 160-20, str(bCount), color=(0, 255, 0), scale=1.6)
              elif id == 3:
                  cls = 'C'
                  img.draw_string(85, 160-20, str(cCount), color=(0, 255, 0), scale=1.6)
              img.draw_string(40, 160-20, cls, color=(0, 255, 0), scale=1.6)
      
              Wait_Ok()
              if id <= 3 and uartSendFlag == True:
                  uart.write(cls)
                  uartSendFlag = False
                  if cls == 'A':
                      aCount += 1
                  elif cls == 'B':
                      bCount += 1
                  elif cls == 'C':
                      cCount += 1
              led1.off()
          lcd.display(img)
          print("fps:%f" %clock.fps())
      
      
      green = (61, 23, -39, -17, 9, -19)
      red = (47, 39, 36, 96, 24, 71);
      yellow = (0, 63, -16, 4, 32, 79);
      greenCount = 0
      redCount = 0
      yellowCount = 0
      
      
      
      def doWork():
         # mode = GetWork_Mode()
          #while True:
           #   if mode == 1:
                  workMode1()
            #  elif mode == 2:
            #      workMode2()
             # else:
                  doWork()
      
      while(True):
          doWork()
      


    • 我使用OpenMV4 H7 Plus没有问题。

      你用的是什么硬件?

      什么固件版本?

      我看有代码里有串口,是在串口接受的时候断开连接?