导航

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

    李大庄 发布的帖子

    • 颜色形状同时识别问题

      我在学颜色形状同时识别那个例程,然后想在里面加个框加个十字架标注一下我的圆的,但是就会报错,错误是list index out of range,想请教一下为什么

      import sensor, image, time
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False) # must be turned off for color tracking
      sensor.set_auto_whitebal(False) # must be turned off for color tracking
      clock = time.clock()
      red_threshold_01=(0,45,-28,82,-46,68)
      while(True):
          clock.tick()
          img = sensor.snapshot().lens_corr(1.8)
          for c in img.find_circles(threshold = 2000, x_margin = 20, y_margin = 20, r_margin = 20,
                  r_min = 2, r_max = 100, r_step = 2):
              area = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r())
              #area为识别到的圆的区域,即圆的外接矩形框
              statistics = img.get_statistics(roi=area)#像素颜色统计
              print(statistics)
              #(0,100,0,120,0,120)是红色的阈值,所以当区域内的众数(也就是最多的颜色),范围在这个阈值内,就说明是红色的圆。
              #l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。
      
      
      #以下为我自己改的部分
              blobs = img.find_blobs([red_threshold_01])
              if blobs :
                  print(blobs)
                  img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))#识别到的红色圆形用红色的圆框出来
                  img.draw_cross(blobs[5], blobs[6])
                  img.draw_rectangle(blobs[0:4])
      #就这段话,报了错误为 list index out of range
      
                  
              else:
                  img.draw_rectangle(area, color = (255, 255, 255))
                  #将非红色的圆用白色的矩形框出来
          print("FPS %f" % clock.fps())
      
      发布在 OpenMV Cam
      李
      李大庄
    • RE: 无人机搭载Openmv闪白灯

      @yuan 我们就接了四根线,一个电一个地,一个输入一个输出,数据基本还是有的啊,只是时不时闪白灯

      发布在 OpenMV Cam
      李
      李大庄
    • RE: 无人机搭载Openmv闪白灯

      用的是例程啊

      
      # 色块监测 例子
      #
      # 这个例子展示了如何通过find_blobs()函数来查找图像中的色块
      # 这个例子查找的颜色是深绿色
      
      from pyb import UART
      import json
      import sensor, image, time
      # 颜色追踪的例子,一定要控制环境的光,保持光线是稳定的。
      #green_threshold   = (   15,   45,  15,   40,   -80,   -40)
      green_threshold=(64, 44, 12, 86, 52, -15);
      #设置绿色的阈值,括号里面的数值分别是L A B 的最大值和最小值(minL, maxL, minA,
      # maxA, minB, maxB),LAB的值在图像左侧三个坐标图中选取。如果是灰度图,则只需
      #设置(min, max)两个数字即可。
      
      sensor.reset() # 初始化摄像头
      sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565.
      sensor.set_framesize(sensor.QVGA) # 使用 QaaaaaaQVGA 速度快一些
      sensor.skip_frames(10) # 跳过10帧,使新设置生效
      sensor.set_auto_whitebal(False)
      #关闭白平衡。白平衡是默认开启的,在颜色识别中,一定要关闭白平衡。
      clock = time.clock() # 追踪帧率
      uart = UART(3, 115200)
      
      while(True):
          clock.tick() # Track elapsed milliseconds between snapshots().
          img = sensor.snapshot() # 从感光芯片获得一张图像
      
          blobs = img.find_blobs([green_threshold],x_stride=10,y_stride=10)
          if blobs:
          #如果找到了目标颜色
              last_pixels=0;
              data=[]
              out_=blobs[0];
              for b in blobs:
              #迭代找到的目标颜色区域
                  # Draw a rect around the blob.
                  if b.pixels()>last_pixels:
                      last_pixels=b.pixels();
                      out_=b;
              img.draw_rectangle(out_[0:4]);
                  #用矩形标记出目标颜色区域
              img.draw_cross(out_[5], out_[6],color=(0,255,0)) # cx, cy
                 # print("fps:%d local:%d,%d" % (clock.fps() ,b[5], b[6]))
             # img.draw_string(10,20, "local:%d,%d"% (b[5], b[6]),color=(128,0,0))
                  #在目标颜色区域的中心画十字形标记
              data.append((out_[5], out_[6]))
              data_out = json.dumps(set(data))
              uart.write(data_out +'\n')
              print(data_out)
      

      请问有什么问题吗

      发布在 OpenMV Cam
      李
      李大庄
    • 无人机搭载Openmv闪白灯

      用openmv来寻找红十字,无人机飞上去后,识别到了,但是时不时闪白灯,一闪白灯就无人机就飘,个人感觉闪白灯是openmv在重新启动,不知道对不对,并且想问为什么识别到红十字,在没有对openmv拔电的情况下还会亮白灯?我该怎么解决?请指教,正在比赛,晚上就截止了,急急急急急急!谢谢

      发布在 OpenMV Cam
      李
      李大庄
    • 无人机搭载openmv识别红色模块,经常传不回数据

      用的是例程 色块检测的例程检测红色十字架,然后有时候可以检测得到数据,有时候检测不到,而且感觉跟光的强弱有很大的关系,灯光一弱,就识别不到红色模块了,请问有什么改进的方法吗,正在参加比赛,急急急,识别的是红色十字架
      例程代码如下

      
      # 色块监测 例子
      #
      # 这个例子展示了如何通过find_blobs()函数来查找图像中的色块
      # 这个例子查找的颜色是深绿色
      
      from pyb import UART
      import json
      import sensor, image, time
      # 颜色追踪的例子,一定要控制环境的光,保持光线是稳定的。
      #green_threshold   = (   15,   45,  15,   40,   -80,   -40)
      green_threshold=(64, 44, 12, 86, 52, -15);
      #设置绿色的阈值,括号里面的数值分别是L A B 的最大值和最小值(minL, maxL, minA,
      # maxA, minB, maxB),LAB的值在图像左侧三个坐标图中选取。如果是灰度图,则只需
      #设置(min, max)两个数字即可。
      
      sensor.reset() # 初始化摄像头
      sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565.
      sensor.set_framesize(sensor.QVGA) # 使用 QaaaaaaQVGA 速度快一些
      sensor.skip_frames(10) # 跳过10帧,使新设置生效
      sensor.set_auto_whitebal(False)
      #关闭白平衡。白平衡是默认开启的,在颜色识别中,一定要关闭白平衡。
      clock = time.clock() # 追踪帧率
      uart = UART(3, 115200)
      
      while(True):
          clock.tick() # Track elapsed milliseconds between snapshots().
          img = sensor.snapshot() # 从感光芯片获得一张图像
      
          blobs = img.find_blobs([green_threshold],x_stride=10,y_stride=10)
          if blobs:
          #如果找到了目标颜色
              last_pixels=0;
              data=[]
              out_=blobs[0];
              for b in blobs:
              #迭代找到的目标颜色区域
                  # Draw a rect around the blob.
                  if b.pixels()>last_pixels:
                      last_pixels=b.pixels();
                      out_=b;
              img.draw_rectangle(out_[0:4]);
                  #用矩形标记出目标颜色区域
              img.draw_cross(out_[5], out_[6],color=(0,255,0)) # cx, cy
                 # print("fps:%d local:%d,%d" % (clock.fps() ,b[5], b[6]))
             # img.draw_string(10,20, "local:%d,%d"% (b[5], b[6]),color=(128,0,0))
                  #在目标颜色区域的中心画十字形标记
              data.append((out_[5], out_[6]))
              data_out = json.dumps(set(data))
              uart.write(data_out +'\n')
              print(data_out)
      
      
      发布在 OpenMV Cam
      李
      李大庄