yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
K230 Vision Module📖
1. Quick Start
  • 0.Get start
  • 1. K230 firmware download and burning
  • 2. Install the programming environment
  • 3. Debug and run routines
  • 4. Offline running routine
  • 5. Micropython Quick Start
  • 6. GUI Program Instructions
  • 7.K230 module bracket installation tutorial
  • 8.K230 module 2DOF PTZ installation tutorial
2. Basic Courses
  • 1.FPIOA pin assignment
  • 2.RGB lights
  • 3.Buzzer
  • 4.Buttons
  • 5.Serial communication
  • 6.I2C communication
  • 7.PWM
  • 8.WDT watchdog
  • 9.Timer
  • 10.Fourier Transform
  • 11.SHA256 encryption
  • 12.AES encryption
  • 13.Multithreading
  • 14.File reading and writing
  • 15.Image Display
  • 16.Touch Display
  • 17.Camera display
  • 18.Image Flip
  • 19.Camera
3. Draw the image
  • 1. Draw the lines
  • 2. Draw the circle
  • 3. Draw the rectangle
  • 4. Draw the ellipse
  • 5. Draw the arrow
  • 6. Draw the crosshairs
  • 7. Draw text
  • 8. Draw key points
4. Graphics detection
  • 1. Line segment detection
  • 2. Rectangle Detection
  • 3. Circle detection
  • 4. Object edge detection
  • 5. Line inspection basics:fast linear regression
5. Color recognition
  • 1. Color recognition
  • 2. Object Counting
  • 3. Multi-color recognition
  • 4. K230 Color Line Patrol
6.1 CV_lite Image Processing Special Topic
  • 1.Introduction to cv_litenew
  • 2.cv_lite API Reference Manualnew
  • 3.Color Block Recognition - Grayscale Imagenew
  • 4.Color Block Recognition - Color Imagenew
  • 5.Circle Recognition - Grayscale Imagenew
  • 6.Circle Recognition - Color Imagenew
  • 7.Corner Recognition - Grayscale Imagenew
  • 8.Corner Recognition - Color Imagenew
  • 9.Edge Recognition - Grayscale Imagenew
  • 10. Edge Recognition - Color Imagenew
  • 11. Rectangle Recognition - Grayscale Imagenew
  • 12.Rectangle Recognition - Color Imagenew
  • 13.Rectangle recognition combined with corner recognition - grayscale imagenew
  • 14.Rectangle recognition combined with corner recognition - color imagenew
  • 15.Image Binarization - Grayscalenew
  • 16.Image Binarization - Color Imagenew
  • 17.Exposure Adjustmentnew
  • 18.Image Black Hat Operationsnew
  • 19.Image Color Histogramnew
  • 20.Image Closingnew
  • 21.Image Expansionnew
  • 22.Image Corrosionnew
  • 23.Gaussian Blurnew
  • 24.Gradient Transformationnew
  • 25.Mean Fuzzynew
  • 26.Image Openingnew
  • 27.Image Top Hat Operationnew
  • 28.PnP rangingnew
  • 29.Find rectangles and measure distancesnew
  • 30.Image grayscale world white balancenew
6.2 OpenCV Image Processing Special Topicnew
  • 1. OpenCV Introduction
  • 2. OpenCV API Reference
  • 3. Image Basic Transforms
  • 4. Morphological Operations
  • 5. Color Segmentation and Shape Classification
  • 6. Corner and Centroid Detection
  • 7. Hough Circle Detection
  • 8. Hough Line Detection
  • 9. Contour Analysis
  • 10. Drawing Functions
  • 11. Template Matching
  • 12. Image Blur Filtering
  • 13. Edge Detection
  • 14. Thresholding
  • 15. Color Segmentation
  • 16. Histogram and Pixel Transformation
  • 17. Arithmetic and Bitwise Operations
  • 18. Channel Operation and Statistics
  • 19. Image File Read and Write
  • 20. Pixel Level Transformation
7. Code type recognition
  • 1.Barcode recognition
  • 2.QR code recognition
  • 3.AprilTag tag recognition
  • 4.DM code recognition
8. Face Recognition
  • 1.[Must-read] General code structure and prerequisite knowledge of AI vision routines
  • 2.Face Detection
  • 3.Facial key point recognition
  • 4.Face orientation detection
  • 5.Face 3D Network
  • 6.Gaze direction detection
  • 7.Register for face recognition
