find_apriltags_w_lens_zoom.py
# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# AprilTags示例
#
# 本示例展示OpenMV Cam检测AprilTags的强大能力
# 在OpenMV Cam M7上。M4版本无法检测April标签。
import csi
import time
import math
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.VGA)
csi0.window((160, 120)) # 仅查看VGA分辨率中心的160x120像素。
csi0.snapshot(time=2000)
csi0.auto_gain(False) # 必须关闭此功能以防止图像褪色...
csi0.auto_whitebal(False) # 必须关闭此功能以防止图像褪色...
clock = time.clock()
# 注意!与find_qrcodes不同,find_apriltags方法不需要对图像进行镜头校正即可工作。
# 标签家族之间有什么区别?例如,TAG16H5家族实际上是
# 4x4的方形标签。这意味着它比6x6方形的TAG36H11标签
# 能在更远的距离被识别。但更低的H值(H5对比H11)意味着
# 4x4标签的误报率远远高于6x6标签。所以,除非您有
# 使用其他标签家族的理由,否则请使用默认的TAG36H11家族。
while True:
clock.tick()
img = csi0.snapshot()
for tag in img.find_apriltags(): # 默认为TAG36H11
img.draw_detection(tag, color1=(255, 0, 0), color2=(0, 255, 0))
print_args = (tag.name, tag.id, (180 * tag.rotation) / math.pi)
print("Tag Family %s, Tag ID %d, rotation %f (degrees)" % print_args)
print(clock.fps())