diff --git a/Demo.cpp b/Demo.cpp index f3a80384b8366ac40180a51166051159f5aad401..51c3a8d25d261aaa04ec1a6ac1c6ca51730a6f45 100644 --- a/Demo.cpp +++ b/Demo.cpp @@ -14,9 +14,9 @@ based on original demo.cpp #include <signal.h> -#define PROCESS_CENTER_VERSION_MAJOR 0 -#define PROCESS_CENTER_VERSION_MINOR 9 -#define PROCESS_CENTER_VERSION_MINOR_FIXES 9 +#define PROCESS_CENTER_VERSION_MAJOR 1 +#define PROCESS_CENTER_VERSION_MINOR 0 +#define PROCESS_CENTER_VERSION_MINOR_FIXES 1 //opencv #include <opencv2/opencv.hpp> @@ -65,12 +65,12 @@ int main(int argc, char * argv[]) //!** parse programm input****************/ 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; } - 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; } @@ -107,7 +107,16 @@ int main(int argc, char * argv[]) 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***********/ //./program -i pathToInputDir -a amountOfJpgFiles -o outPutPath @@ -228,6 +237,25 @@ int main(int argc, char * argv[]) cout <<"circleRadius: "<< circleRadius<<endl; 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********** // //std::string fileName = getFileName(begin); // std::string staticFile = inputDir+"/bk.jpg"; @@ -348,6 +376,11 @@ int main(int argc, char * argv[]) 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, //! step 1) img_input = TToolBox::cropImageCircle(img_input,circleCenterX,circleCenterY,circleRadius);