9. Human body characteristics
  • 1. Human body detection
  • 2. Human key point detection
  • 3. Human posture recognition
  • 4. Fall detection
  • 5. Palm detection
  • 6. Palm key point detection
  • 7. Palm key point classification
  • 8. Gesture Recognition
  • 9. Dynamic gesture recognition
  • 10. Rock, Paper, Scissors
10. Scenario Application
  • 1.OCR character detection
  • 2.OCR character recognition
  • 3.yolov8n target detection
  • 4.yolov8n segmentation
  • 5. Self-learning object recognition
  • 6. License plate detection
  • 7. License Plate Recognition
  • 8. Target Tracking
  • 9. Fruit classification
  • 10. Garbage classification
  • 11. Road sign recognition
11. Audio and video processing
  • 1. Audio Recording
  • 2. Play Audio
  • 3. Video Recording
  • 4. Play Video
  • 5. Keyword wake-up
12. Network Basics
  • 1. Wireless network connection
  • 2. AP hotspot mode
  • 3. TCP-Server Example
  • 4. TCP-Client Example
  • 5. UDP-Server Example
  • 6. UDP-Client Example
  • 7. HTTP-Server Example
  • 8. HTTP-Client Example
  • 9. MQTT Quick Start
  • 10. MQTT-Publisher
  • 11. MQTT-Subscriber
  • 12. RTSP real-time image transmission
  • 13. RTSP real-time image transmission combined with AIDemo
  • 14. Call OpenRouter large model aggregation service
  • 15. Open the Resource Monitoring Panel
13. LVGL Graphical Interface
  • 1. Introduction to LVGL
  • 2. Create a button
  • 3. Create a slider
  • 4. Create an Image
  • 5. Create a text box and keyboard
14. GUI Code Tutorial & Secondary Development
  • 01.GUI System Architecture
  • 02.Core Engine Initialization
  • 03.Application Discovery Mechanism in GUI
  • 04.Desktop Layout Algorithm
  • 05.Advanced UI Styling
  • 06.BaseApp Base Class Analysis
  • 07.Hello_World Practical
  • 08.GUI Application Lifecycle and Resource Management
15. Train your own model
  • 1. Local deployment of yolo training environment
  • 2. Use online platforms for training
16.Touch Course
  • 1.Touch point detectionnew
  • 2.Touch Paintingnew
  • 3.Touch to take a photonew
17. Multi-master communication (purchased separately)
ESP32-K230
  • 1.k230 color recognition
  • 2.k230 barcode recognition
  • 3.k230 QR code recognition
  • 4.k230Apriltag code recognition
  • 5.k230DM code recognition
  • 6.k230 face detection
  • 7.k230 gaze direction
  • 8.k230 face recognition
  • 9.k230 human body detection
  • 10.k230 fall detection
  • 11.k230 palm detection
  • 12.k230 gesture recognition
  • 13.k230OCR character recognition
  • 14.k230 object detection
  • 15.k230 target tracking
  • 16.k230 self-learning object recognition
  • 17.k230 license plate recognition
Jetson-K230
  • 1.k230 color recognition
  • 2.k230 barcode recognition
  • 3.k230 QR code recognition
  • 4.k230Apriltag code recognition
  • 5.k230DM code recognition
  • 6.k230 face detection
  • 7.k230 gaze direction
  • 8.k230 face recognition
  • 9.k230 human body detection
  • 10.k230 fall detection
  • 11.k230 palm detection
  • 12.k230 gesture recognition
  • 13.k230OCR character recognition
  • 14.k230 object detection
  • 15.k230 target tracking
  • 16.k230 self-learning object recognition
  • 17.k230 license plate recognition
MSPM0G3507-K230
  • 1.k230 color recognition
  • 2.k230 barcode recognition
  • 3.k230 QR code recognition
  • 4.k230Apriltag code recognition
  • 5.k230DM code recognition
  • 6.k230 face detection
  • 7.k230 gaze direction
  • 8.k230 face recognition
  • 9.k230 human body detection
  • 10.k230 fall detection
  • 11.k230 palm detection
  • 12.k230 gesture recognition
  • 13.k230OCR character recognition
  • 14.k230 object detection
  • 15.k230 target tracking
  • 16.k230 self-learning object recognition
  • 17.k230 license plate recognition
