星瞳实验室APP,快速收到回复
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • openmv的帧率太低了几乎是2帧每秒,如何提高帧率!



    • # Blob Detection Example
      #
      # This example shows off how to use the find_blobs function to find color
      # blobs in the image. This example in particular looks for dark green objects.
      
      import sensor, image, time, pyb
      from pyb import UART
      
      # You may need to tweak the above settings for tracking green things...
      # Select an area in the Framebuffer to copy the color settings.
      
      sensor.reset() # Initialize the camera sensor.
      sensor.set_pixformat(sensor.RGB565) # use RGB565.
      sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
      sensor.skip_frames(10) # Let new settings take affect.
      sensor.set_auto_whitebal(False) # turn this off.
      clock = time.clock() # Tracks FPS.
      
      #sensor.set_windowing((100, 100))
      
      # For color tracking to work really well you should ideally be in a very, very,
      # very, controlled enviroment where the lighting is constant...
      green_threshold   = (54, 95, -4, 30, 22, 70)
      size_threshold = 1500
      blue_led = pyb.LED(3)
      green_led = pyb.LED(2)
      red_led = pyb.LED(1)
      uart = UART(3, 9600)
      sensor.set_auto_exposure(True, exposure_us=5000) # make smaller to go faster
      
      def find_max(blobs):
          max_size=0
          for blob in blobs:
              if blob[2]*blob[3] > max_size:
                  max_blob=blob
                  max_size = blob[2]*blob[3]
          return max_blob
      
      while(True):
          clock.tick() # Track elapsed milliseconds between snapshots().
          img = sensor.snapshot() # Take a picture and return the image.
          blobs = img.find_blobs([green_threshold])
          #FZ = bytearray([0x55,0x55,0x12,0x03,0x03,0xd0,0x07,0x01,0xa1,0x02,0x02,0x04,0x05,0x03,0x6c,0x06])
          #FZ1 = bytearray([0x55,0x55,0x14,0x03,0x05,0xd0,0x07,0x01,0x05,0x09,0x02,0x4c,0x05,0x03,0xe9,0x02,0x04,0xc1,0x07,0x05,0x24,0x02])
          #FZ1 = bytearray([0x55,0x55,0x08,0x03,0x01,0xd0,0x07,0x01,0x05,0x09])
          #uart.write(FZ1)
          
          #FZ2 = bytearray([0x55,0x55,0x08,0x03,0x02,0xd0,0x07,0x02,0x4c,0x05])
          #uart.write(FZ2)
          #time.sleep_ms(1000)
          #FZ3 = bytearray([0x55,0x55,0x08,0x03,0x03,0xd0,0x07,0x03,0xe9,0x02])
          #uart.write(FZ3)
          #time.sleep_ms(1000)
          #FZ4 = bytearray([0x55,0x55,0x08,0x03,0x04,0xd0,0x07,0x04,0xc1,0x07])
          #uart.write(FZ)
          time.sleep_ms(1000)
          xiangshu=0
          
          if blobs:
              max_blob = find_max(blobs)
              max_blob1=find_max1(blobs)
              xiangshu = max_blob.blob[4]
              img.draw_rectangle(max_blob[0:4]) # rect
              img.draw_cross(max_blob[5], max_blob[6]) # cx, cy
              if xiangshu > size_threshold:
                          #FZ = bytearray([0x55,0x55,0x05,0x06,0x64,0x01,0x00])
                          #art.write(FZ)
                          red_led.on()
                          time.sleep_ms(150)#延时150ms
                          red_led.off()
              else:
                          blue_led.on()
                          time.sleep_ms(150)     #延时150ms    
                          blue_led.off()
              
          else:
              green_led.on()
              time.sleep_ms(150)     #延时150ms    
              green_led.off()
      


    • 把time.sleep都删掉。延时了当然低。