blob: 24fd64dc685a25688d22c02bf1363d1fe83aa7c9 [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 {
Brian Silvermanf64b9bd2020-02-29 12:51:33 -080012 // Contains the descriptor data. OpenCV likes to represent them as floats, but
13 // they're really ubytes.
Brian Silvermanfac9b872020-02-05 20:07:38 -080014 //
15 // TODO(Brian): These are scaled to be convertible to chars. Should we do
16 // that to minimize storage space? Or maybe int16?
17 //
18 // The size of this depends on the parameters. It is width*width*hist_bins.
19 // Currently we have width=4 and hist_bins=8, which results in a size of
20 // 4*4*8=128.
Brian Silvermanf64b9bd2020-02-29 12:51:33 -080021 descriptor:[ubyte];
Brian Silvermanfac9b872020-02-05 20:07:38 -080022
23 // Location of the keypoint.
24 x:float;
25 y:float;
26
27 // Size of the keypoint neighborhood.
28 size:float;
29
30 // Angle of the keypoint.
31 // This is in [0,360) clockwise.
32 angle:float;
33
34 // How good of a keypoint this is.
35 response:float;
36
37 // Which octave this keypoint is from.
38 octave:int;
Brian Silverman4d4a70d2020-02-17 13:03:19 -080039
40 // Where this feature's keypoint is on the field. This will only be filled out
41 // for training features, not ones extracted from query images.
42 field_location:KeypointFieldLocation;
Brian Silvermanfac9b872020-02-05 20:07:38 -080043}
44
45// Represents a single match between a training image and a query image.
Brian Silverman4d4a70d2020-02-17 13:03:19 -080046struct Match {
Brian Silvermanfac9b872020-02-05 20:07:38 -080047 // The index of the feature for the query image.
48 query_feature:int;
49 // The index of the feature for the training image.
50 train_feature:int;
Brian Silverman4d4a70d2020-02-17 13:03:19 -080051 // How "good" the match is.
52 distance:float;
Brian Silvermanfac9b872020-02-05 20:07:38 -080053}
54
55// Represents all the matches between a single training image and a query
56// image.
57table ImageMatch {
58 matches:[Match];
59 // The index of the training image within all the training images.
60 train_image:int;
61}
62
63table TransformationMatrix {
Jim Ostrowskiad5d8a72020-02-28 00:15:26 -080064 // The matrix data for a row-major 4x4 homogeneous transformation matrix.
65 // This implies the bottom row is (0, 0, 0, 1).
Brian Silverman4770c7d2020-02-17 20:34:42 -080066 data:[float];
Brian Silvermanfac9b872020-02-05 20:07:38 -080067}
68
Brian Silverman4d4a70d2020-02-17 13:03:19 -080069// Calibration information for a given camera on a given robot.
70table CameraCalibration {
71 // The name of the camera node which this calibration data applies to.
72 node_name:string;
73 // The team number of the robot which this calibration data applies to.
74 team_number:int;
75
76 // Intrinsics for the camera.
77 //
78 // This is the standard OpenCV intrinsics matrix in row major order (3x3).
79 intrinsics:[float];
80
81 // Fixed extrinsics for the camera. This transforms from camera coordinates to
82 // robot coordinates. For example: multiplying (0, 0, 0, 1) by this results in
83 // the position of the camera aperature in robot coordinates.
84 fixed_extrinsics:TransformationMatrix;
85
86 // Extrinsics for a camera on a turret. This will only be filled out for
87 // applicable cameras. For turret-mounted cameras, fixed_extrinsics defines
88 // a position for the center of rotation of the turret, and this field defines
89 // a position for the camera on the turret.
90 //
91 // The combination of the two transformations is underdefined, so nothing can
92 // distinguish between the two parts of the final extrinsics for a given
93 // turret position.
94 //
95 // To get the final extrinsics for a camera using this transformation,
96 // multiply (in order):
97 // fixed_extrinsics
98 // rotation around the Z axis by the turret angle
99 // turret_extrinsics
100 turret_extrinsics:TransformationMatrix;
Jim Ostrowskiad5d8a72020-02-28 00:15:26 -0800101
102 // This is the standard OpenCV 5 parameter distortion coefficients
103 dist_coeffs:[float];
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800104}
105
106// Contains the information the EKF wants from an image matched against a single
107// training image.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800108//
Jim Ostrowskie4264262020-02-29 00:27:24 -0800109// This is represented as a transformation from the camera to the target
110// (camera_to_target) and a transformatoin from the field to the target
111// (field_to_target).
112//
113// We also send the map from the field to the camera, which can be computed
114// with the first two, to make it easier to display.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800115table CameraPose {
Jim Ostrowskie4264262020-02-29 00:27:24 -0800116 // Transformation matrix from the camera to the target.
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800117 // (0, 0, 0) is the aperture of the camera (we pretend it's an ideal pinhole
118 // camera). Positive Z is out of the camera. Positive X and Y are right
119 // handed, but which way they face depends on the camera extrinsics.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800120 camera_to_target:TransformationMatrix;
121
122 // Field coordinates of the target, represented as a transformation matrix
Jim Ostrowskie4264262020-02-29 00:27:24 -0800123 // from the field to the target.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800124 // (0, 0, 0) is the center of the field, on the level of most of the field
125 // (not the region under the truss). Positive X is towards the red alliance's
126 // PLAYER STATION. Positive Z is up. The coordinate system is right-handed.
127 //
128 // Note that the red PLAYER STATION is where the red drive teams are. This is
129 // often where the blue robots are shooting towards.
130 //
131 // The value here will be selected from a small, static set of targets we
132 // train images on.
133 field_to_target:TransformationMatrix;
Jim Ostrowskie4264262020-02-29 00:27:24 -0800134
135 // The pose of the camera in the field coordinate frame
136 field_to_camera:TransformationMatrix;
Jim Ostrowski18f7fbf2020-03-01 13:53:22 -0800137
138 // 2D image coordinate representing target location on the matched image
139 query_target_point_x:float;
140 query_target_point_y:float;
141 // Perceived radius of target circle
142 query_target_point_radius:float;
Brian Silvermanfac9b872020-02-05 20:07:38 -0800143}
144
145table ImageMatchResult {
146 // The matches from this image to each of the training images which matched.
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800147 // Each member is against the same captured image.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800148 image_matches:[ImageMatch];
Jim Ostrowskiad5d8a72020-02-28 00:15:26 -0800149
Brian Silvermanfac9b872020-02-05 20:07:38 -0800150 // The transformations for this image for each of the training images which
151 // matched.
152 // TODO(Brian): Include some kind of covariance information for these.
153 camera_poses:[CameraPose];
154
155 // The features for this image.
156 features:[Feature];
Brian Silverman967e5df2020-02-09 16:43:34 -0800157
158 // Timestamp when the frame was captured.
159 image_monotonic_timestamp_ns:long;
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800160
161 // Information about the camera which took this image.
162 camera_calibration:CameraCalibration;
Brian Silvermanfac9b872020-02-05 20:07:38 -0800163}
164
165root_type ImageMatchResult;