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



    • # 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,utime,lcd
      from pyb import Servo
      from pyb import Pin
      # For color tracking to work really well you should ideally be in a very, very,
      # very, controlled enviroment where the lighting is constant...
      red_threshold_01 = (0, 24, -22, 43, -8, 41)
      
      #设置红色的阈值,括号里面的数值分别是L A B 的最大值和最小值(minL, maxL, minA,
      # maxA, minB, maxB),LAB的值在图像左侧三个坐标图中选取。如果是灰度图,则只需
      #设置(min, max)两个数字即可。
      
      # 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.
      lcd.init() # Initialize the lcd screen.
      sensor.skip_frames(50) # Let new settings take affect.
      p_in00 = Pin("P5", Pin.IN)#设置p0输入
      p_in00.value()
      sensor.set_auto_whitebal(False)
      #关闭白平衡。白平衡是默认开启的,在颜色识别中,需要关闭白平衡。
      clock = time.clock() # Tracks FPS.
      start = utime.ticks_ms() # get value of millisecond counter  获取毫秒计数器的值
      
      while(True):
          sensor.set_vflip(True) #垂直方向翻转
          if(p_in00.value()==0):
              print(p_in00.value())
              while(True):
                  clock.tick() # Track elapsed milliseconds between snapshots().
                  img = sensor.snapshot() # Take a picture and return the image.
                  #  pixels_threshold=100, area_threshold=100
                  blobs = img.find_blobs([red_threshold_01], area_threshold=150)
      
                  if blobs:
                  #如果找到了目标颜色
      
                      for b in blobs:
                      #迭代找到的目标颜色区域
                          # Draw a rect around the blob.
      
                          if(blobs[0].pixels())>6000:
                              tt=utime.ticks_diff(utime.ticks_ms(), start)
                              print(utime.ticks_diff(utime.ticks_ms(), start))
                              img.draw_rectangle(b[0:4]) # rect
                              #用矩形标记出目标颜色区域
                              img.draw_cross(b[5], b[6]) # cx, cy
                              #在目标颜色区域的中心画十字形标记
                              while(True):
                                  lcd.display(img.draw_string(20,0, "%d"%tt,200,2))
                                  lcd.display(sensor.snapshot()) # Take a picture and display the image.
              #print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
              # connected to your computer. The FPS should increase once disconnected.
      
      ```![0_1600781440466_QLBF0`0`7}KRUMHUIS5R817.png](https://fcdn.singtown.com/8c273a79-0a34-45b7-9334-bf0159cd5015.png)


    • 在同学的openmv就不会卡顿,但是我用新的就不行,一会好,一会就两三秒卡死。求大佬帮忙解决。



    • 这个代码目的就是识别到颜色,并从开始到识别到颜色这段时间进行及时



    • 代码逻辑的问题,

      你的程序有死循环,还没有break,当然不会跳出。