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



    • # Single Color RGB565 Blob Tracking Example
      #
      # This example shows off single color RGB565 tracking using the OpenMV Cam.
      
      import sensor, image, time, math
      #导入自带的模块
      
      threshold_index = 0     # 0 for red, 1 for green, 2 for blue
      #设置颜色的阈值,LAB的三个最大值,三个最小值
      # Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
      # The below thresholds track in general red/green/blue things. You may wish to tune them...
      thresholds = [(30, 100, 15, 127, 15, 127), # generic_red_thresholds
                    (30, 100, -64, -8, -32, 32), # generic_green_thresholds
                    (0, 15, 0, 40, -80, -2)] # generic_blue_thresholds
      
      sensor.reset()#重置感光元件,重置摄像机
      sensor.set_pixformat(sensor.RGB565)#重置颜色格式为RGB56
      sensor.set_framesize(sensor.QVGA)#图像的大小是QVGA
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False) # 务必要关闭白平衡
      sensor.set_auto_whitebal(False) # 务必要关闭自动增益
      #因为打开会影响颜色识别的效果,会使颜色的阈值发生改变
      clock = time.clock()
      
      # Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are
      # returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the
      # camera resolution. "merge=True" merges all overlapping blobs in the image.
      
      while(True):
          clock.tick()
          img = sensor.snapshot()#先截取感光元件的一张图片
          #在img.find_blobs这个函数中,进行颜色识别
          for blob in img.find_blobs([thresholds[threshold_index]], pixels_threshold=200, area_threshold=200, merge=True):
         #此处没有设置roi的值,便是对整个图像进行颜色识别
              # These values depend on the blob not being circular - otherwise they will be shaky.
              if blob.elongation() > 0.5:
                  img.draw_edges(blob.min_corners(), color=(255,0,0))
                  img.draw_line(blob.major_axis_line(), color=(0,255,0))
                  img.draw_line(blob.minor_axis_line(), color=(0,0,255))
              # These values are stable all the time.
              img.draw_rectangle(blob.rect())
              #如果识别到了颜色,我们就在这个色块的周围画一个框把它圈出来
              img.draw_cross(blob.cx(), blob.cy())
              #中间画一个十字,(blob.cx(), blob.cy())是色块的中心坐标
              # Note - the blob rotation is unique to 0-180 only.
              img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20)
              #blob是find_blobs返回的参数
          print(clock.fps())
      
      

      请在这里粘贴代码



    • 你的阈值是使用阈值助手测试的?

      https://singtown.com/learn/49993/