Skip to content
Snippets Groups Projects
Commit 163f4e6a authored by Thomas Boy's avatar Thomas Boy
Browse files

added the lense distortion

parent 0083d760
No related branches found
No related tags found
No related merge requests found
...@@ -14,9 +14,9 @@ based on original demo.cpp ...@@ -14,9 +14,9 @@ based on original demo.cpp
#include <signal.h> #include <signal.h>
#define PROCESS_CENTER_VERSION_MAJOR 0 #define PROCESS_CENTER_VERSION_MAJOR 1
#define PROCESS_CENTER_VERSION_MINOR 9 #define PROCESS_CENTER_VERSION_MINOR 0
#define PROCESS_CENTER_VERSION_MINOR_FIXES 9 #define PROCESS_CENTER_VERSION_MINOR_FIXES 1
//opencv //opencv
#include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
...@@ -65,12 +65,12 @@ int main(int argc, char * argv[]) ...@@ -65,12 +65,12 @@ int main(int argc, char * argv[])
//!** parse programm input****************/ //!** parse programm input****************/
if(cmdOptionExists(argv, argv+argc, "-h")) if(cmdOptionExists(argv, argv+argc, "-h"))
{ {
cout <<" error: please use command as\n./bgs_demo -i pathToInputDir -a amountOfJpgFiles -c exactCenterConfFile.xml -o outPutPath"<<endl; cout <<" error: please use command as\n./bgs_demo -i pathToInputDir -a amountOfJpgFiles -c exactCenterConfFile.xml -o outPutPath -p camparameterFile.xml"<<endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if(!cmdOptionExists(argv, argv+argc, "-i")||!cmdOptionExists(argv, argv+argc, "-a")||!cmdOptionExists(argv, argv+argc, "-o") ) if(!cmdOptionExists(argv, argv+argc, "-i")||!cmdOptionExists(argv, argv+argc, "-a")||!cmdOptionExists(argv, argv+argc, "-o") ||!cmdOptionExists(argv, argv+argc, "-p"))
{ {
cout <<" error: please use command as\n./bgs_demo -i pathToInputDir -a amountOfJpgFiles -c exactCenterConfFile.xml -o outPutPath"<<endl; cout <<" error: please use command as\n./bgs_demo -i pathToInputDir -a amountOfJpgFiles -c exactCenterConfFile.xml -o outPutPath -p camparameterFile.xml"<<endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
...@@ -107,7 +107,16 @@ int main(int argc, char * argv[]) ...@@ -107,7 +107,16 @@ int main(int argc, char * argv[])
outputDir = string(testOutputDir); outputDir = string(testOutputDir);
} }
cout <<"args: -i "<<inputDir<<" -a "<<amountFiles << " -c" << centerFileString<<" -o " << outputDir; char *camerFile = getCmdOption(argv, argv + argc, "-p");
std::string cameraParameterFile(".");
if (camerFile)
{
//test dir exists
cameraParameterFile = string(camerFile);
}
cout <<"args: -i "<<inputDir<<" -a "<<amountFiles << " -c" << centerFileString<<" -o " << outputDir <<" -p " << cameraParameterFile ;
//!**** end parse input***********/ //!**** end parse input***********/
//./program -i pathToInputDir -a amountOfJpgFiles -o outPutPath //./program -i pathToInputDir -a amountOfJpgFiles -o outPutPath
...@@ -228,6 +237,25 @@ int main(int argc, char * argv[]) ...@@ -228,6 +237,25 @@ int main(int argc, char * argv[])
cout <<"circleRadius: "<< circleRadius<<endl; cout <<"circleRadius: "<< circleRadius<<endl;
fsCen.release(); fsCen.release();
//we open the camera config file
cv::String camParam (cameraParameterFile);
Mat intrinsicsCameraMatrix, distortionCoeff;
{
cout << "read cam parameter of: "<< cameraParameterFile ;
FileStorage fs;
fs.open(camParam, FileStorage::READ);
if (!fs.isOpened())
{
cerr << "error during open " << cameraParameterFile << " will abort\n ";
return -1;
}
fs["camera_matrix"] >> intrinsicsCameraMatrix;
std::cout << "camera_matrix = "<< intrinsicsCameraMatrix<<endl;
fs["distortion_coefficients"] >> distortionCoeff;
std::cout << "distortion_coefficients"<< distortionCoeff<<endl;
}
// //first the static pic********** // //first the static pic**********
// //std::string fileName = getFileName(begin); // //std::string fileName = getFileName(begin);
// std::string staticFile = inputDir+"/bk.jpg"; // std::string staticFile = inputDir+"/bk.jpg";
...@@ -348,6 +376,11 @@ int main(int argc, char * argv[]) ...@@ -348,6 +376,11 @@ int main(int argc, char * argv[])
if(img_input.data ) if(img_input.data )
{ {
//! step 0 we take care about the lense distortion
//! correct lense distortion
//Mat imgLenseCorrection = img_input.clone();
cv::undistort(img_input, img_input, intrinsicsCameraMatrix, distortionCoeff);
//! we cut out a smaller ROI, //! we cut out a smaller ROI,
//! step 1) //! step 1)
img_input = TToolBox::cropImageCircle(img_input,circleCenterX,circleCenterY,circleRadius); img_input = TToolBox::cropImageCircle(img_input,circleCenterX,circleCenterY,circleRadius);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment