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



    • 曝光率和识别速度有关系吗?

      # 红外RGB565跟踪示例
      
      #
      
      # 这个例子展示了使用OpenMV Cam进行红外RGB565跟踪。
      
      
      import sensor, image
      import time
      #from numba import jit
      from pyb import UART
      
      import json
      import utime
      
      import pyb
      
      #EXPOSURE_TIME_SCALE = 0.1
      thresholds = (100,100,0,0,0,0) # thresholds for bright white light from IR.
      
      TimeBin = [0,0]
      TimeBox = [0,0]
      
      sensor.reset()
      
      sensor.set_pixformat(sensor.RGB565)
      
      sensor.set_framesize(sensor.QQQVGA)
      
      #sensor.set_windowing((60,80)) #将相机的分辨率设置为当前分辨率的子分辨率
      
      sensor.set_auto_gain(False) # must be turned off for color tracking
      
      sensor.set_auto_whitebal(False) # must be turned off for color tracking
      
      sensor.skip_frames(time = 10)
      sensor.get_exposure_us()#以毫秒为单位返回曝光率
      
      sensor.set_auto_exposure(False,exposure_us=100)#设置曝光
      
      
      
      
      #sensor.set_auto_exposure(False, \
         # exposure_us = int(current_exposure_time_in_microseconds* EXPOSURE_TIME_SCALE))
      
      
      clock = time.clock() # Tracks FPS.
      
      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):
          #utime.sleep_ms(50)
          #for i in range(0,6000):
          clock.tick()# Track elapsed milliseconds between snapshots().
          
         
          img = sensor.snapshot()#binary([thresholds], invert=True, zero=True)
          TimeBox[1]= TimeBox[0]
          TimeBox[0] = utime.ticks_ms()
          deal = utime.ticks_diff(TimeBox[0],TimeBox[1])
          print("deal :",deal)
         # start = utime.ticks_ms()
          blobs=img.find_blobs([thresholds],pixels_threshold=200,area_threshold=250)
      
      
          if blobs:
      
            output_str = json.dumps(blobs)
      
            max_blob=find_max(blobs)
      
            img.draw_rectangle(max_blob.rect(),color=(255,0,0))
      
            output_str="[%d,%d]" % (max_blob.cx(),max_blob.cy())
      
            #print('you send:',output_str)
            uart.write(output_str+'\n')
      
           # print("Initial exposure == %d" % sensor.set_auto_exposure())
      
            #current_exposure_time_in_microseconds=sensor.get_exposure_us()
      
            #sensor.set_auto_exposure(False, \
               # exposure_us = int(sensor.get_exposure_us() * EXPOSURE_TIME_SCALE))
            print("New exposure == %d" % sensor.get_exposure_us())
            
            TimeBin[1] = TimeBin[0]
            TimeBin[0] = utime.ticks_ms()
            delta= utime.ticks_diff(TimeBin[0], TimeBin[1])
            print('duration:',delta)
      
            print("FPS:", clock.fps())
      
                  #img.draw_cross(blob.cx(), blob.cy())
          else:
      
                      print('not found!')
      
      
      
      
      
      
      


    • 0_1588689283645_1588689136(1).png 测试结果



    • 每一个新的提问,单独发一个新帖子,我现在说“为什么设置的曝光率和测试出的值不一样?”

      测试代码:

      import sensor, image
      import time
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQQVGA)
      #sensor.set_windowing((60,80)) #将相机的分辨率设置为当前分辨率的子分辨率
      sensor.set_auto_gain(False) # must be turned off for color tracking
      sensor.set_auto_whitebal(False) # must be turned off for color tracking
      sensor.set_auto_exposure(False,exposure_us=196)#设置曝光
      sensor.skip_frames(time = 1000)
      while(True):
          print("New exposure == %d" % sensor.get_exposure_us())
      
      

      结果:设置的196,获取到192。
      0_1588739950961_4b349884-88fe-42e3-8c18-6b628dc9e859-image.png

      原因:设置曝光值是按照档位设置的。会自动找到最接近的档位。