python 使用apriltag检测二维码

使用二维码来标定相机外参时,可用python的apriltag库来检测二维码,代码示例如下:

import cv2
import apriltag

# 设置AprilTag检测器的参数
options = apriltag.DetectorOptions(families='tag36h11', border=1)

# 初始化AprilTag检测器
at_detector = apriltag.Detector(options)

# 读取图像
image = cv2.imread('qr_code.png')

# 将图像转换为灰度图像
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# 检测AprilTag
tags = at_detector.detect(gray)

# 遍历检测到的AprilTag
for tag in tags:
    print('Tag ID:', tag.tag_id)
    print('Tag Center:', tag.center)
    print('Tag Corners:', tag.corners)

    # 画出AprilTag的边界框
    for pt in tag.corners:
        cv2.circle(image, tuple(map(int, pt)), 5, (0, 255, 0), -1)

# 显示图像
cv2.imshow('AprilTag Detection', image)
cv2.waitKey(0)
cv2.destroyAllWindows()

注:以上代码为chatgpt生成

在使用时,为了能有更好的检测效果,可以传入丰富的options参数,如下图所示(apriltag官方文档):
在这里插入图片描述

在这里插入图片描述

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值