An aruco marker is a square marker composed by a certain number of bits that corresponds to a specific id. The complete ArUco marker with the black border is essential for its detection. The size of the ArUco markers can vary with such that a 5x5 that marker will consist of 25 bits.
...
OpenCV has a library that detects and generates ArUco markers, the link to the documentation can be found here.
Start with importing AruCo markers.
Code Block |
---|
|
from cv2 import aruco |
Create an AruCo marker object.
Code Block |
---|
|
dictionary = aruco.Dictionary_get(cv2.aruco.DICT_6X6_1000)
parameters = aruco.DetectorParameters_create() |
Start with passing the camera frame in the aruco object.
Code Block |
---|
|
while True:
markerCorners, markerIds, rejectedCandidates = aruco.detectMarkers(leftFrame,dictionary,parameters=parameters)
leftFrame = aruco.drawDetectedMarkers(leftFrame,markerCorners,markerIds) |
To check what frame is detected.
Code Block |
---|
|
if markerIds is not None:
for i in range(len(markerIds)):
print(f'id = {i}') |
There are few pre-built libraries we can access.
Code Block |
---|
|
aruco_dictionary = {
"DICT_4X4_50": cv2.aruco.DICT_4X4_50,
"DICT_4X4_100": cv2.aruco.DICT_4X4_100,
"DICT_4X4_250": cv2.aruco.DICT_4X4_250,
"DICT_4X4_1000": cv2.aruco.DICT_4X4_1000,
"DICT_5X5_50": cv2.aruco.DICT_5X5_50,
"DICT_5X5_100": cv2.aruco.DICT_5X5_100,
"DICT_5X5_250": cv2.aruco.DICT_5X5_250,
"DICT_5X5_1000": cv2.aruco.DICT_5X5_1000,
"DICT_6X6_50": cv2.aruco.DICT_6X6_50,
"DICT_6X6_100": cv2.aruco.DICT_6X6_100,
"DICT_6X6_250": cv2.aruco.DICT_6X6_250,
"DICT_6X6_1000": cv2.aruco.DICT_6X6_1000,
"DICT_7X7_50": cv2.aruco.DICT_7X7_50,
"DICT_7X7_100": cv2.aruco.DICT_7X7_100,
"DICT_7X7_250": cv2.aruco.DICT_7X7_250,
"DICT_7X7_1000": cv2.aruco.DICT_7X7_1000,
"DICT_ARUCO_ORIGINAL": cv2.aruco.DICT_ARUCO_ORIGINAL,
"DICT_APRILTAG_16h5": cv2.aruco.DICT_APRILTAG_16h5,
"DICT_APRILTAG_25h9": cv2.aruco.DICT_APRILTAG_25h9,
"DICT_APRILTAG_36h10": cv2.aruco.DICT_APRILTAG_36h10,
"DICT_APRILTAG_36h11": cv2.aruco.DICT_APRILTAG_36h11
} |