• 星瞳AI VISION软件内测!可以离线标注,训练,并生成OpenMV的模型。可以替代edge impulse https://forum.singtown.com/topic/8206
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 脱机与连电脑得到的值不同



    • 为什么使用openmv求寻迹偏差值的时候脱机运行和连电脑时得到的值不同,连电脑的时候很完美,脱机错误很大



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



    • import sensor, image, time
      from pyb import UART,LED
      import json
      write_threshold=(0, 19, 28, -33, 122, -2)
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.VGA)
      sensor.set_windowing((504,480))
      sensor.set_vflip(True)
      sensor.set_hmirror(True)
      sensor.skip_frames(time = 2000)
      clock = time.clock()
      quyu=[278,278,278,278,278,278,278,278,278,278]
      LED(1).on()
      LED(2).on()
      LED(3).on()
      lx=0
      x=0
      k=0
      t=0
      m=0
      last=0
      l=0
      uart=UART(3,115200)
      def find_max(blobs):
       max_size=0
       for blob in blobs:
        if blob.pixels()>max_size:
         max_blob=blob
         max_size = blob.pixels()
        return max_blob
      while(True):
        clock.tick()
        img=sensor.snapshot ()
        for n in range(0,10):
         blobs = img.find_blobs([write_threshold],roi=[193,480-48*(n+1),172,48],x_stride=20,y_stride=20,x_stride=400)
         img.draw_rectangle((193,480-48*(n+1),172,48),color=(231,188,105))
         max_blob=find_max(blobs)
         if blobs:
          for blob in blobs:
           img.draw_cross(max_blob.cx(), max_blob.cy())
           quyu[n]=max_blob.cx()
           m+=1
           if m>=2:
            k+=(max_blob.cx()-lx)/48
           lx=max_blob.cx()
         x=x+quyu[n]
        blobs = img.find_blobs([write_threshold],roi=[53,80,100,80])
        max_blob=find_max(blobs)
        if blobs:
         for blob in blobs:
          img.draw_cross(max_blob.cx(), max_blob.cy())
          t+=max_blob.cx()
        blobs = img.find_blobs([write_threshold],roi=[53,240,452,80])
        max_blob=find_max(blobs)
        if blobs:
         for blob in blobs:
          l=max_blob.w()
        if m!=0:
         last=x/10+k*30/m
        if l>200:
         t=666
        if k>1:
         k=1
        if k<-1:
         k=-1
        print(last-278,t)
        output_str="%.3d, %.3d" % (last,t)
        lx=0
        x=0
        k=0
        t=0
        m=0
        uart.write('\n'+output_str+'\r')
        img.draw_rectangle((53,80,100,80),color=(231,188,105))
        img.draw_rectangle((53,240,452,80), color=(231,188,105))
      
      


    • @kidswong999

      import sensor, image, time
      from pyb import UART,LED
      import json
      write_threshold=(0, 19, 28, -33, 122, -2)
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.VGA)
      sensor.set_windowing((504,480))
      sensor.set_vflip(True)
      sensor.set_hmirror(True)
      sensor.skip_frames(time = 2000)
      clock = time.clock()
      quyu=[278,278,278,278,278,278,278,278,278,278]
      LED(1).on()
      LED(2).on()
      LED(3).on()
      lx=0
      x=0
      k=0
      t=0
      m=0
      last=0
      l=0
      uart=UART(3,115200)
      def find_max(blobs):
       max_size=0
       for blob in blobs:
        if blob.pixels()>max_size:
         max_blob=blob
         max_size = blob.pixels()
        return max_blob
      while(True):
        clock.tick()
        img=sensor.snapshot ()
        for n in range(0,10):
         blobs = img.find_blobs([write_threshold],roi=[193,480-48*(n+1),172,48],x_stride=20,y_stride=20,x_stride=400)
         img.draw_rectangle((193,480-48*(n+1),172,48),color=(231,188,105))
         max_blob=find_max(blobs)
         if blobs:
          for blob in blobs:
           img.draw_cross(max_blob.cx(), max_blob.cy())
           quyu[n]=max_blob.cx()
           m+=1
           if m>=2:
            k+=(max_blob.cx()-lx)/48
           lx=max_blob.cx()
         x=x+quyu[n]
        blobs = img.find_blobs([write_threshold],roi=[53,80,100,80])
        max_blob=find_max(blobs)
        if blobs:
         for blob in blobs:
          img.draw_cross(max_blob.cx(), max_blob.cy())
          t+=max_blob.cx()
        blobs = img.find_blobs([write_threshold],roi=[53,240,452,80])
        max_blob=find_max(blobs)
        if blobs:
         for blob in blobs:
          l=max_blob.w()
        if m!=0:
         last=x/10+k*30/m
        if l>200:
         t=666
        if k>1:
         k=1
        if k<-1:
         k=-1
        print(last-278,t)
        output_str="%.3d, %.3d" % (last,t)
        lx=0
        x=0
        k=0
        t=0
        m=0
        uart.write('\n'+output_str+'\r')
        img.draw_rectangle((53,80,100,80),color=(231,188,105))
        img.draw_rectangle((53,240,452,80), color=(231,188,105))
      


    • 代码没看出来有什么问题,你是不是环境光源不一致?