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



    • 利用“histogram.get_threshold()”得到最佳阈值后,想使用“threshold.value()”拿出阈值,失败了..😭 😭

      THRESHOLD = [0, 100] # Grayscale threshold for dark things...
      BINARY_VISIBLE = True # Does binary first so you can see what the linear regression
                            # is being run on... might lower FPS though.
      
      import sensor, image, time
      from pyb import LED
      
      sensor.reset()
      sensor.set_pixformat(sensor.GRAYSCALE)
      sensor.set_framesize(sensor.QQQVGA) # 80x60 (4,800 pixels) - O(N^2) max = 2,3040,000.
      sensor.skip_frames(time = 2000)     # WARNING: If you use QQVGA it may take seconds
      clock = time.clock()                # to process a frame sometimes.
      
      LED(1).on()
      LED(2).on()
      LED(3).on()
      
      while(True):
          clock.tick()
          img = sensor.snapshot().lens_corr(strength = 0.5, zoom = 1.0)
          img.gaussian(3, unsharp=True)
      
          histogram = img.get_histogram()#得到直方图
          Thresholds = histogram.get_threshold()#得到最佳阈值
          THR=threshold.value()#获取当前阈值
      
          #img.binary([THRESHOLD])if BINARY_VISIBLE else sensor.snapshot()
      
          line = img.get_regression([(255,255) if BINARY_VISIBLE else THRESHOLD], robust = True)
      
          if (line): img.draw_line(line.line(), color = 127)
      
      

      0_1556531054977_1.PNG




    已锁定