• OpenMV VSCode 扩展发布了,在插件市场直接搜索OpenMV就可以安装
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • openmv偶尔发问号,是硬件问题吗,波特率不稳定?



    • 大多数情况不会。



    • 好像是有时候发不出



    • 如果涉及代码,需要报错提示与全部代码文本,请注意不要贴代码图片

      还有具体的现象。



    • @kidswong999 没有报错,就是偶尔会发出问号



    • @xhk5 提供具体的代码,和问号的截图



    • @kidswong999 # Single Color Code Tracking Example
      #
      # This example shows off single color code tracking using the OpenMV Cam.
      #
      # A color code is a blob composed of two or more colors. The example below will
      # only track colored objects which have both the colors below in them.
      
      import sensor, image, time, math
      
      # Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
      # The below thresholds track in general red/green things. You may wish to tune them...
      #hongse
      thresholds1 = [(30, 100, 15, 127, 15, 127),
                    (30, 100, -64, -8, -32, 32)]
      #lvse
      thresholds2=[(59, 37, -67, -21, 22, 49),
                  (59, 37, -127, -21, 10, 127)]
      #lanse
      thresholds3=[(39, 60, -18, -3, -49, -11),
                  (0, 100, -18, -3, -49, -11)]
      
      
      
      
      import time
      from pyb import UART
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False) # must be turned off for color tracking
      sensor.set_auto_whitebal(False) # must be turned off for color tracking
      clock = time.clock()
      uart = UART(3,115200)
      # Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are
      # returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the
      # camera resolution. "merge=True" must be set to merge overlapping color blobs for color codes.
      a=0
      d=0
      b=1
      t=0
      while(True):
          img = sensor.snapshot().lens_corr(strength = 1.8, zoom = 1.0)
          if t==0 and uart.any():
              m=uart.read(1).decode()
              if m!='o':
                  a=int(m)
      
              clock.tick()
      
      
      
              for blob in img.find_blobs(thresholds1, pixels_threshold=10, area_threshold=10, merge=True):
                  if blob.code() == 3: # r/g code == (1 << 1) | (1 << 0)
      
                      img.draw_rectangle(blob.rect())
                      img.draw_cross(blob.cx(), blob.cy())
                      # Note - the blob rotation is unique to 0-180 only.
                      img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20)
      
                      b=1
                      #print(b)
                      #print(a)
                      print('lse')
      
      
      
      
      
              for blob in img.find_blobs(thresholds2, pixels_threshold=10, area_threshold=10, merge=True):
                  if blob.code() == 3: # r/g code == (1 << 1) | (1 << 0)
      
                      img.draw_rectangle(blob.rect())
                      img.draw_cross(blob.cx(), blob.cy())
                      # Note - the blob rotation is unique to 0-180 only.
                      img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20)
      
                      b=3
                      #print(b)
                      #print(a)
                      #print(c)
                      print('hse')
      
      
      
              for blob in img.find_blobs(thresholds3, pixels_threshold=10, area_threshold=10, merge=True):
                  if blob.code() == 3: # r/g code == (1 << 1) | (1 << 0)
      
                      img.draw_rectangle(blob.rect())
                      img.draw_cross(blob.cx(), blob.cy())
                      # Note - the blob rotation is unique to 0-180 only.
                      img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20)
      
                      b=5
      
      
                  print(b)
              if a==b or a==b+1 :
                      uart.write("d")
      
              elif a!=b and b==3:
                  uart.write("G")
                  uart.write("G")
                  n=3
      
                  d=a
      
                  t=1
              elif  a!=b and b==5:
                  uart.write("B")
      
                  d=a
      
                  t=1
              else:
                  uart.write("d")
              print(t)
              print(a)
              print(b)
              print(d)
          if t==1 and uart.any():
              p=0
              n=uart.read(1).decode()
              if n!='o':
                  r=int(n)
      
              clock.tick()
      
      
      
      
              for blob in img.find_blobs(thresholds1, pixels_threshold=10, area_threshold=10, merge=True):
                  if blob.code() == 3: # r/g code == (1 << 1) | (1 << 0)
      
                      img.draw_rectangle(blob.rect())
                      img.draw_cross(blob.cx(), blob.cy())
                      # Note - the blob rotation is unique to 0-180 only.
                      img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20)
      
                      p=1
                      #print(b)
                      #print(a)
      
      
      
      
      
      
              for blob in img.find_blobs(thresholds2, pixels_threshold=10, area_threshold=10, merge=True):
                  if blob.code() == 3: # r/g code == (1 << 1) | (1 << 0)
      
                      img.draw_rectangle(blob.rect())
                      img.draw_cross(blob.cx(), blob.cy())
                      # Note - the blob rotation is unique to 0-180 only.
                      img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20)
      
                      p=3
                      #print(b)
                      #print(a)
                      #print(c)
      
      
      
      
              for blob in img.find_blobs(thresholds3, pixels_threshold=10, area_threshold=10, merge=True):
                  if blob.code() == 3: # r/g code == (1 << 1) | (1 << 0)
      
                      img.draw_rectangle(blob.rect())
                      img.draw_cross(blob.cx(), blob.cy())
                      # Note - the blob rotation is unique to 0-180 only.
                      img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20)
      
                      p=5
      
              if p==d or p==d-1:
                  uart.write("F")
      
                  t=0
      
              else:
                  uart.write("d")
      
              print(t)
              print(r)
              print(p)
              print(d)
      


    • 大多数情况没问题,但是有时候发不出字母,有时候发问号,尤其发生在和工控机通讯的时候



    • 0_1680100391758_1680100293312.jpg



    • 代码我看了没什么问题,都是发送的字符。
      1,检查一下接收端串口的停止位,检验位对不对。
      2,检查一下串口线是不是太长了,有时候有干扰。
      3,检查一下串口线是不是接触不好。

      解决办法:
      1,超过10cm使用串口,波特率越高越容易干扰,ttl转成rs232再传输。
      2,再软件上自己加入检验。