Track Markers
First, make sure you have calibrated your camera: read the Calibrate a Camera page. You need to have a calibration file to track some aruco objects.
Also, print and place in the environment the aruco objects you want to track. Read the Create Markers page for details.
To track your aruco objects:
- Open the
Assets/ArucoUnity/Scenes/TrackMarkers.unity
scene. - Configure the camera:
- For a webcam, use the
ArucoWebcamCalibrated
object already in the scene. Otherwise, drag the prefab corresponding to your camera :Assets/ArucoUnity/Prefabs/Cameras/<CameraType>Calibrated.prefab
. - Fill
CameraParametersFilename
with the camera parameters XML file from the calibration of the camera (Fig.1).
- For a webcam, use the
Fig.1: ArucoWebcamCalibrated
configured with camera parameters from a calibration.
- Create each aruco objects to track:
- Configure it with what you measure on the printed aruco object. Units are in meters for tracking, not in pixels.
- Use a
ArucoObjectDisplayer
to visualize the aruco object, not a ArucoObjectCreator. - Simply add any game object as child of the aruco object e.g. the red cube in Fig.2.
Fig.2: ArucoMarker
configured to track a physical aruco marker with a 5.4 cm side length. The ArucoObjectDisplayer
helps to visualize in the editor the physical object that will be tracked.
- Configure the tracker
ArucoObjectsTracker
:- Drag all the aruco objects to track in
ArucoObjects
. - Set
ArucoCameraDisplay
with the camera prefab you use (Fig.3).
- Drag all the aruco objects to track in
Fig.3: ArucoObjectsTracker
configured to track three objects for the ArucoCameraCalibrated
we configured.
- Run the scene! The
ArucoTracker
will place (position, rotation, scale) any detected aruco object in theArucoObjects
list relative to the camera (Fig.4).
Fig.4: Roll a ball set as child of an aruco board: the game follows the board movements.
To understand the algorithm used, read this tutorial: Detection of ArUco Markers.