Quick answer: OpenCV and Aruco Markers.
Aruco markers are square markers that are made up of a black border and inner binary matrix whose pattern determines the ID number associated with that marker. The size of the marker determines the size of the internal matrix. For example, a marker size of 4×4 is composed by 16 bits.
In this article, we’ll use the 6×6 dictionary. To generate your own markers you can click here. When you visit that page, you can go to the “Dictionary” dropdown menu and select “6×6”. Change the “Marker ID” value from 0-999 and see the pattern of the displayed Aruco marker change.
You can save the resulting marker and print it out for testing out the code we will see later on.
In the video above, I am running a Python script where two Aruco tags are being detected and tracked. The script prints the id number of each tag (good for differentiating each other) as well as their x and y coordinates (good for tracking their position).
Assuming your system already has OpenCV installed with the extra modules, we can run the following Python code get the same results as in the video.
With these markers, you can attach them to certain objects and create a Raspberry Pi robot to drive towards a specified marker, create an object sorting machine, or maybe even create an augmented reality project!