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



    • 0_1536655839403_OX.png
      想实现自适应阈值对图像进行阈值分割,使用img.histogram.get_threhsold()函数得到阈值时出现错误提示: AttributeError:'bound_method' object has no attribute 'get_threshold',不知道是不是自己函数写错了,不知道有没有人可以帮忙解惑一下

      while(True):
          clock.tick()
          img = sensor.snapshot().lens_corr(1.0)
      #   image.get_histogram()
          th = img.histogram.get_threhsold([roi])
      #   th = (42, 100, -128, 127, -128, 127)
          img.binary([th],invert = True)
      


    • 请提供全部的代码



    • # Find Rects Example
      #
      # This example shows off how to find rectangles in the image using the quad threshold
      # detection code from our April Tags code. The quad threshold detection algorithm
      # detects rectangles in an extremely robust way and is much better than Hough
      # Transform based methods. For example, it can still detect rectangles even when lens
      # distortion causes those rectangles to look bent. Rounded rectangles are no problem!
      # (But, given this the code will also detect small radius circles too)...
      
      import sensor, image, time, lcd
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565) # grayscale is faster (160x120 max on OpenMV-M7)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      clock = time.clock()
      lcd.init()
      
      roi = (80,0,80,120)#搜索矩形的图像区域
      
      #kernel_size = 1 # kernel width = (size*2)+1, kernel height = (size*2)+1
      #kernel = [-1, -1, -1,\
      #         -1, +9, -1,\
      #         -1, -1, -1]
      
      
      
      while(True):
          clock.tick()
          img = sensor.snapshot().lens_corr(1.0)
      #   th = img.histogram.get_threhsold([roi])
      
      #   img.binary([th],invert = True)
      #   img.find_edges(image.EDGE_CANNY, threshold=(50, 80))
      #   img.laplacian(2)
      
      
      
          # `threshold` below should be set to a high enough value to filter out noise
          # rectangles detected in the image which have low edge magnitudes. Rectangles
          # have larger edge magnitudes the larger and more contrasty they are...
      
          for r in img.find_rects(roi,threshold = 10000):
              statistics = img.get_statistics(roi=r.rect())
              print(statistics)
              if statistics.mean() <= 50:
                 img.draw_rectangle(r.rect(), color = (255, 0, 0))
                 for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
              lcd.display(img)
              print(r.rect())
      
          print("FPS %f" % clock.fps())
      
      


    • @kidswong999

      # Find Rects Example
      #
      # This example shows off how to find rectangles in the image using the quad threshold
      # detection code from our April Tags code. The quad threshold detection algorithm
      # detects rectangles in an extremely robust way and is much better than Hough
      # Transform based methods. For example, it can still detect rectangles even when lens
      # distortion causes those rectangles to look bent. Rounded rectangles are no problem!
      # (But, given this the code will also detect small radius circles too)...
      
      import sensor, image, time, lcd
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565) # grayscale is faster (160x120 max on OpenMV-M7)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      clock = time.clock()
      lcd.init()
      
      roi = (80,0,80,120)#搜索矩形的图像区域
      
      #kernel_size = 1 # kernel width = (size*2)+1, kernel height = (size*2)+1
      #kernel = [-1, -1, -1,\
      #         -1, +9, -1,\
      #         -1, -1, -1]
      
      
      
      while(True):
          clock.tick()
          img = sensor.snapshot().lens_corr(1.0)
      #   th = img.histogram.get_threhsold([roi])
      
      #   img.binary([th],invert = True)
      #   img.find_edges(image.EDGE_CANNY, threshold=(50, 80))
      #   img.laplacian(2)
      
      
      
          # `threshold` below should be set to a high enough value to filter out noise
          # rectangles detected in the image which have low edge magnitudes. Rectangles
          # have larger edge magnitudes the larger and more contrasty they are...
      
          for r in img.find_rects(roi,threshold = 10000):
              statistics = img.get_statistics(roi=r.rect())
              print(statistics)
              if statistics.mean() <= 50:
                 img.draw_rectangle(r.rect(), color = (255, 0, 0))
                 for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
              lcd.display(img)
              print(r.rect())
      
          print("FPS %f" % clock.fps())
      
      


    • img = sensor.snapshot().lens_corr(1.0)
      hist = img.get_histogram()
      th = hist.get_threshold()