Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing bug incorrect distortion coeff in fisheye #69

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions McCalib/src/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,16 @@ void Camera::setCameraMat(const cv::Mat camera_matrix) {
*/
void Camera::setDistortionVector(const cv::Mat distortion_vector) {
if (distortion_model_ == 0) {
intrinsics_[4] = distortion_vector.at<double>(0);
intrinsics_[5] = distortion_vector.at<double>(1);
intrinsics_[8] = distortion_vector.at<double>(4); // radial
intrinsics_[6] = distortion_vector.at<double>(2);
intrinsics_[7] = distortion_vector.at<double>(3); // tangential
for (std::size_t intrinIdx = 4u; intrinIdx <= 8u; ++intrinIdx) {
std::size_t distIdx = intrinIdx - 4u;
intrinsics_[intrinIdx] = distortion_vector.at<double>(distIdx);
}
}
if (distortion_model_ == 1) {
intrinsics_[4] = distortion_vector.at<double>(0);
intrinsics_[5] = distortion_vector.at<double>(1);
intrinsics_[8] = distortion_vector.at<double>(2);
intrinsics_[6] = distortion_vector.at<double>(3);
for (std::size_t intrinIdx = 4u; intrinIdx <= 7u; ++intrinIdx) {
std::size_t distIdx = intrinIdx - 4u;
intrinsics_[intrinIdx] = distortion_vector.at<double>(distIdx);
}
}
}

Expand All @@ -74,20 +73,19 @@ void Camera::setDistortionVector(const cv::Mat distortion_vector) {
cv::Mat Camera::getDistortionVectorVector() const {
if (distortion_model_ == 0) {
cv::Mat distortion_vector = cv::Mat(1, 5, CV_64F, cv::Scalar(0));
distortion_vector.at<double>(0) = intrinsics_[4];
distortion_vector.at<double>(1) = intrinsics_[5];
distortion_vector.at<double>(4) = intrinsics_[8];
distortion_vector.at<double>(2) = intrinsics_[6];
distortion_vector.at<double>(3) = intrinsics_[7];
for (std::size_t intrinIdx = 4u; intrinIdx <= 8u; ++intrinIdx) {
std::size_t distIdx = intrinIdx - 4u;
distortion_vector.at<double>(distIdx) = intrinsics_[intrinIdx];
}
return distortion_vector;
}

else if (distortion_model_ == 1) {
cv::Mat distortion_vector = cv::Mat(1, 4, CV_64F, cv::Scalar(0));
distortion_vector.at<double>(0) = intrinsics_[4];
distortion_vector.at<double>(1) = intrinsics_[5];
distortion_vector.at<double>(4) = intrinsics_[8];
distortion_vector.at<double>(2) = intrinsics_[6];
for (std::size_t intrinIdx = 4u; intrinIdx <= 7u; ++intrinIdx) {
std::size_t distIdx = intrinIdx - 4u;
distortion_vector.at<double>(distIdx) = intrinsics_[intrinIdx];
}
return distortion_vector;
}

Expand Down
Loading