Routineerklärung 16-Codes->find_apriltags Tag-Tracking
Video-Tutorial 11 – AprilTag-Tag-Tracking:https://singtown.com/learn/49590/
Video-Tutorial 21 – Auto jagt andere Objekte: https://singtown.com/learn/50041/
# AprilTags 标记追踪例程
#
# 这个例子展示了OpenMV Cam的功能,可以检测OpenMV Cam M7上的April标签。 M4版本无法检测april标签。
import sensor, image, time, math
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA) # 如果分辨率太高,内存可能会溢出…
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # 必须关闭此功能,以防止图像冲洗…
sensor.set_auto_whitebal(False) # 必须关闭此功能,以防止图像冲洗…
clock = time.clock()
# 注意!与find_qrcodes不同,find_apriltags方法不需要对镜像进行镜头校正。
# apriltag标签代码最多支持6个可以同时处理的标签族。
# 返回的标签对象将在标签系列中具有其标签系列和标识。
tag_families = 0
tag_families |= image.TAG16H5 # comment out to disable this family
tag_families |= image.TAG25H7 # comment out to disable this family
tag_families |= image.TAG25H9 # comment out to disable this family
tag_families |= image.TAG36H10 # comment out to disable this family
tag_families |= image.TAG36H11 # comment out to disable this family (default family)
tag_families |= image.ARTOOLKIT # comment out to disable this family
#标签系列有什么区别? 那么,例如,TAG16H5家族实际上是一个4x4的方形标签。
#所以,这意味着可以看到比6x6的TAG36H11标签更长的距离。 然而,较低的H值(H5对H11)
#意味着4x4标签的假阳性率远高于6x6标签。 所以,除非你有理由使用其他标签系列,
#否则使用默认族TAG36H11。
def family_name(tag):
if(tag.family() == image.TAG16H5):
return "TAG16H5"
if(tag.family() == image.TAG25H7):
return "TAG25H7"
if(tag.family() == image.TAG25H9):
return "TAG25H9"
if(tag.family() == image.TAG36H10):
return "TAG36H10"
if(tag.family() == image.TAG36H11):
return "TAG36H11"
if(tag.family() == image.ARTOOLKIT):
return "ARTOOLKIT"
while(True):
clock.tick()
img = sensor.snapshot()
for tag in img.find_apriltags(families=tag_families): # defaults to TAG36H11 without "families".
img.draw_rectangle(tag.rect(), color = (255, 0, 0))
img.draw_cross(tag.cx(), tag.cy(), color = (0, 255, 0))
print_args = (family_name(tag), tag.id(), (180 * tag.rotation()) / math.pi)
print("Tag Family %s, Tag ID %d, rotation %f (degrees)" % print_args)
print(clock.fps())
Erklärung der Funktion des offiziellen chinesischen Dokuments von Singtown Technology OpenMV:
Weiterführende Literatur:
- Von der Singtown Lab APP: Wie kann man Apriltag während der Identifizierung lokalisieren/einordnen? Was ist die Einheit der Ausgabe tx ty tz? Wie ermittelt man die tatsächliche Entfernung? https://forum.singtown.com/topic/52