blob: 77d0dc60008be59af05fe5aae9f709c73e1734d4 [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 {
63 // The matrix data. This is a row-major 3x4 matrix.
64 data:[double];
65}
66
Brian Silverman4d4a70d2020-02-17 13:03:19 -080067// Calibration information for a given camera on a given robot.
68table CameraCalibration {
69 // The name of the camera node which this calibration data applies to.
70 node_name:string;
71 // The team number of the robot which this calibration data applies to.
72 team_number:int;
73
74 // Intrinsics for the camera.
75 //
76 // This is the standard OpenCV intrinsics matrix in row major order (3x3).
77 intrinsics:[float];
78
79 // Fixed extrinsics for the camera. This transforms from camera coordinates to
80 // robot coordinates. For example: multiplying (0, 0, 0, 1) by this results in
81 // the position of the camera aperature in robot coordinates.
82 fixed_extrinsics:TransformationMatrix;
83
84 // Extrinsics for a camera on a turret. This will only be filled out for
85 // applicable cameras. For turret-mounted cameras, fixed_extrinsics defines
86 // a position for the center of rotation of the turret, and this field defines
87 // a position for the camera on the turret.
88 //
89 // The combination of the two transformations is underdefined, so nothing can
90 // distinguish between the two parts of the final extrinsics for a given
91 // turret position.
92 //
93 // To get the final extrinsics for a camera using this transformation,
94 // multiply (in order):
95 // fixed_extrinsics
96 // rotation around the Z axis by the turret angle
97 // turret_extrinsics
98 turret_extrinsics:TransformationMatrix;
99}
100
101// Contains the information the EKF wants from an image matched against a single
102// training image.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800103//
104// This is represented as a transformation to a target in field coordinates.
105table CameraPose {
106 // Transformation matrix from the target to the camera's origin.
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800107 // (0, 0, 0) is the aperture of the camera (we pretend it's an ideal pinhole
108 // camera). Positive Z is out of the camera. Positive X and Y are right
109 // handed, but which way they face depends on the camera extrinsics.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800110 camera_to_target:TransformationMatrix;
111
112 // Field coordinates of the target, represented as a transformation matrix
113 // from the target to the field.
114 // (0, 0, 0) is the center of the field, on the level of most of the field
115 // (not the region under the truss). Positive X is towards the red alliance's
116 // PLAYER STATION. Positive Z is up. The coordinate system is right-handed.
117 //
118 // Note that the red PLAYER STATION is where the red drive teams are. This is
119 // often where the blue robots are shooting towards.
120 //
121 // The value here will be selected from a small, static set of targets we
122 // train images on.
123 field_to_target:TransformationMatrix;
124}
125
126table ImageMatchResult {
127 // The matches from this image to each of the training images which matched.
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800128 // Each member is against the same captured image.
Brian Silvermanfac9b872020-02-05 20:07:38 -0800129 image_matches:[ImageMatch];
130 // The transformations for this image for each of the training images which
131 // matched.
132 // TODO(Brian): Include some kind of covariance information for these.
133 camera_poses:[CameraPose];
134
135 // The features for this image.
136 features:[Feature];
Brian Silverman967e5df2020-02-09 16:43:34 -0800137
138 // Timestamp when the frame was captured.
139 image_monotonic_timestamp_ns:long;
Brian Silverman4d4a70d2020-02-17 13:03:19 -0800140
141 // Information about the camera which took this image.
142 camera_calibration:CameraCalibration;
Brian Silvermanfac9b872020-02-05 20:07:38 -0800143}
144
145root_type ImageMatchResult;