Add constants.h which contains the result of calibration.
Change-Id: Ia7f76ff9bd549728c40888e800ebc266769525db
diff --git a/y2019/vision/BUILD b/y2019/vision/BUILD
index c2f9da5..bdef187 100644
--- a/y2019/vision/BUILD
+++ b/y2019/vision/BUILD
@@ -10,6 +10,12 @@
]
cc_library(
+ name = "constants",
+ hdrs = ["constants.h"],
+ srcs = ["constants.cc"],
+)
+
+cc_library(
name = "target_finder",
srcs = [
"target_finder.cc",
@@ -21,6 +27,7 @@
],
restricted_to = VISION_TARGETS,
deps = [
+ ":constants",
"//aos/vision/blob:contour",
"//aos/vision/blob:hierarchical_contour_merge",
"//aos/vision/blob:region_alloc",
diff --git a/y2019/vision/constants.cc b/y2019/vision/constants.cc
new file mode 100644
index 0000000..bf3953c
--- /dev/null
+++ b/y2019/vision/constants.cc
@@ -0,0 +1,33 @@
+#include "y2019/vision/constants.h"
+
+namespace y2019 {
+namespace vision {
+
+constexpr double kInchesToMeters = 0.0254;
+
+CameraCalibration camera_4 = {
+ {
+ 3.50309 / 180.0 * M_PI, 593.557, -0.0487739 / 180.0 * M_PI,
+ },
+ {
+ {{5.56082 / kInchesToMeters, 4.70235 / kInchesToMeters,
+ 33.4998 / kInchesToMeters}},
+ 22.2155 * M_PI / 180.0,
+ },
+ {
+ 4,
+ {{12.5 / kInchesToMeters, 12.0 / kInchesToMeters}},
+ {{kInchesToMeters, 0.0}},
+ 26.0,
+ "cam4_0/debug_viewer_jpeg_",
+ }};
+
+const CameraCalibration *GetCamera(int camera_id) {
+ switch (camera_id) {
+ case 4: return &camera_4;
+ default: return nullptr;
+ }
+}
+
+} // namespace vision
+} // namespace y2019
diff --git a/y2019/vision/constants.h b/y2019/vision/constants.h
new file mode 100644
index 0000000..cbad8bf
--- /dev/null
+++ b/y2019/vision/constants.h
@@ -0,0 +1,78 @@
+#ifndef _Y2019_VISION_CONSTANTS_H_
+#define _Y2019_VISION_CONSTANTS_H_
+
+#include <math.h>
+#include <array>
+#include <string>
+
+namespace y2019 {
+namespace vision {
+
+// Position of the idealized camera in 3d space.
+struct CameraGeometry {
+ // In Meters from floor under imu center.
+ std::array<double, 3> location{{0, 0, 0}};
+ double heading = 0.0;
+
+ void set(double *data) {
+ location[0] = data[0];
+ location[1] = data[1];
+ location[2] = data[2];
+ heading = data[3];
+ }
+ static CameraGeometry get(const double *data) {
+ CameraGeometry out;
+ out.location[0] = data[0];
+ out.location[1] = data[1];
+ out.location[2] = data[2];
+ out.heading = data[3];
+ return out;
+ }
+};
+
+struct IntrinsicParams {
+ static constexpr size_t kNumParams = 3;
+
+ double mount_angle = 0.819433 / 180.0 * M_PI; // 9.32615 / 180.0 * M_PI;
+ double focal_length = 666.763; // 734.328;
+ // This is a final rotation where the camera isn't straight.
+ double barrel_mount = 2.72086 / 180.0 * M_PI;
+
+ void set(double *data) {
+ data[0] = mount_angle;
+ data[1] = focal_length;
+ data[2] = barrel_mount;
+ }
+ static IntrinsicParams get(const double *data) {
+ IntrinsicParams out;
+ out.mount_angle = data[0];
+ out.focal_length = data[1];
+ out.barrel_mount = data[2];
+ return out;
+ }
+};
+
+// Metadata about the calibration results (Should be good enough to reproduce).
+struct DatasetInfo {
+ int camera_id;
+ // In meters from IMU start.
+ std::array<double, 2> to_tape_measure_start;
+ // In meters,
+ std::array<double, 2> tape_measure_direction;
+ // This will multiply tape_measure_direction and thus has no units.
+ double beginning_tape_measure_reading;
+ const char *filename_prefix;
+};
+
+struct CameraCalibration {
+ IntrinsicParams intrinsics;
+ CameraGeometry geometry;
+ DatasetInfo dataset;
+};
+
+const CameraCalibration *GetCamera(int camera_id);
+
+} // namespace vision
+} // namespace y2019
+
+#endif // _Y2019_VISION_CONSTANTS_H_
diff --git a/y2019/vision/target_types.h b/y2019/vision/target_types.h
index 089b897..a20ecf7 100644
--- a/y2019/vision/target_types.h
+++ b/y2019/vision/target_types.h
@@ -3,6 +3,7 @@
#include "aos/vision/math/segment.h"
#include "aos/vision/math/vector.h"
+#include "y2019/vision/constants.h"
namespace y2019 {
namespace vision {
@@ -42,28 +43,6 @@
std::array<aos::vision::Vector<2>, 8> toPointList() const;
};
-struct IntrinsicParams {
- static constexpr size_t kNumParams = 3;
-
- double mount_angle = 0.819433 / 180.0 * M_PI; // 9.32615 / 180.0 * M_PI;
- double focal_length = 666.763; // 734.328;
- // This is a final rotation where the camera isn't straight.
- double barrel_mount = 2.72086 / 180.0 * M_PI;
-
- void set(double *data) {
- data[0] = mount_angle;
- data[1] = focal_length;
- data[2] = barrel_mount;
- }
- static IntrinsicParams get(const double *data) {
- IntrinsicParams out;
- out.mount_angle = data[0];
- out.focal_length = data[1];
- out.barrel_mount = data[2];
- return out;
- }
-};
-
struct ExtrinsicParams {
static constexpr size_t kNumParams = 4;