Skip to content
Snippets Groups Projects
Commit f0a23847 authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

Intrinsic parameter scaling

parent 699b3da9
Branches
Tags
No related merge requests found
Pipeline #12582 passed
......@@ -103,7 +103,8 @@ bool Calibrate::_loadCalibration(cv::Size img_size, std::pair<Mat, Mat> &map1, s
}
LOG(INFO) << "Extrinsics from: " << *efile;
} else {
}
else {
LOG(WARNING) << "Calibration extrinsics file not found";
return false;
}
......@@ -115,9 +116,26 @@ bool Calibrate::_loadCalibration(cv::Size img_size, std::pair<Mat, Mat> &map1, s
fs["P1"] >> P1_;
fs["P2"] >> P2_;
fs["Q"] >> Q_;
img_size_ = img_size;
// TODO: normalize calibration
double scale_x = 1.0 / 1280.0;
double scale_y = 1.0 / 720.0;
Mat scale(cv::Size(3, 3), CV_64F, 0.0);
scale.at<double>(0, 0) = (double) img_size.width * scale_x;
scale.at<double>(1, 1) = (double) img_size.height * scale_y;
scale.at<double>(2, 2) = 1.0;
M1_ = scale * M1_;
M2_ = scale * M2_;
P1_ = scale * P1_;
P2_ = scale * P2_;
Q_.at<double>(0, 3) = Q_.at<double>(3, 2) * (double) img_size.width * scale_x;
Q_.at<double>(1, 3) = Q_.at<double>(3, 2) * (double) img_size.height * scale_y;
Q_.at<double>(3, 3) = Q_.at<double>(3, 3) * (double) img_size.width * scale_x;
// cv::cuda::remap() works only with CV_32FC1
initUndistortRectifyMap(M1_, D1_, R1_, P1_, img_size_, CV_32FC1, map1.first, map2.first);
initUndistortRectifyMap(M2_, D2_, R2_, P2_, img_size_, CV_32FC1, map1.second, map2.second);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment