mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
t/calib: Also save the fisheye distortion always
This commit is contained in:
parent
f9599a6763
commit
419f038017
|
@ -35,13 +35,11 @@ public:
|
||||||
cv::Mat l_intrinsics_mat = {};
|
cv::Mat l_intrinsics_mat = {};
|
||||||
cv::Mat l_distortion_mat = {};
|
cv::Mat l_distortion_mat = {};
|
||||||
cv::Mat l_distortion_fisheye_mat = {};
|
cv::Mat l_distortion_fisheye_mat = {};
|
||||||
cv::Mat l_translation_mat = {};
|
|
||||||
cv::Mat l_rotation_mat = {};
|
cv::Mat l_rotation_mat = {};
|
||||||
cv::Mat l_projection_mat = {};
|
cv::Mat l_projection_mat = {};
|
||||||
cv::Mat r_intrinsics_mat = {};
|
cv::Mat r_intrinsics_mat = {};
|
||||||
cv::Mat r_distortion_mat = {};
|
cv::Mat r_distortion_mat = {};
|
||||||
cv::Mat r_distortion_fisheye_mat = {};
|
cv::Mat r_distortion_fisheye_mat = {};
|
||||||
cv::Mat r_translation_mat = {};
|
|
||||||
cv::Mat r_rotation_mat = {};
|
cv::Mat r_rotation_mat = {};
|
||||||
cv::Mat r_projection_mat = {};
|
cv::Mat r_projection_mat = {};
|
||||||
|
|
||||||
|
@ -57,11 +55,13 @@ public:
|
||||||
|
|
||||||
l_intrinsics_mat = cv::Mat(3, 3, CV_64F, &l_intrinsics[0][0]);
|
l_intrinsics_mat = cv::Mat(3, 3, CV_64F, &l_intrinsics[0][0]);
|
||||||
l_distortion_mat = cv::Mat(1, 5, CV_64F, &l_distortion[0]);
|
l_distortion_mat = cv::Mat(1, 5, CV_64F, &l_distortion[0]);
|
||||||
|
l_distortion_fisheye_mat = cv::Mat(1, 4, CV_64F, &l_distortion_fisheye[0]);
|
||||||
l_rotation_mat = cv::Mat(3, 3, CV_64F, &l_rotation[0][0]);
|
l_rotation_mat = cv::Mat(3, 3, CV_64F, &l_rotation[0][0]);
|
||||||
l_projection_mat = cv::Mat(3, 4, CV_64F, &l_projection[0][0]);
|
l_projection_mat = cv::Mat(3, 4, CV_64F, &l_projection[0][0]);
|
||||||
|
|
||||||
r_intrinsics_mat = cv::Mat(3, 3, CV_64F, &r_intrinsics[0][0]);
|
r_intrinsics_mat = cv::Mat(3, 3, CV_64F, &r_intrinsics[0][0]);
|
||||||
r_distortion_mat = cv::Mat(1, 5, CV_64F, &r_distortion[0]);
|
r_distortion_mat = cv::Mat(1, 5, CV_64F, &r_distortion[0]);
|
||||||
|
r_distortion_fisheye_mat = cv::Mat(1, 4, CV_64F, &r_distortion_fisheye[0]);
|
||||||
r_rotation_mat = cv::Mat(3, 3, CV_64F, &r_rotation[0][0]);
|
r_rotation_mat = cv::Mat(3, 3, CV_64F, &r_rotation[0][0]);
|
||||||
r_projection_mat = cv::Mat(3, 4, CV_64F, &r_projection[0][0]);
|
r_projection_mat = cv::Mat(3, 4, CV_64F, &r_projection[0][0]);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -76,14 +76,12 @@ public:
|
||||||
camera_fundamental_mat.size() == cv::Size(3, 3) &&
|
camera_fundamental_mat.size() == cv::Size(3, 3) &&
|
||||||
l_intrinsics_mat.size() == cv::Size(3, 3) &&
|
l_intrinsics_mat.size() == cv::Size(3, 3) &&
|
||||||
l_distortion_mat.size() == cv::Size(5, 1) &&
|
l_distortion_mat.size() == cv::Size(5, 1) &&
|
||||||
l_distortion_fisheye_mat.size() == cv::Size(0, 0) &&
|
l_distortion_fisheye_mat.size() == cv::Size(4, 1) &&
|
||||||
l_translation_mat.size() == cv::Size(0, 0) &&
|
|
||||||
l_rotation_mat.size() == cv::Size(3, 3) &&
|
l_rotation_mat.size() == cv::Size(3, 3) &&
|
||||||
l_projection_mat.size() == cv::Size(4, 3) &&
|
l_projection_mat.size() == cv::Size(4, 3) &&
|
||||||
r_intrinsics_mat.size() == cv::Size(3, 3) &&
|
r_intrinsics_mat.size() == cv::Size(3, 3) &&
|
||||||
r_distortion_mat.size() == cv::Size(5, 1) &&
|
r_distortion_mat.size() == cv::Size(5, 1) &&
|
||||||
r_distortion_fisheye_mat.size() == cv::Size(0, 0) &&
|
r_distortion_fisheye_mat.size() == cv::Size(4, 1) &&
|
||||||
r_translation_mat.size() == cv::Size(0, 0) &&
|
|
||||||
r_rotation_mat.size() == cv::Size(3, 3) &&
|
r_rotation_mat.size() == cv::Size(3, 3) &&
|
||||||
r_projection_mat.size() == cv::Size(4, 3);
|
r_projection_mat.size() == cv::Size(4, 3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,10 @@ t_file_load_stereo_calibration_v1(FILE *calib_file,
|
||||||
|
|
||||||
assert(raw.isDataStorageValid());
|
assert(raw.isDataStorageValid());
|
||||||
|
|
||||||
|
// Dummies
|
||||||
|
cv::Mat l_translation_dummy;
|
||||||
|
cv::Mat r_translation_dummy;
|
||||||
|
|
||||||
//! @todo Load from file.
|
//! @todo Load from file.
|
||||||
bool use_fisheye = false;
|
bool use_fisheye = false;
|
||||||
|
|
||||||
|
@ -74,8 +78,8 @@ t_file_load_stereo_calibration_v1(FILE *calib_file,
|
||||||
read_cv_mat(calib_file, &raw.r_distortion_fisheye_mat, "r_distortion_fisheye");
|
read_cv_mat(calib_file, &raw.r_distortion_fisheye_mat, "r_distortion_fisheye");
|
||||||
read_cv_mat(calib_file, &raw.l_rotation_mat, "l_rotation"); // 3 x 3
|
read_cv_mat(calib_file, &raw.l_rotation_mat, "l_rotation"); // 3 x 3
|
||||||
read_cv_mat(calib_file, &raw.r_rotation_mat, "r_rotation"); // 3 x 3
|
read_cv_mat(calib_file, &raw.r_rotation_mat, "r_rotation"); // 3 x 3
|
||||||
read_cv_mat(calib_file, &raw.l_translation_mat, "l_translation"); // empty
|
read_cv_mat(calib_file, &l_translation_dummy, "l_translation"); // empty
|
||||||
read_cv_mat(calib_file, &raw.r_translation_mat, "r_translation"); // empty
|
read_cv_mat(calib_file, &r_translation_dummy, "r_translation"); // empty
|
||||||
read_cv_mat(calib_file, &raw.l_projection_mat, "l_projection"); // 3 x 4
|
read_cv_mat(calib_file, &raw.l_projection_mat, "l_projection"); // 3 x 4
|
||||||
read_cv_mat(calib_file, &raw.r_projection_mat, "r_projection"); // 3 x 4
|
read_cv_mat(calib_file, &raw.r_projection_mat, "r_projection"); // 3 x 4
|
||||||
read_cv_mat(calib_file, &raw.disparity_to_depth_mat, "disparity_to_depth"); // 4 x 4
|
read_cv_mat(calib_file, &raw.disparity_to_depth_mat, "disparity_to_depth"); // 4 x 4
|
||||||
|
@ -213,6 +217,10 @@ t_file_save_raw_data(FILE *calib_file, struct t_calibration_raw_data *raw_data)
|
||||||
{
|
{
|
||||||
CalibrationRawData &raw = *(CalibrationRawData *)raw_data;
|
CalibrationRawData &raw = *(CalibrationRawData *)raw_data;
|
||||||
|
|
||||||
|
cv::Mat l_translation_dummy;
|
||||||
|
cv::Mat r_translation_dummy;
|
||||||
|
|
||||||
|
|
||||||
write_cv_mat(calib_file, &raw.l_intrinsics_mat);
|
write_cv_mat(calib_file, &raw.l_intrinsics_mat);
|
||||||
write_cv_mat(calib_file, &raw.r_intrinsics_mat);
|
write_cv_mat(calib_file, &raw.r_intrinsics_mat);
|
||||||
write_cv_mat(calib_file, &raw.l_distortion_mat);
|
write_cv_mat(calib_file, &raw.l_distortion_mat);
|
||||||
|
@ -221,8 +229,8 @@ t_file_save_raw_data(FILE *calib_file, struct t_calibration_raw_data *raw_data)
|
||||||
write_cv_mat(calib_file, &raw.r_distortion_fisheye_mat);
|
write_cv_mat(calib_file, &raw.r_distortion_fisheye_mat);
|
||||||
write_cv_mat(calib_file, &raw.l_rotation_mat);
|
write_cv_mat(calib_file, &raw.l_rotation_mat);
|
||||||
write_cv_mat(calib_file, &raw.r_rotation_mat);
|
write_cv_mat(calib_file, &raw.r_rotation_mat);
|
||||||
write_cv_mat(calib_file, &raw.l_translation_mat);
|
write_cv_mat(calib_file, &l_translation_dummy);
|
||||||
write_cv_mat(calib_file, &raw.r_translation_mat);
|
write_cv_mat(calib_file, &r_translation_dummy);
|
||||||
write_cv_mat(calib_file, &raw.l_projection_mat);
|
write_cv_mat(calib_file, &raw.l_projection_mat);
|
||||||
write_cv_mat(calib_file, &raw.r_projection_mat);
|
write_cv_mat(calib_file, &raw.r_projection_mat);
|
||||||
write_cv_mat(calib_file, &raw.disparity_to_depth_mat);
|
write_cv_mat(calib_file, &raw.disparity_to_depth_mat);
|
||||||
|
@ -345,6 +353,10 @@ read_cv_mat(FILE *f, cv::Mat *m, const char *name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (header[1] == 0 && header[2] == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//! @todo We may have written things other than CV_32F and CV_64F.
|
//! @todo We may have written things other than CV_32F and CV_64F.
|
||||||
if (header[0] == 4) {
|
if (header[0] == 4) {
|
||||||
m->create(static_cast<int>(header[1]),
|
m->create(static_cast<int>(header[1]),
|
||||||
|
|
|
@ -249,6 +249,8 @@ struct t_calibration_raw_data
|
||||||
double l_intrinsics[3][3];
|
double l_intrinsics[3][3];
|
||||||
//! Left camera distortion
|
//! Left camera distortion
|
||||||
double l_distortion[5];
|
double l_distortion[5];
|
||||||
|
//! Left fisheye camera distortion
|
||||||
|
double l_distortion_fisheye[4];
|
||||||
//! Left rectification transform (rotation matrix).
|
//! Left rectification transform (rotation matrix).
|
||||||
double l_rotation[3][3];
|
double l_rotation[3][3];
|
||||||
//! Left projection matrix in the new (rectified) coordinate systems.
|
//! Left projection matrix in the new (rectified) coordinate systems.
|
||||||
|
@ -258,17 +260,12 @@ struct t_calibration_raw_data
|
||||||
double r_intrinsics[3][3];
|
double r_intrinsics[3][3];
|
||||||
//! Right camera distortion
|
//! Right camera distortion
|
||||||
double r_distortion[5];
|
double r_distortion[5];
|
||||||
|
//! Right fisheye camera distortion
|
||||||
|
double r_distortion_fisheye[4];
|
||||||
//! Right rectification transform (rotation matrix).
|
//! Right rectification transform (rotation matrix).
|
||||||
double r_rotation[3][3];
|
double r_rotation[3][3];
|
||||||
//! Right projection matrix in the new (rectified) coordinate systems.
|
//! Right projection matrix in the new (rectified) coordinate systems.
|
||||||
double r_projection[3][4];
|
double r_projection[3][4];
|
||||||
|
|
||||||
#if 0
|
|
||||||
double r_translation[3]; // [0 x 0] [1 x 3]??
|
|
||||||
double r_distortion_fisheye[4]; // [0 x 0] [4 x 1]??
|
|
||||||
double l_translation[3]; // [0 x 0] [1 x 3]??
|
|
||||||
double l_distortion_fisheye[4]; // [0 x 0] [4 x 1]??
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
Loading…
Reference in a new issue