blob: 43ea152cfe2aefc41d08dff1a4f6496969f3239e [file] [log] [blame]
Brian Silvermanfac9b872020-02-05 20:07:38 -08001namespace frc971.vision.sift;
2
Brian Silverman4d4a70d2020-02-17 13:03:19 -08003// Represents the location of a keypoint in field coordinates.
4struct KeypointFieldLocation {
5 x:float;
6 y:float;
7 z:float;
8}
9
Brian Silvermanfac9b872020-02-05 20:07:38 -080010// Represents a single feature extracted from an image.
11table Feature {
12 // Contains the descriptor data.
13 //
14 // TODO(Brian): These are scaled to be convertible to chars. Should we do
15 // that to minimize storage space? Or maybe int16?
16 //
17 // The size of this depends on the parameters. It is width*width*hist_bins.
18 // Currently we have width=4 and hist_bins=8, which results in a size of
19 // 4*4*8=128.
20 descriptor:[float];
21
22 // Location of the keypoint.
23 x:float;
24 y:float;
25
26 // Size of the keypoint neighborhood.
27 size:float;
28
29 // Angle of the keypoint.
30 // This is in [0,360) clockwise.
31 angle:float;
32
33 // How good of a keypoint this is.
34 response:float;
35
36 // Which octave this keypoint is from.
37 octave:int;
Brian Silverman4d4a70d2020-02-17 13:03:19 -080038
39 // Where this feature's keypoint is on the field. This will only be filled out
40 // for training features, not ones extracted from query images.
41 field_location:KeypointFieldLocation;
Brian Silvermanfac9b872020-02-05 20:07:38 -080042}
43
44// Represents a single match between a training image and a query image.
Brian Silverman4d4a70d2020-02-17 13:03:19 -080045struct Match {
Brian Silvermanfac9b872020-02-05 20:07:38 -080046 // The index of the feature for the query image.
47 query_feature:int;
48 // The index of the feature for the training image.
49 train_feature:int;
Brian Silverman4d4a70d2020-02-17 13:03:19 -080050 // How "good" the match is.
51 distance:float;
Brian Silvermanfac9b872020-02-05 20:07:38 -080052}
53
54// Represents all the matches between a single training image and a query
55// image.
56table ImageMatch {
57 matches:[Match];
58 // The index of the training image within all the training images.
59 train_image:int;
60}
61
62table TransformationMatrix {
Jim Ostrowskiad5d8a72020-02-28 00:15:26 -080063 // The matrix data for a row-major 4x4 homogeneous transformation matrix.
64 // This implies the bottom row is (0, 0, 0, 1).
Brian Silverman4770c7d2020-02-17 20:34:42 -080065 data:[float];
Brian Silvermanfac9b872020-02-05 20:07:38 -080066}
67
Brian Silverman4d4a70d2020-02-17 13:03:19 -080068// Calibration information for a given camera on a given robot.
69table CameraCalibration {
70 // The name of the camera node which this calibration data applies to.
71 node_name:string;
72 // The team number of the robot which this calibration data applies to.
73 team_number:int;
74
75 // Intrinsics for the camera.
76 //
77 // This is the standard OpenCV intrinsics matrix in row major order (3x3).
78 intrinsics:[float];
79
80 // Fixed extrinsics for the camera. This transforms from camera coordinates to
81 // robot coordinates. For example: multiplying (0, 0, 0, 1) by this results in
82 // the position of the camera aperature in robot coordinates.
83 fixed_extrinsics:TransformationMatrix;
84
85 // Extrinsics for a camera on a turret. This will only be filled out for
86 // applicable cameras. For turret-mounted cameras, fixed_extrinsics defines
87 // a position for the center of rotation of the turret, and this field defines
88 // a position for the camera on the turret.
89 //
90 // The combination of the two transformations is underdefined, so nothing can
91 // distinguish between the two parts of the final extrinsics for a given
92 // turret position.
93 //
94 // To get the final extrinsics for a camera using this transformation,
95 // multiply (in order):
96 // fixed_extrinsics
97 // rotation around the Z axis by the turret angle
98 // turret_extrinsics
99 turret_extrinsics:TransformationMatrix;
Jim Ostrowskiad5d8a72020-02-28 00:15:26 -0800100
101 // This is the standard OpenCV 5 parameter distortion coefficients
102 dist_coeffs:[float];
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800103}
104
105// Contains the information the EKF wants from an image matched against a single
106// training image.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800107//
Jim Ostrowskie4264262020-02-29 00:27:24 -0800108// This is represented as a transformation from the camera to the target
109// (camera_to_target) and a transformatoin from the field to the target
110// (field_to_target).
111//
112// We also send the map from the field to the camera, which can be computed
113// with the first two, to make it easier to display.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800114table CameraPose {
Jim Ostrowskie4264262020-02-29 00:27:24 -0800115 // Transformation matrix from the camera to the target.
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800116 // (0, 0, 0) is the aperture of the camera (we pretend it's an ideal pinhole
117 // camera). Positive Z is out of the camera. Positive X and Y are right
118 // handed, but which way they face depends on the camera extrinsics.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800119 camera_to_target:TransformationMatrix;
120
121 // Field coordinates of the target, represented as a transformation matrix
Jim Ostrowskie4264262020-02-29 00:27:24 -0800122 // from the field to the target.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800123 // (0, 0, 0) is the center of the field, on the level of most of the field
124 // (not the region under the truss). Positive X is towards the red alliance's
125 // PLAYER STATION. Positive Z is up. The coordinate system is right-handed.
126 //
127 // Note that the red PLAYER STATION is where the red drive teams are. This is
128 // often where the blue robots are shooting towards.
129 //
130 // The value here will be selected from a small, static set of targets we
131 // train images on.
132 field_to_target:TransformationMatrix;
Jim Ostrowskie4264262020-02-29 00:27:24 -0800133
134 // The pose of the camera in the field coordinate frame
135 field_to_camera:TransformationMatrix;
Brian Silvermanfac9b872020-02-05 20:07:38 -0800136}
137
138table ImageMatchResult {
139 // The matches from this image to each of the training images which matched.
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800140 // Each member is against the same captured image.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800141 image_matches:[ImageMatch];
Jim Ostrowskiad5d8a72020-02-28 00:15:26 -0800142
Brian Silvermanfac9b872020-02-05 20:07:38 -0800143 // The transformations for this image for each of the training images which
144 // matched.
145 // TODO(Brian): Include some kind of covariance information for these.
146 camera_poses:[CameraPose];
147
148 // The features for this image.
149 features:[Feature];
Brian Silverman967e5df2020-02-09 16:43:34 -0800150
151 // Timestamp when the frame was captured.
152 image_monotonic_timestamp_ns:long;
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800153
154 // Information about the camera which took this image.
155 camera_calibration:CameraCalibration;
Jim Ostrowskiad5d8a72020-02-28 00:15:26 -0800156
157 // 2D image coordinate representing target location on the matched image
158 target_point_x:float;
159 target_point_y:float;
Brian Silvermanfac9b872020-02-05 20:07:38 -0800160}
161
162root_type ImageMatchResult;