Pico-K230
  • 1.k230 color recognition
  • 2.k230 barcode recognition
  • 3.k230 QR code recognition
  • 4.k230Apriltag code recognition
  • 5.k230DM code recognition
  • 6.k230 face detection
  • 7.k230 gaze direction
  • 8.k230 face recognition
  • 9.k230 human body detection
  • 10.k230 fall detection
  • 11.k230 palm detection
  • 12.k230 gesture recognition
  • 13.k230OCR character recognition
  • 14.k230 object detection
  • 15.k230 target tracking
  • 16.k230 self-learning object recognition
  • 17.k230 license plate recognition
raspberrypi-K230
  • 1.k230 color recognition
  • 2.k230 barcode recognition
  • 3.k230 QR code recognition
  • 4.k230Apriltag code recognition
  • 5.k230DM code recognition
  • 6.k230 face detection
  • 7.k230 gaze direction
  • 8.k230 face recognition
  • 9.k230 human body detection
  • 10.k230 fall detection
  • 11.k230 palm detection
  • 12.k230 gesture recognition
  • 13.k230OCR character recognition
  • 14.k230 object detection
  • 15.k230 target tracking
  • 16.k230 self-learning object recognition
  • 17.k230 license plate recognition
RDK-K230
  • 1.k230 color recognition
  • 2.k230 barcode recognition
  • 3.k230 QR code recognition
  • 4.k230Apriltag code recognition
  • 5.k230DM code recognition
  • 6.k230 face detection
  • 7.k230 gaze direction
  • 8.k230 face recognition
  • 9.k230 human body detection
  • 10.k230 fall detection
  • 11.k230 palm detection
  • 12.k230 gesture recognition
  • 13.k230OCR character recognition
  • 14.k230 object detection
  • 15.k230 target tracking
  • 16.k230 self-learning object recognition
  • 17.k230 license plate recognition
STM32-K230
  • 1. stm32_k230 color recognition
  • 2. stm32_k230 barcode recognition
  • 3. stm32_k230 QR code recognition
  • 4. stm32_k230Apriltag code recognition
  • 5. stm32_k230DM code recognition
  • 6. stm32_k230 face detection
  • 7.stm32_k230 looking direction
  • 8. stm32_k230 face recognition
  • 9. stm32_k230 human body detection
  • 10. stm32_k230 fall detection
  • 11. stm32_k230 palm detection
  • 12. stm32_k230 gesture recognition
  • 13. stm32_k230OCR character recognition
  • 14. stm32_k230 object detection
  • 15. stm32_k230 target tracking
  • 16. stm32_k230 self-learning object recognition
  • 17.stm32_k230 license plate recognition
Arduino-K230
  • 1.arduino_k230 color recognition
  • 2.arduino_k230 barcode recognition
  • 3.arduino_k230 QR code recognition
  • 4.arduino_k230 Apriltag code recognition
  • 5.arduino_k230 DM code recognition
  • 6.arduino_k230 face detection
  • 7.arduino_k230 looking direction
  • 8.arduino_k230 face recognition
  • 9.arduino_k230 human body detection
  • 10.arduino_k230 fall detection
  • 11.arduino_k230 palm detection
  • 12.arduino_k230 gesture recognition
  • 13.arduino_k230 OCR character recognition
  • 14.arduino_k230 object detection
  • 15.arduino_k230 target tracking
  • 16.arduino_k230 self-learning object recognition
  • 17.arduino_k230 license plate recognition
Microbit-K230
  • 1.microbit_k230 color recognition
  • 2.microbit_k230 barcode recognition
  • 3.microbit_k230 QR code recognition
  • 4.microbit_k230 Apriltag code recognition
  • 5.microbit_k230 DM code recognition
  • 6.microbit_k230 face detection
  • 7.microbit_k230 looking direction
  • 8.microbit_k230 face recognition
  • 9.microbit_k230 human body detection
  • 10.microbit_k230 fall detection
  • 11.microbit_k230 palm detection
  • 12.microbit_k230 gesture recognition
  • 13.microbit_k230 OCR character recognition
  • 14.microbit_k230 object detection
  • 15.microbit_k230 target tracking
  • 16.microbit_k230 self-learning object recognition
  • 17.microbit_k230 license plate recognition
