导航

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

    openmv 发布的帖子

    • RE: AprilTag定位

      @kidswong999 好的,谢谢

      发布在 OpenMV Cam
      O
      openmv
    • AprilTag定位

      请问用AprilTag进行定位的具体原理是什么啊?

      发布在 OpenMV Cam
      O
      openmv
    • 打印输出

      请问怎么样可以在打印输出矩形长度的时候只打印一行?就是摄像头不动的时候就只打印一行数据,而不是一直跳动着打印数据,就每次变化的时候只打印一行数据,不动就不打印数据?

      发布在 OpenMV Cam
      O
      openmv
    • RE: openmv绘制文字

      @kidswong999 显示要填的确定位置啊,而且绘制的文字不是要求字符串的吗?
      我想在这个机器人寻线的例程里在识别到的最近的黑色色块矩形中绘制出矩形的长度要怎么改啊?

      Black Grayscale Line Following Example

      跟随机器人做一条线需要很多努力。 本示例脚本显示了如何执行跟随机器人的

      机器视觉部分。 您可以使用此脚本的输出来驱动差分驱动机器人遵循一条线。

      这个脚本只是产生一个转动的值,告诉你的机器人向左或向右。

      为了使这个脚本正常工作,你应该把摄像机指向45度左右的一条线。请确保只有线在相机的视野内。

      import sensor, image, time, math

      Tracks a black line. Use [(128, 255)] for a tracking a white line.

      GRAYSCALE_THRESHOLD = [(0, 64)]
      #设置阈值,如果是黑线,GRAYSCALE_THRESHOLD = [(0, 64)];
      #如果是白线,GRAYSCALE_THRESHOLD = [(128,255)]

      Each roi is (x, y, w, h). The line detection algorithm will try to find the

      centroid of the largest blob in each roi. The x position of the centroids

      will then be averaged with different weights where the most weight is assigned

      to the roi near the bottom of the image and less to the next roi and so on.

      ROIS = [ # [ROI, weight]
      (0, 100, 160, 20, 0.7), # You'll need to tweak the weights for you app
      (0, 050, 160, 20, 0.3), # depending on how your robot is setup.
      (0, 000, 160, 20, 0.1)
      ]
      #roi代表三个取样区域,(x,y,w,h,weight),代表左上顶点(x,y)宽高分别为w和h的矩形,
      #weight为当前矩形的权值。注意本例程采用的QQVGA图像大小为160x120,roi即把图像横分成三个矩形。
      #三个矩形的阈值要根据实际情况进行调整,离机器人视野最近的矩形权值要最大,
      #如上图的最下方的矩形,即(0, 100, 160, 20, 0.7)

      Compute the weight divisor (we're computing this so you don't have to make weights add to 1).

      weight_sum = 0 #权值和初始化
      for r in ROIS: weight_sum += r[4] # r[4] is the roi weight.
      #计算权值和。遍历上面的三个矩形,r[4]即每个矩形的权值。

      Camera setup...

      sensor.reset() # Initialize the camera sensor.
      sensor.set_pixformat(sensor.GRAYSCALE) # use grayscale.
      sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
      sensor.skip_frames(30) # Let new settings take affect.
      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() # Tracks FPS.

      while(True):
      clock.tick() # Track elapsed milliseconds between snapshots().
      img = sensor.snapshot() # Take a picture and return the image.

      centroid_sum = 0
      #利用颜色识别分别寻找三个矩形区域内的线段
      for r in ROIS:
          blobs = img.find_blobs(GRAYSCALE_THRESHOLD, roi=r[0:4], merge=True) 
          # r[0:4] is roi tuple.
          #找到视野中的线,merge=true,将找到的图像区域合并成一个
      
          #目标区域找到直线
          if blobs:
              # Find the index of the blob with the most pixels.
              most_pixels = 0
              largest_blob = 0
              for i in range(len(blobs)):
              #目标区域找到的颜色块(线段块)可能不止一个,找到最大的一个,作为本区域内的目标直线
                  if blobs[i].pixels() > most_pixels:
                      most_pixels = blobs[i].pixels()
                      #merged_blobs[i][4]是这个颜色块的像素总数,如果此颜色块像素总数大于                     #most_pixels,则把本区域作为像素总数最大的颜色块。更新most_pixels和largest_blob
                      largest_blob = i
      
              # Draw a rect around the blob.
              img.draw_rectangle(blobs[largest_blob].rect())
              #将此区域的像素数最大的颜色块画矩形和十字形标记出来
              img.draw_cross(blobs[largest_blob].cx(),
                             blobs[largest_blob].cy())
      
              centroid_sum += blobs[largest_blob].cx() * r[4] # r[4] is the roi weight.
              #计算centroid_sum,centroid_sum等于每个区域的最大颜色块的中心点的x坐标值乘本区域的权值
      
      center_pos = (centroid_sum / weight_sum) # Determine center of line.
      #中间公式
      
      # Convert the center_pos to a deflection angle. We're using a non-linear
      # operation so that the response gets stronger the farther off the line we
      # are. Non-linear operations are good to use on the output of algorithms
      # like this to cause a response "trigger".
      deflection_angle = 0
      #机器人应该转的角度
      
      # The 80 is from half the X res, the 60 is from half the Y res. The
      # equation below is just computing the angle of a triangle where the
      # opposite side of the triangle is the deviation of the center position
      # from the center and the adjacent side is half the Y res. This limits
      # the angle output to around -45 to 45. (It's not quite -45 and 45).
      deflection_angle = -math.atan((center_pos-80)/60)
      #角度计算.80 60 分别为图像宽和高的一半,图像大小为QQVGA 160x120.    
      #注意计算得到的是弧度值
      
      # Convert angle in radians to degrees.
      deflection_angle = math.degrees(deflection_angle)
      #将计算结果的弧度值转化为角度值
      
      # Now you have an angle telling you how much to turn the robot by which
      # incorporates the part of the line nearest to the robot and parts of
      # the line farther away from the robot for a better prediction.
      print("Turn Angle: %f" % deflection_angle)
      #将结果打印在terminal中
      
      print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
      # connected to your computer. The FPS should increase once disconnected.
      发布在 OpenMV Cam
      O
      openmv
    • RE: openmv绘制文字

      @yuan 你好,我试了一下好像不行😥

      发布在 OpenMV Cam
      O
      openmv
    • RE: openmv绘制文字

      @yuan 好的,谢谢

      发布在 OpenMV Cam
      O
      openmv
    • openmv绘制文字

      openmv可以在窗口上绘制文字,请问如何在窗口上实时地显示识别到的矩形的长度啊?就是随着长度的变化数字也变化?

      发布在 OpenMV Cam
      O
      openmv
    • openmv测距

      请问如果想要实现这个视频里面的现象具体的代码怎么写?

      发布在 OpenMV Cam
      O
      openmv
    • 图像处理

      请问用openmv怎么实现拍摄前后两张图片相减啊?有具体的例程吗?

      发布在 OpenMV Cam
      O
      openmv
    • RE: 提取画面

      @yuan 不是很懂😔

      发布在 OpenMV Cam
      O
      openmv
    • 提取画面

      请问如何在拍摄的图像中提取中间的一小块画面啊?谢谢

      发布在 OpenMV Cam
      O
      openmv
    • 关于AprilTag测距的问题

      请问一下关于AprilTag测距的原理是什么啊?谢谢!

      发布在 OpenMV Cam
      O
      openmv
    • RE: 光流检测

      @kidswong999 请问用光流检测这个例程怎么改可以实现控制红绿灯的变化呢,就是实现镜头远离图像时红灯亮,镜头靠近时绿灯亮?
      #图像微分光流旋转/缩放测量
      BLOCK_W = 16 # pow2
      BLOCK_H = 16 # pow2
      import sensor, image, time, math
      import sensor
      import time
      import math
      import ide
      #支持64x32, 64x64,128x64,128x128. 32x32 需要对 64x64 image 使用 "img.pool(2, 2)"
      sensor.reset()
      sensor.set_pixformat(sensor.GRAYSCALE)
      sensor.set_framesize(sensor.B128X128)
      sensor.skip_frames(time = 2000)
      clock = time.clock()
      extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.GRAYSCALE)
      extra_fb.replace(sensor.snapshot())
      while(True):
      clock.tick()
      img = sensor.snapshot()
      for y in range(0, sensor.height(), BLOCK_H):
      for x in range(0, sensor.width(), BLOCK_W):
      displacement = extra_fb.find_displacement(img, logpolar=True,roi = (x, y, BLOCK_W, BLOCK_H), template_roi = (x, y, BLOCK_W, BLOCK_H))
      if(displacement.response() > 0.1):
      rotation_change = displacement.rotation()
      zoom_amount = 1.0 + displacement.scale()
      pixel_x = x + (BLOCK_W//2) + int(math.sin(rotation_change) * zoom_amount * (BLOCK_W//4))
      pixel_y = y + (BLOCK_H//2) + int(math.cos(rotation_change) * zoom_amount * (BLOCK_H//4))
      img.draw_line((x + BLOCK_W//2, y + BLOCK_H//2, pixel_x, pixel_y),color = 255)
      else:
      img.draw_line((x + BLOCK_W//2, y + BLOCK_H//2, x + BLOCK_W//2, y + BLOCK_H//2),color = 0)
      ide.display(img)
      extra_fb.replace(img)
      print(clock.fps())

      发布在 OpenMV Cam
      O
      openmv
    • RE: 光流检测

      @kidswong999 如果不用测出具体的距离呢?只要通过xy的变化量来控制红绿灯的变化就行

      发布在 OpenMV Cam
      O
      openmv
    • 光流检测

      请问可以用光流检测来做距离控制红绿灯吗?

      发布在 OpenMV Cam
      O
      openmv
    • RE: 请问用openmv通过镜头离画面的远近控制红绿灯怎么实现啊?

      @kidswong999 好吧,谢谢

      发布在 OpenMV Cam
      O
      openmv
    • RE: 请问用openmv通过镜头离画面的远近控制红绿灯怎么实现啊?

      如果没有特殊的参考物,就是随便拍摄的画面要怎么做呢?

      发布在 OpenMV Cam
      O
      openmv
    • 请问用openmv通过镜头离画面的远近控制红绿灯怎么实现啊?

      请问用openmv通过镜头离画面的远近控制红绿灯怎么实现啊?

      发布在 OpenMV Cam
      O
      openmv
    • RE: 请问用openmv做测距时比如镜头远离图像时绿灯亮,镜头靠近图像时红灯亮要怎样实现?

      @kidswong999 不会测距

      发布在 OpenMV Cam
      O
      openmv