导航

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

    zmrn

    @zmrn

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

    zmrn 关注

    zmrn 发布的帖子

    • RE: 请问像是一条线上两种颜色的巡线该如何实现?

      请问是如何操作呢?直接thresholds = [(颜色阈值),颜色阈值,颜色阈值]的话

      img = sensor.snapshot().binary([THRESHOLDS])
      这里就是报错TypeError: can't convert tuple to int
      发布在 OpenMV Cam
      Z
      zmrn
    • 请问像是一条线上两种颜色的巡线该如何实现?

      0_167861388.png

      
      R_THRESHOLD = (59, 25, 127, 19, -128, 89)
      G_THRESHOLD = (0, 100, -69, -32, -47, 82)
      import sensor, image, time,lcd
      from pyb import LED
      from pyb import UART
      import ustruct
      
      
      
      LED(1).on()
      LED(2).on()
      LED(3).on()
      
      uart = UART(3,115200,bits=8, parity=None, stop=1, timeout_char = 1000)
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQQVGA) # 80x60 (4,800 pixels) - O(N^2) max = 2,3040,000.
      lcd.init() # Initialize the lcd screen.
      sensor.set_vflip(True)
      sensor.set_hmirror(True)
      #sensor.set_windowing([0,20,80,40])
      sensor.skip_frames(time = 2000)     # WARNING: If you use QQVGA it may take seconds
      clock = time.clock()
                    # to process a frame sometimes.
      def sending_data(data1,data2):
          global uart;
          data=bytearray([0xA5,data1,data2,0XA6])
          '''data1= ustruct.pack("<bbb",      #格式为俩个字符俩个短整型(2字节)
                         0xA5,                      #帧头
                         data1,
                         data2,
                         0xA6
                         )     '''   #数组大小为7,其中2,3,4,5为有效数据,0,1,6为帧头帧尾
          uart.write(data);   #必须要传入一个字节数组
          #print("head",data[0],"status",data[1],"tail",data[2])
      
      while(True):
          clock.tick()
          img = sensor.snapshot().binary([R_THRESHOLD] )  
          #img.mean(0)
          line = img.get_regression([(100,100)], robust = True)
      
          #img.midpoint(1, bias=0.5, threshold=True, offset=5, invert=True)
          if (line):
              '''rho_err = abs(line.rho())-img.width()/2
              if line.theta()>90:
                  theta_err = line.theta()-180
              else:
                  theta_err = line.theta()
              img.draw_line(line.line(), color = 127)
              print(rho_err,theta_err)
              if line.magnitude()>8:
                sending_data((int)(rho_err),(int)(theta_err))'''         
                         
              rho_err = abs(line.rho())
              theta_err = line.theta()
              img.draw_line(line.line(), color = 127)
      
              if line.magnitude()>8:
                  sending_data((int)(rho_err),(int)(theta_err))
              rho_err_temp = abs(line.rho())-img.width()/2
              if line.theta()>90:
                  theta_err_temp = line.theta()-180
              else:
                  theta_err_temp = line.theta()
              print(rho_err_temp,theta_err_temp,line.magnitude())
      
              pass
          lcd.display(img)
          #print(clock.fps())
      
      
      发布在 OpenMV Cam
      Z
      zmrn