MSPM0G3519-K230
  • 1. K230 Color Recognitionnew
  • 2. K230 Barcode Recognitionnew
  • 3. K230 QR Code Recognitionnew
  • 4. K230 Apriltag Code Recognitionnew
  • 5. K230 DM Code Recognitionnew
  • 6. K230 Face Detectionnew
  • 7. K230 Gaze Directionnew
  • 8. K230 Face Recognitionnew
  • 9. K230 Human Body Detectionnew
  • 10. K230 Fall Detectionnew
  • 11. K230 Palm Detectionnew
  • 12. K230 Gesture Recognitionnew
  • 13. K230 OCR Character Recognitionnew
  • 14. K230 Object Detectionnew
  • 15. K230 Target Trackingnew
  • 16. K230 Self-learning Object Recognitionnew
  • 17. K230 License Plate Recognitionnew
18.Extension case (purchase separately)
For 2DOF Electric Platform
  • 1.Moving target control and automatic tracking system
  • 2.Human body recognition alarm
  • 3.Gesture Recognition
  • 4.Rock Paper Scissors
  • 5.Fruit sorting
  • 6.Color Tracking
  • 7.Face Tracking
MSPM0G3507 wheeled chassis V1/V2 combined with K230 application case
  • 1.Visual tracking
  • 2.Color tracking
  • 3.Color response
  • 4.Road sign recognition
  • 5.Machine code tracking
  • 6.QR code recognition action
  • 7.Autonomous avoid
  • 8.License plate tracking
  • 9.Face tracking
  • 10.Gaze direction tracking
  • 11.Palm tracking
  • 12.Target tracking
  • 13.Human body tracking
  • 14.OCR character recognition action
STM32 wheeled chassis V1/V2 combined with K230 application case
  • 1.Visual tracking
  • 2.Color tracking
  • 3.Color response
  • 4.Road sign recognition
  • 5.Machine code tracking
  • 6.QR code recognition action
  • 7.Autonomous avoid
  • 8.License plate tracking
  • 9.Face tracking
  • 10.Gaze direction tracking
  • 11.Palm tracking
  • 12.Target tracking
  • 13.Human body tracking
  • 14.OCR character recognition action
MSPM0G3519 wheeled chassis V1/V2 combined with K230 application case
  • 1.Visual trackingnew
  • 2.Color trackingnew
  • 3.Color responsenew
  • 4.Road sign recognitionnew
  • 5.Machine code trackingnew
  • 6.QR code recognition actionnew
  • 7.Autonomous avoidnew
  • 8.License plate trackingnew
  • 9.Face trackingnew
  • 10.Gaze direction trackingnew
  • 11.Palm trackingnew
  • 12.Target trackingnew
  • 13.Human body trackingnew
  • 14.OCR character recognition actionnew
19. Expansion case(purchase separately)new
  • 1.Motion target control and Auto track system
  • 2.Vehicle-mounted balance ball motion control system
Download
  • Manual
  • CanMV IDE
  • Software Tools
  • Firmware
  • Source Code
  • Appendix
Download ZIP

Welcome to K230 Vision Module repository

3.AprilTag tag recognition

AprilTag tag recognition

AprilTag tag recognitionIntroduction to the results of routine experimentsCode ExplanationComplete codeCode structurefind_apriltags()kindAprilTagConstructorcornersrectxywhidfamilycxcyrotationdecision_marginhamminggoodnessx_translationy_translationz_translationx_rotationy_rotationz_rotation

 

Introduction to the results of routine experiments

In this section, let's identify the AprilTag tag.

AprilTag is a two-dimensional barcode for visual recognition, which is widely used in robot navigation, augmented reality, and camera calibration. It was originally developed by researchers at Georgia Institute of Technology. AprilTag is designed to provide a reliable and easy-to-recognize tagging system that can work efficiently in complex environments.

Here are some of the key features of AprilTag:

  1. High-precision recognition : AprilTag uses image processing technology to accurately identify and locate tags under a variety of lighting conditions and backgrounds.
  2. Information encoding : Each AprilTag can encode different information, usually a unique integer ID, allowing the system to distinguish between multiple tags.
  3. Fast detection : The system can quickly detect the tag position and orientation, which is particularly important for real-time applications such as robot localization and navigation.
  4. Anti-interference : AprilTag has strong anti-interference ability and can maintain a high recognition rate in the presence of noise or other interfering objects.
  5. Open source support : AprilTag is open source and developers can use and modify it freely, which promotes its application in various projects.
  6. Easy to make : Users can easily print out AprilTag and make labels for experiments or applications.

