6
6
7
7
from .coordinates import (
8
8
Cartesian ,
9
+ HomographyMatrix ,
9
10
cartesian_to_legacy_polar ,
10
11
cartesian_to_spherical ,
11
12
)
@@ -48,6 +49,13 @@ def from_apriltag_detection(
48
49
49
50
pixel_corners = [PixelCoordinate (* l ) for l in apriltag_detection .p ]
50
51
52
+ homography_matrix = HomographyMatrix (np .reshape (
53
+ [apriltag_detection .H .data [i ] for i in range (9 )],
54
+ (3 , 3 ),
55
+ ).tolist ())
56
+ # The homography matrix is a 2D transformation of a unit square to the
57
+ # co-ordinates of the marker in the image
58
+
51
59
marker_id = apriltag_detection .id
52
60
53
61
# *************************************************************************
@@ -59,7 +67,10 @@ def from_apriltag_detection(
59
67
certainty = apriltag_detection .goodness ,
60
68
)
61
69
62
- instance .update_pixel_coords (pixel_corners = pixel_corners )
70
+ instance .update_2D_transforms (
71
+ pixel_corners = pixel_corners ,
72
+ homography_matrix = homography_matrix ,
73
+ )
63
74
64
75
# We don't set coordinates in the absence of a camera model.
65
76
if camera_model :
@@ -80,10 +91,11 @@ def from_apriltag_detection(
80
91
return instance
81
92
82
93
# noinspection PyAttributeOutsideInit
83
- def update_pixel_coords (
84
- self ,
85
- * ,
86
- pixel_corners : List [PixelCoordinate ]
94
+ def update_2D_transforms (
95
+ self ,
96
+ * ,
97
+ pixel_corners : List [PixelCoordinate ],
98
+ homography_matrix : HomographyMatrix ,
87
99
):
88
100
"""Set the pixel coordinate information of the Token."""
89
101
# The pixel_corners value we expose is in clockwise order starting with
@@ -95,6 +107,8 @@ def update_pixel_coords(
95
107
# centre of marker: average the corners
96
108
self .pixel_centre = PixelCoordinate (* np .average (pixel_corners , axis = 0 ))
97
109
110
+ self .homography_matrix = homography_matrix
111
+
98
112
# noinspection PyAttributeOutsideInit
99
113
def update_3D_transforms (
100
114
self ,
0 commit comments