aboutsummaryrefslogtreecommitdiff
path: root/docs/user_guide/aruco_marker_pipeline/aruco_markers_description.md
blob: 66a0581b0098a894fe41430bf30cd3ac3ee35653 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
Set up ArUco markers
====================

First of all, ArUco markers needs to be printed and placed into the scene. 

Here is an example scene where markers are surrounding a workspace with two screens, a control panel and a window.

![Scene](../../img/scene.png)

## Print ArUco markers from an ArUco dictionary

ArUco markers always belongs to a set of markers called ArUco markers dictionary.

![ArUco dictionaries](../../img/aruco_dictionaries.png)

Many ArUco dictionaries exist with properties concerning the format, the number of markers or the difference between each markers to avoid error in tracking.

Here is the documention [about ArUco markers dictionaries](https://docs.opencv.org/3.4/d9/d6a/group__aruco.html#gac84398a9ed9dd01306592dd616c2c975).

The creation of [ArUcoMarkers](../../argaze.md/#argaze.ArUcoMarkers.ArUcoMarker) pictures from a dictionary is illustrated in the code below:
 
```python
from argaze.ArUcoMarkers import ArUcoMarkersDictionary

# Create a dictionary of specific April tags
aruco_dictionary = ArUcoMarkersDictionary.ArUcoMarkersDictionary('DICT_APRILTAG_16h5')

# Export marker n°5 as 3.5 cm picture with 300 dpi resolution
aruco_dictionary.create_marker(5, 3.5).save('./markers/', 300)

# Export all dictionary markers as 3.5 cm pictures with 300 dpi resolution
aruco_dictionary.save('./markers/', 3.5, 300)
```

!!! note
      There is **A4_DICT_APRILTAG_16h5_5cm_0-7.pdf** file located in *./src/argaze/ArUcoMarkers/utils/* folder ready to be printed on A4 paper sheet.

Let's print some of them before to go further.

!!! warning
	Print markers with a blank zone around them to help in their detection.

## Describe ArUco markers place

Once [ArUcoMarkers](../../argaze.md/#argaze.ArUcoMarkers.ArUcoMarker) pictures are placed into a scene it is possible to describe their 3D places into a file.

![ArUco markers description](../../img/aruco_markers_description.png)

Where ever the origin point is, all markers places need to be described in a [right-handed 3D axis](https://robotacademy.net.au/lesson/right-handed-3d-coordinate-frame/) where:

* +X is pointing to the right,
* +Y is pointing to the top,
* +Z is pointing to the backward.

!!! warning
	All ArUco markers spatial values must be given in **centimeters**.

### Edit OBJ file description

OBJ file format could be exported from most 3D editors.

``` obj
o DICT_APRILTAG_16h5#0_Marker
v 15.000000 0.378741 0.330527
v 20.000000 0.378741 0.330527
v 15.000000 5.120359 -1.255996
v 20.000000 5.120359 -1.255996
f 1 2 4 3
o DICT_APRILTAG_16h5#1_Marker
v 43.500000 31.428055 18.333317
v 48.500000 31.428055 18.333317
v 43.500000 36.428055 18.333317
v 48.500000 36.428055 18.333317
f 5 6 8 7
o DICT_APRILTAG_16h5#2_Marker
v 38.500000 2.678055 5.498381
v 43.500000 2.678055 5.498381
v 38.500000 5.178055 1.168253
v 43.500000 5.178055 1.168253
f 9 10 12 11
```

Here are common OBJ file features needed to describe ArUco markers places:  

* Object lines (starting with *o* key) indicate markers dictionary and id by following this format: **DICTIONARY**#**ID**\_Marker.
* Vertice lines (starting with *v* key) indicate markers corners. The marker size will be automatically deducted from the geometry.
* Face (starting with *f* key) link vertices and normals indexes together.

!!! warning
	Markers have to belong to the same dictionary.

!!! note
    Markers can have different size.

### Edit JSON file description

JSON file format allows to describe markers places using translation and euler angle rotation vectors.

``` json
{
    "dictionary": "DICT_APRILTAG_16h5",
    "places": {
        "0": {
            "translation": [17.5, 2.75, -0.5],
            "rotation": [-18.5, 0, 0],
            "size": 5
        },
        "1": {
            "translation": [46, 34, 18.333],
            "rotation": [0, 70, 0],
            "size": 5
        },
        "2": {
            "translation": [41, 4, 3.333],
            "rotation": [-60, 0, 0],
            "size": 5
        }
    }
}
```