blob: 3336d0c1f86a571315026739885337385159662d [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 {
Austin Schuhd7851b02020-11-14 13:46:27 -08005 x:float (id: 0);
6 y:float (id: 1);
7 z:float (id: 2);
Brian Silverman4d4a70d2020-02-17 13:03:19 -08008}
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.
Austin Schuhd7851b02020-11-14 13:46:27 -080021 descriptor:[ubyte] (id: 0);
Brian Silvermanfac9b872020-02-05 20:07:38 -080022
23 // Location of the keypoint.
Austin Schuhd7851b02020-11-14 13:46:27 -080024 x:float (id: 1);
25 y:float (id: 2);
Brian Silvermanfac9b872020-02-05 20:07:38 -080026
27 // Size of the keypoint neighborhood.
Austin Schuhd7851b02020-11-14 13:46:27 -080028 size:float (id: 3);
Brian Silvermanfac9b872020-02-05 20:07:38 -080029
30 // Angle of the keypoint.
31 // This is in [0,360) clockwise.
Austin Schuhd7851b02020-11-14 13:46:27 -080032 angle:float (id: 4);
Brian Silvermanfac9b872020-02-05 20:07:38 -080033
34 // How good of a keypoint this is.
Austin Schuhd7851b02020-11-14 13:46:27 -080035 response:float (id: 5);
Brian Silvermanfac9b872020-02-05 20:07:38 -080036
37 // Which octave this keypoint is from.
Austin Schuhd7851b02020-11-14 13:46:27 -080038 octave:int (id: 6);
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.
Austin Schuhd7851b02020-11-14 13:46:27 -080042 field_location:KeypointFieldLocation (id: 7);
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.
Austin Schuhd7851b02020-11-14 13:46:27 -080048 query_feature:int (id: 0);
Brian Silvermanfac9b872020-02-05 20:07:38 -080049 // The index of the feature for the training image.
Austin Schuhd7851b02020-11-14 13:46:27 -080050 train_feature:int (id: 1);
Brian Silverman4d4a70d2020-02-17 13:03:19 -080051 // How "good" the match is.
Austin Schuhd7851b02020-11-14 13:46:27 -080052 distance:float (id: 2);
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 {
Austin Schuhd7851b02020-11-14 13:46:27 -080058 matches:[Match] (id: 0);
Brian Silvermanfac9b872020-02-05 20:07:38 -080059 // The index of the training image within all the training images.
Austin Schuhd7851b02020-11-14 13:46:27 -080060 train_image:int (id: 1);
Brian Silvermanfac9b872020-02-05 20:07:38 -080061}
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).
Austin Schuhd7851b02020-11-14 13:46:27 -080066 data:[float] (id: 0);
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.
Austin Schuhd7851b02020-11-14 13:46:27 -080072 node_name:string (id: 0);
Brian Silverman4d4a70d2020-02-17 13:03:19 -080073 // The team number of the robot which this calibration data applies to.
Austin Schuhd7851b02020-11-14 13:46:27 -080074 team_number:int (id: 1);
Brian Silverman4d4a70d2020-02-17 13:03:19 -080075
76 // Intrinsics for the camera.
77 //
78 // This is the standard OpenCV intrinsics matrix in row major order (3x3).
Austin Schuhd7851b02020-11-14 13:46:27 -080079 intrinsics:[float] (id: 2);
Brian Silverman4d4a70d2020-02-17 13:03:19 -080080
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.
Austin Schuhd7851b02020-11-14 13:46:27 -080084 fixed_extrinsics:TransformationMatrix (id: 3);
Brian Silverman4d4a70d2020-02-17 13:03:19 -080085
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
Austin Schuhd7851b02020-11-14 13:46:27 -0800100 turret_extrinsics:TransformationMatrix (id: 4);
Jim Ostrowskiad5d8a72020-02-28 00:15:26 -0800101
102 // This is the standard OpenCV 5 parameter distortion coefficients
Austin Schuhd7851b02020-11-14 13:46:27 -0800103 dist_coeffs:[float] (id: 5);
Austin Schuhc1f118e2020-04-11 15:50:08 -0700104
105 // Timestamp for when the calibration was taken on the realtime clock.
Austin Schuhd7851b02020-11-14 13:46:27 -0800106 calibration_timestamp:int64 (id: 6);
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800107}
108
109// Contains the information the EKF wants from an image matched against a single
110// training image.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800111//
Jim Ostrowskie4264262020-02-29 00:27:24 -0800112// This is represented as a transformation from the camera to the target
113// (camera_to_target) and a transformatoin from the field to the target
114// (field_to_target).
115//
116// We also send the map from the field to the camera, which can be computed
117// with the first two, to make it easier to display.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800118table CameraPose {
Jim Ostrowskie4264262020-02-29 00:27:24 -0800119 // Transformation matrix from the camera to the target.
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800120 // (0, 0, 0) is the aperture of the camera (we pretend it's an ideal pinhole
121 // camera). Positive Z is out of the camera. Positive X and Y are right
122 // handed, but which way they face depends on the camera extrinsics.
Austin Schuhd7851b02020-11-14 13:46:27 -0800123 camera_to_target:TransformationMatrix (id: 0);
Brian Silvermanfac9b872020-02-05 20:07:38 -0800124
125 // Field coordinates of the target, represented as a transformation matrix
Jim Ostrowskie4264262020-02-29 00:27:24 -0800126 // from the field to the target.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800127 // (0, 0, 0) is the center of the field, on the level of most of the field
128 // (not the region under the truss). Positive X is towards the red alliance's
129 // PLAYER STATION. Positive Z is up. The coordinate system is right-handed.
130 //
131 // Note that the red PLAYER STATION is where the red drive teams are. This is
132 // often where the blue robots are shooting towards.
133 //
134 // The value here will be selected from a small, static set of targets we
135 // train images on.
Austin Schuhd7851b02020-11-14 13:46:27 -0800136 field_to_target:TransformationMatrix (id: 1);
Jim Ostrowskie4264262020-02-29 00:27:24 -0800137
138 // The pose of the camera in the field coordinate frame
Austin Schuhd7851b02020-11-14 13:46:27 -0800139 field_to_camera:TransformationMatrix (id: 2);
Jim Ostrowski18f7fbf2020-03-01 13:53:22 -0800140
141 // 2D image coordinate representing target location on the matched image
Austin Schuhd7851b02020-11-14 13:46:27 -0800142 query_target_point_x:float (id: 3);
143 query_target_point_y:float (id: 4);
Jim Ostrowski18f7fbf2020-03-01 13:53:22 -0800144 // Perceived radius of target circle
Austin Schuhd7851b02020-11-14 13:46:27 -0800145 query_target_point_radius:float (id: 5);
James Kuszmaul9c658352021-10-22 19:37:58 -0700146 // Number of features used in this match.
147 homography_feature_count:int (id: 6);
148 // Training image used for this pose.
149 training_image_index:int (id: 7);
Brian Silvermanfac9b872020-02-05 20:07:38 -0800150}
151
152table ImageMatchResult {
153 // The matches from this image to each of the training images which matched.
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800154 // Each member is against the same captured image.
Austin Schuhd7851b02020-11-14 13:46:27 -0800155 image_matches:[ImageMatch] (id: 0);
Jim Ostrowskiad5d8a72020-02-28 00:15:26 -0800156
Brian Silvermanfac9b872020-02-05 20:07:38 -0800157 // The transformations for this image for each of the training images which
158 // matched.
159 // TODO(Brian): Include some kind of covariance information for these.
Austin Schuhd7851b02020-11-14 13:46:27 -0800160 camera_poses:[CameraPose] (id: 1);
Brian Silvermanfac9b872020-02-05 20:07:38 -0800161
162 // The features for this image.
Austin Schuhd7851b02020-11-14 13:46:27 -0800163 features:[Feature] (id: 2);
Brian Silverman967e5df2020-02-09 16:43:34 -0800164
165 // Timestamp when the frame was captured.
Austin Schuhd7851b02020-11-14 13:46:27 -0800166 image_monotonic_timestamp_ns:long (id: 3);
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800167
168 // Information about the camera which took this image.
Austin Schuhd7851b02020-11-14 13:46:27 -0800169 camera_calibration:CameraCalibration (id: 4);
milind1f1dca32021-07-03 13:50:07 -0700170
171 // Total number of match result send failures.
172 send_failures:uint64 (id: 5);
Brian Silvermanfac9b872020-02-05 20:07:38 -0800173}
174
175root_type ImageMatchResult;