CPPxDIC
C++ Digital Image Correlation library for fingertip 3D reconstruction
Loading...
Searching...
No Matches
stereo_calibration.h
Go to the documentation of this file.
1
16#ifndef STEPSABC_STEREO_CALIBRATION_H
17#define STEPSABC_STEREO_CALIBRATION_H
18
19#include <array>
20#include <string>
21#include <vector>
22
23namespace cppxdic {
24namespace stepsABC {
25
28 double x = 0.0;
29 double y = 0.0;
30 double z = 0.0;
31};
32
35 double u = 0.0;
36 double v = 0.0;
37};
38
41 double radius = 30.0; // cylinder radius (mm)
42 int num_columns = 18; // dots around the circumference
43 int num_rows = 11; // dot rows along the cylinder axis
44 double dz = 5.0; // vertical spacing between rows (mm)
45 double theta0_deg = 0.0; // angular offset of first column (deg)
46 bool full_circle = true; // columns span 360 deg (true) or [0, (N-1)*dtheta]
47};
48
50struct CameraDLT {
51 int camera_id = 0;
52 std::array<double, 11> L{}; // 11 DLT parameters
53 double rms_reprojection = 0.0; // RMS image-plane reprojection error (px)
54 bool valid = false;
55};
56
59 double mean = 0.0; // mean 3D error magnitude (mm)
60 double rms = 0.0; // RMS 3D error magnitude (mm)
61 double max = 0.0; // max 3D error magnitude (mm)
62 double std = 0.0; // std-dev of 3D error magnitude (mm)
63 std::vector<double> per_point; // per-point 3D error magnitude (mm)
64};
65
71 std::vector<CalibPoint3D> reconstructed; // triangulated 3D points
72 bool valid = false;
73};
74
76public:
83 static std::vector<CalibPoint3D> generateCylindricalObject(const CylinderCalibSpec& spec);
84
86 static bool writeObjectFile(const std::vector<CalibPoint3D>& pts, const std::string& path,
87 std::string& error_message);
88
90 static std::vector<CalibPoint3D> readObjectFile(const std::string& path,
91 std::string& error_message);
92
94 static std::vector<CalibPoint2D> readImagePointsFile(const std::string& path,
95 std::string& error_message);
96
102 static CameraDLT calcDLTParameters(int camera_id, const std::vector<CalibPoint2D>& image_points,
103 const std::vector<CalibPoint3D>& object_points,
104 std::string& error_message);
105
110 static CalibPoint3D reconstructPoint(const CameraDLT& cam1, const CalibPoint2D& p1,
111 const CameraDLT& cam2, const CalibPoint2D& p2);
112
118 const std::vector<CalibPoint2D>& img1,
119 const CameraDLT& cam2,
120 const std::vector<CalibPoint2D>& img2,
121 const std::vector<CalibPoint3D>& object_points,
122 std::vector<CalibPoint3D>& reconstructed_out);
123
129 int cam_first_id, const std::vector<CalibPoint2D>& img_first, int cam_second_id,
130 const std::vector<CalibPoint2D>& img_second, const std::vector<CalibPoint3D>& object_points,
131 std::string& error_message);
132};
133
134} // namespace stepsABC
135} // namespace cppxdic
136
137#endif // STEPSABC_STEREO_CALIBRATION_H
static ReconstructionError reconstructionError(const CameraDLT &cam1, const std::vector< CalibPoint2D > &img1, const CameraDLT &cam2, const std::vector< CalibPoint2D > &img2, const std::vector< CalibPoint3D > &object_points, std::vector< CalibPoint3D > &reconstructed_out)
DLT reconstruction-error metric: triangulate every calibration point from the two cameras and compare...
static bool writeObjectFile(const std::vector< CalibPoint3D > &pts, const std::string &path, std::string &error_message)
Write generated 3D coordinates to a text file (one "x y z" per line).
static std::vector< CalibPoint3D > readObjectFile(const std::string &path, std::string &error_message)
Read a "x y z" per line 3D coordinate file.
static CalibPoint3D reconstructPoint(const CameraDLT &cam1, const CalibPoint2D &p1, const CameraDLT &cam2, const CalibPoint2D &p2)
Triangulate a 3D point from two cameras' DLT parameters and the matched image observations (linear le...
static CameraDLT calcDLTParameters(int camera_id, const std::vector< CalibPoint2D > &image_points, const std::vector< CalibPoint3D > &object_points, std::string &error_message)
Port of STEP1_CalcDLTparameters_rewrited.m for a single camera.
static std::vector< CalibPoint3D > generateCylindricalObject(const CylinderCalibSpec &spec)
Port of generate_cylindrical_calibration_object_coordinate_file.m.
static std::vector< CalibPoint2D > readImagePointsFile(const std::string &path, std::string &error_message)
Read a "u v" per line 2D image-point file (one per calibration dot).
static StereoCalibrationResult calibrateStereoPair(int cam_first_id, const std::vector< CalibPoint2D > &img_first, int cam_second_id, const std::vector< CalibPoint2D > &img_second, const std::vector< CalibPoint3D > &object_points, std::string &error_message)
Full StepC driver for one stereo pair: fit both cameras and compute the reconstruction error against ...
DataSerializer - Abstract base class for format-agnostic DIC data I/O.
A 2D image observation (pixels).
A single calibration point: 3D world coordinate (mm).
DLT parameters for one camera plus its fit residual.
std::array< double, 11 > L
Geometry of the cylindrical calibration object.
Reconstruction-error metrics for a stereo pair.
Full StepC result for a stereo pair.