Due to these advantages, AprilTag is widely used in many fields such as robots, drones, AR/VR, and has become a popular choice for visual positioning and object recognition.

We have generated 587 tags of the tag36h11 family and placed them in the directory [K230 Tutorial\0. Development Board Data\AprilTags], which can be used directly for identification. You can also use the AprilTag generator that comes with CanMV IDE to generate AprilTag tags of other families.

image-20250124112312362

Run the sample code and point the camera at the AprilTag code to be identified. You can see that the AprilTag code is marked with a red frame and a green cross arrow.

image-20250429093909112

In the serial terminal output of CanMV IDE, you can see the following information output:

Tag Family TAG36H11, Tag ID 0, rotation 2.835588 (degrees)

Where rotation represents the rotation offset

Example images

tag36h11_3

Code Explanation

The peripherals we will use in this section are mainly camera modules

AprilTag detection and recognition is implemented by the find_apriltags() method in K230, which belongs to the image module

Complete code

xxxxxxxxxx
# Import required modules
# 导入所需模块
import time, math, os, gc
​
from media.sensor import *
from media.display import *
from media.media import *
​
from libs.YbProtocol import YbProtocol
from ybUtils.YbUart import YbUart
# uart = None
uart = YbUart(baudrate=115200)
pto = YbProtocol()
​
​
# AprilTag code supports processing up to 6 tag families simultaneously
# The returned tag object will have its tag family and ID within that family
# AprilTag代码最多支持同时处理6种tag家族
# 返回的tag标记对象包含其所属家族及在该家族中的ID
​
# Initialize tag families bitmask
# 初始化tag家族位掩码
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) / 注释掉以禁用此家族(默认)
tag_families |= image.ARTOOLKIT  # Comment out to disable this family / 注释掉以禁用此家族
​
def family_name(tag):
    """
    Get the family name of a tag
    获取tag的家族名称
​
    Args:
        tag: AprilTag object / AprilTag对象
    Returns:
        str: Name of the tag family / tag家族名称
    """
    family_dict = {
        image.TAG16H5: "TAG16H5",
        image.TAG25H7: "TAG25H7",
        image.TAG25H9: "TAG25H9",
        image.TAG36H10: "TAG36H10",
        image.TAG36H11: "TAG36H11",
        image.ARTOOLKIT: "ARTOOLKIT"
    }
    return family_dict.get(tag.family())
​
# Initialize camera sensor
# 初始化摄像头传感器
sensor = Sensor()
sensor.reset()
sensor.set_framesize(width=400, height=240)
sensor.set_pixformat(Sensor.RGB565)
​
# Initialize display
# 初始化显示
Display.init(Display.ST7701, width=640, height=480, to_ide=True)
#Display.init(Display.VIRT, sensor.width(), sensor.height())
​
# Initialize media manager and start sensor
# 初始化媒体管理器并启动传感器
MediaManager.init()
sensor.run()
​
# Create clock for FPS calculation
# 创建时钟用于FPS计算
clock = time.clock()
​
# Main loop
# 主循环
while True:
    clock.tick()
​
    # Capture image
    # 捕获图像
    img = sensor.snapshot()
​
    # Find and process AprilTags
    # 查找和处理AprilTags
    for tag in img.find_apriltags(families=tag_families):
        # Draw rectangle and cross on detected tag
        # 在检测到的tag上绘制矩形和十字
        img.draw_rectangle(tag.rect(), color=(255, 0, 0), thickness=4)
        img.draw_cross(tag.cx(), tag.cy(), color=(0, 255, 0), thickness=2)
​
        # Print tag information
        # 打印tag信息
        print_args = (family_name(tag), tag.id(), (180 * tag.rotation()) / math.pi)
        print("Tag Family %s, Tag ID %d, rotation %f (degrees)" % print_args)
​
        x, y, w, h = tag.rect()
        pto_data = pto.get_apriltag_data(x, y, w, h, tag.id(), (180*tag.rotation())/math.pi)
        uart.send(pto_data)
        print(pto_data)
        break
​
    # Display image centered on screen
    # 在屏幕中央显示图像
    Display.show_image(img, x=120, y=120)
​
    # Print frames per second
    # 打印帧率
    print(clock.fps())

Code structure

The main functions and structure of this section's routine are as follows:

Basic settings section:

  • First, import the necessary modules, including time, mathematical calculations, operating system, and garbage collection functions.
  • Six different AprilTag tag families are initialized, and you can enable or disable specific families through comments.
  • A family_name function is defined to convert the numeric ID of the tag family into a readable string name

