首页 > 技术文章 > openmv apriltag

clayyjh 2020-04-21 21:32 原文

1.Apriltag识别

    Apriltag是openmv标准镜头中识别准确率和速度最快的一个,apriltag中一类识别输出为0-10.

2.下载apriltag标签图片:

    https://lanzous.com/ibq15ng

3. 复制openmv apriltag源码到openmv ide中(ide下载安装链接:https://book.openmv.cc/quick-starter.html)

# AprilTags Example
#
# This example shows the power of the OpenMV Cam to detect April Tags
# on the OpenMV Cam M7. The M4 versions cannot detect April Tags.

import sensor, image, time, math
from pyb import LED

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA) # we run out of memory if the resolution is much bigger...
sensor.skip_frames(30)
sensor.set_auto_gain(False)  # must turn this off to prevent image washout...
sensor.set_auto_whitebal(False)  # must turn this off to prevent image washout...
clock = time.clock()

led=LED(1)
led.toggle()
a=0
while(True):
    clock.tick()
    img = sensor.snapshot()
    for tag in img.find_apriltags(): # 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))
        degress = 180 * tag.rotation() / math.pi
        print(tag.id(),degress)
        if a%2 ==0:
            led.on()
        else:
            led.off()
        a=a+1

4.在openmv ide中,连接openmv(通电之后点击左下角灰色的那个按键),然后点击工具-将打开的脚本保存到Openmv Cam中,实现程序脱机运行。也可以点击左下角的绿色三角实现程序直接运行。

 

 

 5.将openmv与电脑断开,给openmv通上电,识别Apriltag码可输出对应的数字,同时看到openmv上的红色led灯闪烁。

推荐阅读