Example: 06-April-Tags/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 sensor
import time
import math
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.VGA)
sensor.set_windowing((160, 120)) # Look at center 160x120 pixels of the VGA resolution.
sensor.skip_frames(time=2000)
sensor.set_auto_gain(False) # 必须关闭此功能以防止图像褪色...
sensor.set_auto_whitebal(False) # 必须关闭此功能以防止图像褪色...
clock = time.clock()
# 注意!与find_qrcodes不同,find_apriltags方法不需要对图像进行镜头校正即可工作。
# What's the difference between tag families? Well, for example, the TAG16H5 family is effectively
# a 4x4 square tag. So, this means it can be seen at a longer distance than a TAG36H11 tag which
# is a 6x6 square tag. However, the lower H value (H5 versus H11) means that the false positive
# rate for the 4x4 tag is much, much, much, higher than the 6x6 tag. So, unless you have a
# reason to use the other tags families just use TAG36H11 which is the default family.
while True:
clock.tick()
img = sensor.snapshot()
for tag in img.find_apriltags(): # defaults to TAG36H11
img.draw_rectangle(tag.rect, color=(255, 0, 0))
img.draw_cross(tag.cx, tag.cy, color=(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())