...
/Creating Single ArUco Markers and AprilTags with OpenCV
Creating Single ArUco Markers and AprilTags with OpenCV
Learn how to draw ArUco markers and AprilTags.
We'll cover the following...
Generating ArUco markers
In the following example, we’ll learn how to generate ArUco markers.
Press + to interact
import cv2import numpy as npprint(cv2.__version__)aruco_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_6X6_250)marker_id = 42marker_size = 200marker_image = np.zeros((marker_size, marker_size), dtype=np.uint8)marker_image = cv2.aruco.drawMarker(aruco_dict, marker_id, marker_size, marker_image, borderBits=1)cv2.imwrite("output/aruco_marker_42.png", marker_image)
Lines 1–2: To generate markers, we first need to import the required libraries, cv2
and numpy
.
Line 4: We print the version of the cv2
library to make sure that we have installed the correct version.
Then, we’ll get the dictionary containing the specific ArUco markers that we are interested in. For ...