Create Markers
Motivation
Before tracking markers with your camera, you need to create, print and place them in the environment. You can use four type of Aruco objects: markers, grid boards, charuco boards and diamond markers.
From left to right: a marker, a diamond marker, a grid board, a charuco board.
CreateMarkers
scene
Open the Assets/ArucoUnity/Scenes/CreateMarkers.unity
scene to visualize the Aruco objects. Play this scene to create them. You can find the created images in Assets/ArucoUnity/Images/
.
Manual creation
Marker
Manual creation and configuration of a marker.
- Create an empty object.
- Add a
ArucoMarker
script. Configure it:- Select a dictionary of markers. It determines the marker size (for example 4x4 bits) and had a size (for example 50 markers). A lower dictionary size is better to avoid detection errors. For more details, see "Markers and Dictionaries" and "Selection a dictionary" sections of this tutorial.
- Set
MarkerSideLength
in pixels. It controls the image size. - Set
MarkerBorderBits
with a minimum of 1. It controls the width of the black border of the marker, helping its detection. - Set
MarkerId
, from 0 to the dictionary size.
- Add a
ArucoObjectCreator
script. Configure it:- Add the
ArucoMarker
script to theArucoObject
field. - Check
DisplayInPlayMode
if you want to display the marker in play mode. - Check
SaveImage
to save the marker in an image file in play mode. - Set the
OutputFolder
path to save the image, relative to the persistentDataPath in builds or to the "Assets" folder of your project in the editor. - Check
AutomaticFilename
for an automatic image filename based on theArucoObject
property values. - Set the image filename in
OptionalImageFilename
ifAutomaticFilename
is not checked.
- Add the
- Play the scene. The marker is automatically created on a child plane of our object and saved on the project folder.
Grid board
Example of a grid board with the corresponding configuration.
The process is the same as in the marker subsection.
The additional configurable parameters are:
MarkersNumberX
: The number of markers on the board X axis.MarkersNumberY
: The number of markers on the board Y axis.MarkerSeparation
: The margin between markers in pixels.
Charuco board
Example of a charuco board with the corresponding configuration.
The process is the same as in the marker subsection.
The additional configurable parameters are:
MarginLength
: The markers margin on the white squares.SquaresNumberX
: The number of squares on the board X axis.SquaresNumberY
: The number of squares on the board Y axis.SquareSideLength
: The width in pixels of each square.
Diamond marker
Example of a diamond marker with the corresponding configuration.
The process is the same as in the marker subsection.
The additional configurable parameters are:
SquareSideLength
: The width in pixels of each square.MarkersXId
: The ids of the four markers.