blob: 9a3bc9f6ba04214fda78df1fcf630b191dacaac6 (
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
|
Markers detection
=================
![Detected markers](../../img/detected_markers.png)
Firstly, the [ArUcoDetector](../../../argaze/#argaze.ArUcoMarkers.ArUcoDetector.ArUcoDetector) needs to know the expected dictionary and size (in centimeter) of the [ArUcoMarkers](../../../argaze/#argaze.ArUcoMarkers.ArUcoMarker) it have to detect.
Notice that extra parameters are passed to detector: see [OpenCV ArUco markers detection parameters documentation](https://docs.opencv.org/4.x/d1/dcd/structcv_1_1aruco_1_1DetectorParameters.html) to know more.
``` python
from argaze.ArUcoMarkers import ArUcoDetector, ArUcoOpticCalibrator
# Assuming camera calibration data are loaded
# Loading extra detector parameters
extra_parameters = ArUcoDetector.DetectorParameters.from_json('./detector_parameters.json')
# Create ArUco detector to track DICT_APRILTAG_16h5 5cm length markers
aruco_detector = ArUcoDetector.ArUcoDetector(optic_parameters=optic_parameters, dictionary='DICT_APRILTAG_16h5', marker_size=5, parameters=extra_parameters)
```
Here is [DetectorParameters](../../../argaze/#argaze.ArUcoMarkers.ArUcoDetector.DetectorParameters) JSON file example:
```
{
"cornerRefinementMethod": 1,
"aprilTagQuadSigma": 2,
"aprilTagDeglitch": 1
}
```
The [ArUcoDetector](../../../argaze/#argaze.ArUcoMarkers.ArUcoDetector.ArUcoDetector) processes image to detect markers and allows to draw detection results onto it:
``` python
# Detect markers into image and draw them
aruco_detector.detect_markers(image)
aruco_detector.draw_detected_markers(image)
# Get corners position into image related to each detected markers
for marker_id, marker in aruco_detector.detected_markers.items():
print(f'marker {marker_id} corners: ', marker.corners)
# Do something with detected marker i corners
...
```
|