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



    • :RuntimeError:Frame size is not supported or is not set



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



    • THRESHOLD =(79, 93, -24, 16, -19, 22)
      THRESHOLD1 =(77, 94, -22, 18, -15, 17)
      THRESHOLDG = (56, 78, -31, 1, -19, 25)
      THRESHOLDB = (43, 71, -10, 20, -52, -9)
      THRESHOLDR = (38, 67, 5, 41, -26, 24)
      GRAYSCALE_THRESHOLD = (240, 255)
      GRAYSCALE_THRESHOLD1 = (117, 86)
      # Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!
      xingzhuang=0
      import sensor, image, time,json,pyb,math,cpufreq
      from pyb import LED,UART,Pin,Timer
      from image import SEARCH_EX, SEARCH_DS
      roi_x=0
      roi_y=0
      roi_w=0
      roi_h=0
      uart = UART(3, 9600,timeout_char = 0)
      sensor.reset()                      # Reset and initialize the sensor.
      sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
      sensor.set_framesize(sensor.FHD)   # Set frame size to QVGA (320x240)
      sensor.skip_frames(time = 1900)     # Wait for settings take effect.
      clock = time.clock()                # Create a clock object to track the FPS.
      sensor.set_vflip(True)
      sensor.set_hmirror(True)
      img = sensor.snapshot()
      #pyb.delay(600)
      blobs = img.find_blobs([THRESHOLD],pixels_threshold=200000, area_threshold=5000,merge=False)                               # to the IDE. The FPS should increase once disconnected.
      if blobs:
              img.draw_rectangle(blobs[0].rect(),color=(0,0,255))
              img.draw_cross(blobs[0].cx(),blobs[0].cy(),color=(0,0,255))
              a=blobs[0].x()+8
              b=blobs[0].y()+8
              c=blobs[0].w()-20
              d=blobs[0].h()-28
              print('白色',a,b,c,d)
              sensor.set_windowing((a,b,c,d))
      #sensor.set_windowing((206,103,180,240)) #取中间的640*80区域
      #print('cpu:',cpufreq.get_current_frequencies())
      
      while(True):
          clock.tick()
          #pyb.delay(900)
          img = sensor.snapshot()
          print(clock.fps())
          sum = 0
          for l in img.find_line_segments(merge_distance = 250, max_theta_diff = 20):
              #area = (l.x1(),l.y2(),l.x2()-l.x1(),l.y2()-l.y1())
              #statistics = img.get_statistics(roi=area)
              #img.draw_line(l.line(),color = (255,0,0))
              #img.draw_cross(l.x1(),l.y1(),color=(255,0,0))
              #img.draw_cross(l.x2(),l.y2(),color=(255,0,0))
              sum += l.theta()
          sum-=90
          print(sum)
          if sum < 200 and sum >160:
              print('三角形')
              xingzhuang=1
          if sum >70 and sum <120:
              print('正方形')
              xingzhuang=2
          if sum >380:
              print('圆形')
              xingzhuang=3
          roi_x=0
          roi_y=0
          roi_w=0
          roi_h=0
          yanse=0
          blobs = img.find_blobs([THRESHOLDB],pixels_threshold=1000, area_threshold=600,merge=False)                               # to the IDE. The FPS should increase once disconnected.
          if blobs:
              img.draw_rectangle(blobs[0].rect(),color=(0,0,255))
              #img.draw_cross(blobs[0].cx(),blobs[0].cy(),color=(0,0,255))
              print('蓝色')
              roi_x=blobs[0].x()
              roi_y=blobs[0].y()
              roi_w=blobs[0].w()
              roi_h=blobs[0].h()
              yanse=1
              m=blobs[0].pixels()
              print('像素数:',m)
              #img.binary([THRESHOLDB],invert=True)
              #img.erode(3)
              #img.dilate(4)
              pyb.delay(6)
          blobs = img.find_blobs([THRESHOLDR],pixels_threshold=200, area_threshold=20,merge=False)                               # to the IDE. The FPS should increase once disconnected.
          if blobs:
              #img.draw_rectangle(blobs[0].rect(),color=(255,0,0))
              #img.draw_cross(blobs[0].cx(),blobs[0].cy(),color=(255,0,0))
              print('红色')
              roi_x=blobs[0].x()
              roi_y=blobs[0].y()
              roi_w=blobs[0].w()
              roi_h=blobs[0].h()
              yanse=2
              m=blobs[0].pixels()
              print('像素数:',m)
              pyb.delay(6)
          blobs = img.find_blobs([THRESHOLDG],pixels_threshold=2000, area_threshold=200,merge=False)                               # to the IDE. The FPS should increase once disconnected.
          if blobs:
              #img.draw_rectangle(blobs[0].rect(),color=(0,255,0))
              #img.draw_cross(blobs[0].cx(),blobs[0].cy(),color=(0,255,0))
              roi_x=blobs[0].x()
              roi_y=blobs[0].y()
              roi_w=blobs[0].w()
              roi_h=blobs[0].h()
              print('绿色')
              yanse=3
              #img.binary([THRESHOLDG],invert=True)
              m=blobs[0].pixels()
              print('像素数:',m)
              pyb.delay(6)
          if xingzhuang==3:
              blobs = img.find_blobs([THRESHOLD1],pixels_threshold=20000, area_threshold=2000,roi=(roi_x,roi_y,roi_w,roi_h),merge=False)                               # to the IDE. The FPS should increase once disconnected.
              if blobs:
                   img.draw_rectangle(blobs[0].rect(),color=(255,255,255))
                   img.draw_cross(blobs[0].cx(),blobs[0].cy(),color=(255,255,255))
                   kuandu=(roi_w-blobs[0].w())/2*(210/(c+20))
                   print('宽度:',kuandu,'mm')
                   juli=math.sqrt(pow(blobs[0].cx(),2)+pow(blobs[0].cy(),2))*(210/(c-10))
                   print('圆心距离左上角:',juli,'mm')
                   pyb.delay(6)
          if xingzhuang==2:
              blobs = img.find_blobs([THRESHOLD1],pixels_threshold=20000, area_threshold=2000,roi=(roi_x,roi_y,roi_w,roi_h),merge=False)                               # to the IDE. The FPS should increase once disconnected.
              if blobs:
                   img.draw_rectangle(blobs[0].rect(),color=(255,255,255))
                   img.draw_cross(blobs[0].cx(),blobs[0].cy(),color=(255,255,255))
                   kuandu=(roi_w-blobs[0].w())/2*(210/(c+20))
                   gaodu=(roi_h-blobs[0].h())/2*(210/(c+20))
                   xiankuan=(kuandu+gaodu)/2
                   kuandu1=(roi_w+blobs[0].w())/2*(210/(c+20))
                   gaodu1=(roi_h+blobs[0].h())/2*(210/(c+20))
                   print('宽度:',kuandu1,'mm')
                   print('高度:',gaodu1,'mm')
                   data=[]
                   data.append((xingzhuang,yanse,int(xiankuan),int(kuandu1),int(gaodu1),0))
                   data_out = json.dumps(set(data))
                   uart.write(data_out +'\n')
                   print('you send:',data_out)
                   pyb.delay(6)
          if xingzhuang==1:
              cishu=0
              zhouchang=0
              xianchang=[0,0,0,0,0,0,0,0]
              for l in img.find_line_segments(merge_distance = 20000, max_theta_diff = 20):
                  img.draw_line(l.line(),color = (255,0,0))
                  changdu=l.length()*(210/(c-25))
                  print('长度',cishu,':',changdu)
                  xianchang[cishu]=changdu
                  cishu=cishu+1
                  zhouchang=changdu+zhouchang
              if cishu==3:
                  print('周长:',zhouchang)
                  xiankuan=(m*((210/(c-20))*(210/(c-20))))/zhouchang
                  print('线宽:',xiankuan)
                  data=[]
                  #data.append((xingzhuang,yanse,int(zhouchang),int(xiankuan)))
                  data.append((xingzhuang,yanse,int(xiankuan),int(xianchang[0]),int(xianchang[1]),int(xianchang[2])))
                  data_out = json.dumps(set(data))
                  uart.write(data_out +'\n')
                  print('you send:',data_out)
              pyb.delay(6)
          xingzhuang=0
          m=0
      
      


    • 全部代码文本如下



    • 使用的什么硬件?是OpenMV4 Plus吗?





    • 我使用官方的板子,OpenMV4 H7 Plus,sensor OV5640,不是你这个报错。你确定你用的是官方的板子?



    • @kidswong999 是啊 在你们淘宝店铺买了俩块顶配



    • @fc3i 那我建议你寄回检查一下。