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

Distortion parameters for OpenCV Calibration aren't read. #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 9 additions & 4 deletions lsd_slam_core/src/util/Undistorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,19 +482,24 @@ UndistorterOpenCV::UndistorterOpenCV(const char* configFileName)
// l3
if(l3 == "crop")
{
outputCalibration = -1;
outputCalibration[0] = -1;
printf("Out: Crop\n");
}
else if(l3 == "full")
{
outputCalibration = -2;
outputCalibration[0] = -2;
printf("Out: Full\n");
}
else if(l3 == "none")
{
printf("NO RECTIFICATION\n");
valid = false;
}
else if(std::sscanf(l3.c_str(), "%f %f %f %f %f", &outputCalibration[0], &outputCalibration[1], &outputCalibration[2], &outputCalibration[3], &outputCalibration[4]) == 5)
{
printf("Out: %f %f %f %f %f\n",
outputCalibration[0], outputCalibration[1], outputCalibration[2], outputCalibration[3], outputCalibration[4]);
}
else
{
printf("Out: Failed to Read Output pars... not rectifying.\n");
Expand All @@ -514,7 +519,7 @@ UndistorterOpenCV::UndistorterOpenCV(const char* configFileName)

cv::Mat distCoeffs = cv::Mat::zeros(4, 1, CV_32F);
for (int i = 0; i < 4; ++ i)
distCoeffs.at<float>(i, 0) = inputCalibration[4 + i];
distCoeffs.at<float>(i, 0) = outputCalibration[i];

if(inputCalibration[2] < 1.0f)
{
Expand Down Expand Up @@ -542,7 +547,7 @@ UndistorterOpenCV::UndistorterOpenCV(const char* configFileName)

if (valid)
{
K_ = cv::getOptimalNewCameraMatrix(originalK_, distCoeffs, cv::Size(in_width, in_height), (outputCalibration == -2) ? 1 : 0, cv::Size(out_width, out_height), nullptr, false);
K_ = cv::getOptimalNewCameraMatrix(originalK_, distCoeffs, cv::Size(in_width, in_height), (outputCalibration[0] == -2) ? 1 : 0, cv::Size(out_width, out_height), nullptr, false);

cv::initUndistortRectifyMap(originalK_, distCoeffs, cv::Mat(), K_,
cv::Size(out_width, out_height), CV_16SC2, map1, map2);
Expand Down
2 changes: 1 addition & 1 deletion lsd_slam_core/src/util/Undistorter.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class UndistorterOpenCV : public Undistorter
cv::Mat originalK_;

float inputCalibration[10];
float outputCalibration;
float outputCalibration[5];
int out_width, out_height;
int in_width, in_height;
cv::Mat map1, map2;
Expand Down