...
/Creating a Page of ArUco Markers With OpenCV
Creating a Page of ArUco Markers With OpenCV
Learn how to generate a page filled with ArUco markers.
We'll cover the following...
Creating a single marker
Let’s put the relevant functions in a function so we can easily create markers in an iterative manner.
In the example below, we’ll create such a function with the name create_marker()
.
Press + to interact
import cv2import numpy as npdef create_marker(aruco_dict, marker_id, marker_size):marker_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)return marker_imagearuco_dict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_6X6_250)marker_id = 0marker_size = 200cv2.imwrite("output/onemarker.png", create_marker(aruco_dict, marker_id, marker_size))
Line 5: An empty marker_image
will be created as a numpy
matrix of zeros. The size will be marker_size
in both ...