导航

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

    w23d 发布的帖子

    • RE: 为什么串口助手接收不到这个代码的数据?

      @kidswong999 历程可以跑
      0_1689085764445_2.png

      发布在 OpenMV Cam
      W
      w23d
    • 为什么串口助手接收不到这个代码的数据?

      我的串口和波特率都没有选错

      # 利用特征点检测特定物体例程。
      # 向相机显示一个对象,然后运行该脚本。 一组关键点将被提取一次,然后
      # 在以下帧中进行跟踪。 如果您想要一组新的关键点,请重新运行该脚本。
      # 注意:请参阅文档以调整find_keypoints和match_keypoints。
      import sensor, time, image, math 
      from pyb import UART
      from struct import pack, unpack
      import json
      # Reset sensor
      sensor.reset()
      uart = UART(3, 115200)
      
      # Sensor settings
      sensor.set_contrast(3)
      sensor.set_gainceiling(16)
      sensor.set_framesize(sensor.VGA)
      sensor.set_windowing((320, 240))
      sensor.set_pixformat(sensor.GRAYSCALE)
      
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False, value=100)
      
      #画出特征点
      def draw_keypoints(img, kpts):
          if kpts:
              print(kpts)
              img.draw_keypoints(kpts)
              img = sensor.snapshot()
              time.sleep_ms(1000)
      
      kpts1 = None
      #kpts1保存目标物体的特征,可以从文件导入特征,但是不建议这么做。
      #kpts1 = image.load_descriptor("/desc.orb")
      #img = sensor.snapshot()
      #draw_keypoints(img, kpts1)
      
      clock = time.clock()
      
      while (True):
          clock.tick()
          img = sensor.snapshot()
          if (kpts1 == None):
              kpts1 = img.find_keypoints(max_keypoints=150, threshold=10, scale_factor=1.2)
              draw_keypoints(img, kpts1)
          else:
              kpts2 = img.find_keypoints(max_keypoints=150, threshold=10, normalized=True)
              if (kpts2):
                  match = image.match_descriptor(kpts1, kpts2, threshold=85)
                  if (match.count()>10):
                      img.draw_rectangle(match.rect())
                      img.draw_cross(match.cx(), match.cy(), size=10)
                      bx_x=match.cx()-160
                      by_y=120-match.cy()
                      x=int(math.fabs(bx_x))
                      y=int(math.fabs(by_y))
                  #print(kpts2, "matched:%d dt:%d"%(match.count(), match.theta()))
                      data = bytearray([x,y])
                      uart.write(data)
                      print(data)
          img.draw_string(0, 0, "FPS:%.2f"%(clock.fps()))
      
      
      发布在 OpenMV Cam
      W
      w23d