导航

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

    sa5x 发布的帖子

    • img.draw_rectangle(b[0:4]) 中的b[0:4]是什么意思
              for b in blob:       
      
                  img.draw_rectangle(b[0:4]) # rect
      
                  img.draw_cross(b[5], b[6]) # cx, cy
      
                  x = b.cx()
      
                  y = b.cy()
      
                  data = bytearray([x,y])
      
                  uart.write(data)
          
      

      请问这段代码中 img.draw_rectangle(b[0:4]) 中的b[0:4]是什么意思;以及这里的在区域blob迭代的b究竟代表了什么?一个个像素点吗?但是这样的话之后的画十字与矩形又是用之前的区域框画的吗?

              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))
      

      请问这段代码的作用是什么?去函数库里找并未找到相关的(blob.major_axis_line()与(blob.minor_axis_line()
      非常感谢!

      发布在 OpenMV Cam
      S
      sa5x
    • 为何串口调试助手显示数据与其传输数据不符?

      由于时间以及资金问题,我采用了将openmv直接通过蓝牙模块传输至电脑PC端以查看其串口输出数据,但串口调试助手的显示数据与我所输出的数据不符。示波器显示有数据输出。
      示波器:0_1564118619736_CFA35C8BD642FA9FEA0609DE7CBB1B96.png
      串口显示数据:0_15641187g

      openmv代码:

      
      # Untitled - By: 小柱 - 周三 4月 17 2019
      
       
      
      import sensor, image, time
      
      from pyb import UART
      
      import json
      
       
      
      threshold = [(37, 67, 45, 84, 4, 68),         #red
      
                   (34, 67, -55, -22, 2, 41),      #green
      
                   (25, 67, -37, 26, -63, -26)]    #blue
      
      #设置红色的阈值,括号里面的数值分别是L A B 的最大值和最小值(minL, maxL, minA,
      
      # maxA, minB, maxB),LAB的值在图像左侧三个坐标图中选取。如果是灰度图,则只需
      
      #设置(min, max)两个数字即可。
      
       
      
      sensor.reset()
      
      sensor.set_pixformat(sensor.RGB565)
      
      sensor.set_framesize(sensor.QVGA)
      
      sensor.skip_frames(time = 2000 )
      
      sensor.set_auto_whitebal(False)
      
      #关闭白平衡。白平衡是默认开启的,在颜色识别中,需要关闭白平衡。
      
       
      
      clock = time.clock()
      
       
      
      uart = UART(3, 115200)
      
       
      
      uart.init(115200, bits=8, parity=None, stop=1)  #8位数据位,无校验位,1位停止位、
      
       
      
      while(True):
      
          clock.tick()
      
          img = sensor.snapshot()
      
          blob = img.find_blobs(threshold, area_threshold=300)
      
          if blob: #如果找到了目标颜色
      
             # print(blob)
      
             # uart.write("B3 B3 ")    #一帧数据的帧头
      
              FH = bytearray([0xb3,0xb3])
      
              uart.write(FH)
      
              for b in blob:
      
              #迭代找到的目标颜色区域
      
                  img.draw_rectangle(b[0:4]) # rect
      
                  img.draw_cross(b[5], b[6]) # cx, cy
      
                  x = b.cx()
                  y = b.cy()
      
                  print(x, y, end = ',')
      
                  data = bytearray([x,y])
      
                  uart.write(data)
      
                  #uart.write("%x %x \r"%(x,y))   #以16进制的格式输出,(16进制不能这样输出啊,浪费了我两天的时间)
      
          #img.draw_circle((50, 50, 30), color = (250, 0, 0))
      
          print(clock.fps())
      
      
      发布在 OpenMV Cam
      S
      sa5x