Hardware initialization:

  • Set the camera sensor parameters: the resolution is 1280x960, the actual working resolution is set to 320x240, and the RGB565 color format is used
  • Initialize the display: Use ST7701 display, resolution 640x480
  • Initialize the media manager and start the camera sensor

Main loop function:

  • Continuously capture image frames

  • Find the AprilTag in each frame

  • For each tag found:

    • Mark the tag position with a red rectangle
    • Mark the center of the tag with a green cross
    • Print out the tag's family name, ID number, and rotation angle
  • Display the processed image in the center of the screen

  • Display the current frame rate (FPS)

find_apriltags()

image.find_apriltags([roi[, families=image.TAG36H11[, fx[, fy[, cx[, cy]]]]]])

This function finds all AprilTags within the specified ROI and returns a image.apriltaglist of objects. For more information, see image.apriltagthe documentation for the object.

Compared to QR codes, AprilTags can be effectively detected at greater distances, in poor lighting conditions, and in more distorted image environments. AprilTags are able to cope with various image distortion issues, while QR codes cannot. Therefore, AprilTags only encode a digital ID as their payload.

In addition, AprilTags can also be used for positioning. Each image.apriltagobject will return its 3D position information and rotation angle. The position information is determined by fx, fy, cxand cy, which represent the focal length and center point of the image in the X and Y directions respectively.

AprilTags can be created using the tag generator tool built into OpenMV IDE. This tool generates AprilTags in a printable 8.5"x11" format.

  • roiis a rectangle tuple specifying the region of interest (x, y, w, h). If not specified, ROI defaults to the entire image. The operation is limited to pixels within this region.

  • familiesis a bitmask of tag families to decode, expressed as a logical OR of:

    • image.TAG16H5
    • image.TAG25H7
    • image.TAG25H9
    • image.TAG36H10
    • image.TAG36H11
    • image.ARTOOLKIT

The default setting is for the most commonly used image.TAG36H11tag families. Please note that each tag family enabled will slightly reduce find_apriltagsthe speed of .

  • fxis the focal length of the camera in pixels in the X direction. The value for the standard OpenMV Cam is ( (2.8 / 3.984) \times 656 ) which is calculated by dividing the focal length in millimeters by the length of the sensor in the X direction, multiplied by the number of pixels in the sensor in the X direction (for an OV7725 sensor).
  • fyThe focal length of the camera in pixels in the Y direction. The value for the standard OpenMV Cam is ( (2.8 / 2.952) \times 488 ) which is calculated by dividing the focal length in millimeters by the length of the sensor in the Y direction, multiplied by the number of pixels in the sensor in the Y direction (for an OV7725 sensor).
  • cxis the center of the image, that is image.width()/2, not roi.w()/2.
  • cyis the center of the image, that is image.height()/2, not roi.h()/2.

Note: Compressed images and Bayer images are not supported.

kindAprilTag

The AprilTag object is returned by image.find_apriltagsthe function.

Constructor

xxxxxxxxxx
class image.apriltag

Please use image.find_apriltags()the function to create this object.

corners

xxxxxxxxxx
apriltag.corners()

This method returns a list of tuples containing the four corners of AprilTag, each tuple is in the format of (x, y). The order of the four corners is usually starting from the upper left corner and arranged in a clockwise direction.

rect

xxxxxxxxxx
apriltag.rect()

This method returns a rectangle tuple (x, y, w, h) that can be used in other image processing methods, such as image.draw_rectanglethe AprilTag bounding box in .

x

xxxxxxxxxx
apriltag.x()

This method returns the x coordinate of the AprilTag's bounding box (int). You may also get this value using the [0] object.

y

xxxxxxxxxx
apriltag.y()

This method returns the y coordinate of the AprilTag's bounding box (int). You may also get this value using [1] on the object.

w

xxxxxxxxxx
apriltag.w()

This method returns the width of the AprilTag's bounding box (int). You may also get this value using [2] on the object.

h

xxxxxxxxxx
apriltag.h()

This method returns the height of the AprilTag's bounding box (int). You may also get this value using [3] on the object.

id

xxxxxxxxxx
apriltag.id()

