导航

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

    twy4

    @twy4

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

    twy4 关注

    twy4 发布的帖子

    • RE: lmportError: no module named 'nn'没有神经网络nn的数据包

      请问你解决这个问题了吗

      发布在 OpenMV Cam
      twy4
    • 请问如何提取赛道中心线?

      回复: 请问如何绘制赛道中心线
      纯白色的赛道,两边有黑色边缘,无其它颜色的干扰,赛道只包含一个弯道。请问如何绘制赛道的中心线,然后再获取到摄像头最下方中心线点的坐标

      发布在 OpenMV Cam
      twy4
    • 提取双线计算中间赛道的程序,报错了,请问是怎么回事?
      ROIS = [ # [ROI, weight]
              (0, 0, 80, 120, 0.5), # You'll need to tweak the weights for you app
              (80, 0, 80, 120, 0.5) # depending on how your robot is setup.
             ]
      weight_sum = 0 #权值和初始化
      #for r in ROIS: weight_sum += r[2] # r[4] is the roi weight.A
             #计算权值和。遍历上面的三个矩形,r[4]即每个矩形的权值。
      # This is called the fast linear regression because we use the least-squares
      # method to fit the line. However, this method is NOT GOOD FOR ANY images that
      # have a lot (or really any) outlier points which corrupt the line fit...
      
      #设置阈值,(0,100)检测黑色线
      THRESHOLD = (0, 100) # Grayscale threshold for dark things...
      
      #设置是否使用img.binary()函数进行图像分割
      BINARY_VISIBLE = True # Does binary first so you can see what the linear regression
                            # is being run on... might lower FPS though.
      
      import sensor, image, time
      import json
      from pyb import UART
      uart = UART(3, 9600)
      sensor.reset()
      sensor.set_pixformat(sensor.GRAYSCALE)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      clock = time.clock()
      
      while(True):
          clock.tick()
          img = sensor.snapshot().binary([THRESHOLD]) if BINARY_VISIBLE else sensor.snapshot()
          centroid_sum = 0
          for r in ROIS:
            blobs = img.find_blobs(THRESHOLD , roi=r[0:2], merge=True)
          # Returns a line object similar to line objects returned by find_lines() and
          # find_line_segments(). You have x1(), y1(), x2(), y2(), length(),
          # theta() (rotation in degrees), rho(), and magnitude().
          #
          # magnitude() represents how well the linear regression worked. It goes from
          # (0, INF] where 0 is returned for a circle. The more linear the
          # scene is the higher the magnitude.
          #函数返回回归后的线段对象line,有x1(), y1(), x2(), y2(), length(), theta(), rho(), magnitude()参数。
          #x1 y1 x2 y2分别代表线段的两个顶点坐标,length是线段长度,theta是线段的角度。
          #magnitude表示线性回归的效果,它是(0,+∞)范围内的一个数字,其中0代表一个圆。如果场景线性回归的越好,这个值越大。
          line = img.get_regression([(255,255) if BINARY_VISIBLE else THRESHOLD])
          if (line): img.draw_line(line.line(), color = 127)
          arveage_x1 += line.x1 ()*r[4]
          arveage_x2 += line.x2 ()*r[4]
          arveage_y1 += line.y1 ()*r[4]
          arveage_y2 += line.y2 ()*r[4]
          arveage_theta += line.theta()*r[4]
          img.draw_line(arveage_x1,arveage_y1,arveage_x2,arveage_y2, color = 80)
          print("FPS %f, mag = %s" % (clock.fps(), str(line.magnitude()) if (line) else "N/A"))
      
      # About negative rho values:
      #
      # A [theta+0:-rho] tuple is the same as [theta+180:+rho].
          data_out = str(line.theta())
          uart.write(data_out )
          time.sleep(100)
          print("OUT",data_out)
      
      

      0_1634203002262_{0X0Z_G0S1YXKJOOLP%25MI.png 0_1634203004974_VYN)M.png

      发布在 OpenMV Cam
      twy4
    • RE: 请问这段代码中line.x1 ()*r[4] 这里的*r[4]后得到的结果有什么具体含义吗?

      注释r中说r[4]为每个矩形的权值,但我仍然不理解坐标乘以权值能得到什么,或者说有什么含义?

      发布在 OpenMV Cam
      twy4
    • 请问这段代码中line.x1 ()*r[4] 这里的*r[4]后得到的结果有什么具体含义吗?
      ROIS = [ # [ROI, weight]
              (0, 0, 80, 120, 0.5), # You'll need to tweak the weights for you app
              (80, 0, 80, 120, 0.5) # depending on how your robot is setup.
             ]
      weight_sum = 0 #权值和初始化
      #for r in ROIS: weight_sum += r[2] # r[4] is the roi weight.A
             #计算权值和。遍历上面的三个矩形,r[4]即每个矩形的权值。
      # This is called the fast linear regression because we use the least-squares
      # method to fit the line. However, this method is NOT GOOD FOR ANY images that
      # have a lot (or really any) outlier points which corrupt the line fit...
      
      #设置阈值,(0,100)检测黑色线
      THRESHOLD = (0, 100) # Grayscale threshold for dark things...
      
      #设置是否使用img.binary()函数进行图像分割
      BINARY_VISIBLE = True # Does binary first so you can see what the linear regression
                            # is being run on... might lower FPS though.
      
      import sensor, image, time
      import json
      from pyb import UART
      uart = UART(3, 9600)
      sensor.reset()
      sensor.set_pixformat(sensor.GRAYSCALE)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      clock = time.clock()
      
      while(True):
          clock.tick()
          img = sensor.snapshot().binary([THRESHOLD]) if BINARY_VISIBLE else sensor.snapshot()
          centroid_sum = 0
          for r in ROIS:
            blobs = img.find_blobs(THRESHOLD , roi=r[0:2], merge=True)
          # Returns a line object similar to line objects returned by find_lines() and
          # find_line_segments(). You have x1(), y1(), x2(), y2(), length(),
          # theta() (rotation in degrees), rho(), and magnitude().
          #
          # magnitude() represents how well the linear regression worked. It goes from
          # (0, INF] where 0 is returned for a circle. The more linear the
          # scene is the higher the magnitude.
          #函数返回回归后的线段对象line,有x1(), y1(), x2(), y2(), length(), theta(), rho(), magnitude()参数。
          #x1 y1 x2 y2分别代表线段的两个顶点坐标,length是线段长度,theta是线段的角度。
          #magnitude表示线性回归的效果,它是(0,+∞)范围内的一个数字,其中0代表一个圆。如果场景线性回归的越好,这个值越大。
          line = img.get_regression([(255,255) if BINARY_VISIBLE else THRESHOLD])
          if (line): img.draw_line(line.line(), color = 127)
          arveage_x1 += line.x1 ()*r[4]
          arveage_x2 += line.x2 ()*r[4]
          arveage_y1 += line.y1 ()*r[4]
          arveage_y2 += line.y2 ()*r[4]
          arveage_theta += line.theta()*r[4]
          img.draw_line(arveage_x1,arveage_y1,arveage_x2,arveage_y2, color = 80)
          print("FPS %f, mag = %s" % (clock.fps(), str(line.magnitude()) if (line) else "N/A"))
      
      # About negative rho values:
      #
      # A [theta+0:-rho] tuple is the same as [theta+180:+rho].
          data_out = str(line.theta())
          uart.write(data_out )
          time.sleep(100)
          print("OUT",data_out)
      
      发布在 OpenMV Cam
      twy4