导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. zrmt
    Z
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    zrmt

    @zrmt

    0
    声望
    3
    楼层
    304
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    zrmt 关注

    zrmt 发布的帖子

    • 如何识别三个颜色,我这点开只能识别红色不能识别绿色蓝色
      # 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())
      
      

      请在这里粘贴代码

      发布在 OpenMV Cam
      Z
      zrmt
    • 进行颜色识别的时候,为什么图像中红色物体旁出现三种不同的线在那里不停闪烁,所框住的部位还不是红色物块本身。

      0_1638001487992_935e0c43-edb8-4513-b99f-bea7916aa2e2.png

      发布在 OpenMV Cam
      Z
      zrmt