This method returns the numeric ID of the AprilTag.

  • TAG16H5 -> 0 to 29
  • TAG25H7 -> 0 to 241
  • TAG25H9 -> 0 to 34
  • TAG36H10 -> 0 to 2319
  • TAG36H11 -> 0 to 586
  • ARTOOLKIT -> 0 to 511

You can also get this value doing [4] on the object.

family

xxxxxxxxxx
apriltag.family()

This method returns the numeric family of AprilTag.

  • image.TAG16H5
  • image.TAG25H7
  • image.TAG25H9
  • image.TAG36H10
  • image.TAG36H11
  • image.ARTOOLKIT

You can also get this value doing [5] on the object.

cx

xxxxxxxxxx
apriltag.cx()

This method returns the center x coordinate of the AprilTag (int). You may also get this value using [6] on the object.

cy

xxxxxxxxxx
apriltag.cy()

This method returns the center y coordinate of the AprilTag (int). You may also get this value using [7] on the object.

rotation

xxxxxxxxxx
apriltag.rotation()

This method returns the rotation angle of the AprilTag in radians (int). You may also get this value using [8] on the object.

decision_margin

xxxxxxxxxx
aprilt
​
ag . decision_margin()

This method returns the decision margin of the AprilTag, reflecting the confidence in the detection (float). You may also get this value using [9] on the object.

hamming

xxxxxxxxxx
apriltag.hamming()

This method returns the maximum acceptable Hamming distance (that is, the acceptable digit error) of AprilTag. The details are as follows:

  • TAG16H5: Up to 0 bit error is acceptable
  • TAG25H7: Up to 1 bit error can be tolerated
  • TAG25H9: Up to 3 bit errors are acceptable
  • TAG36H10: Up to 3 bit errors are acceptable
  • TAG36H11: Up to 4 bit errors can be tolerated
  • ARTOOLKIT: Up to 0 bit errors are acceptable

You can get this value doing [10] on the object.

goodness

xxxxxxxxxx
apriltag.goodness()

This method returns the color saturation of the AprilTag image, ranging from 0.0 to 1.0, where 1.0 represents the best state.

Currently this value is usually 0.0. In the future we plan to enable a feature called "Tag Refinement" to support detection of smaller AprilTags. However, currently this feature may cause the frame rate to drop below 1 FPS.

You can get this value using [11] on the object.

x_translation

xxxxxxxxxx
apriltag.x_translation()

This method returns the camera's displacement in the x direction in unknown units.

This method is useful for determining the position of an AprilTag that is far from the camera. However, factors such as the size of the AprilTag and the lens you are using can affect where the x units belong. For ease of use, we recommend that you use a lookup table to convert the output of this method into information that is applicable to your application.

Note: The direction here is from left to right.

You can get this value using [12] on the object.

y_translation

xxxxxxxxxx
apriltag.y_translation()

This method returns the camera's displacement in the y direction in unknown units.

This method is useful for determining the position of an AprilTag that is far from the camera. However, factors such as the size of the AprilTag and the lens you use can affect where the y units belong. For ease of use, we recommend that you use a lookup table to convert the output of this method into information that is applicable to your application.

Note: The direction here is from top to bottom.

You can get this value using [13] on the object.

z_translation

xxxxxxxxxx
apriltag.z_translation()

This method returns the camera's displacement in the z direction in unknown units.

This method is useful for determining the position of an AprilTag that is far from the camera. However, factors such as the size of the AprilTag and the lens you are using can affect where the z units belong. For ease of use, we recommend that you use a lookup table to convert the output of this method into information that is applicable to your application.

Note: The direction here is from front to back.

You can get this value using [14] on the object.

x_rotation

xxxxxxxxxx
apriltag.x_rotation()

This method returns the rotation angle of the AprilTag in the x-plane, measured in radians. For example, this method can be applied if the camera is moving from left to right to view the AprilTag.

You can get this value doing [15] on the object.

y_rotation

xxxxxxxxxx
apriltag.y_rotation()

This method returns the rotation angle of the AprilTag in the y plane, measured in radians. For example, this method can be applied if the camera is moving from top to bottom to observe the AprilTag.

You can get this value using [16] on the object.

z_rotation

xxxxxxxxxx
apriltag.z_rotation()

This method returns the rotation angle of the AprilTag in the z plane, measured in radians. For example, this method can be applied if the camera is rotated to view the AprilTag.

Note: This method is apriltag.rotation()a renamed version of .

You can get this value using [17] on the object.

QR code recognition
DM code recognition

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文