Merge pull request #6459 from eliao:Fix6457

This commit is contained in:
Vadim Pisarevsky 2016-04-25 13:07:51 +00:00
commit 5ed4e1b887

View File

@ -50,13 +50,13 @@ static int print_help()
" matrix separately) stereo. \n" " matrix separately) stereo. \n"
" Calibrate the cameras and display the\n" " Calibrate the cameras and display the\n"
" rectified results along with the computed disparity images. \n" << endl; " rectified results along with the computed disparity images. \n" << endl;
cout << "Usage:\n ./stereo_calib -w=<board_width default=9> -h=<board_height default=6> <image list XML/YML file default=../data/stereo_calib.xml>\n" << endl; cout << "Usage:\n ./stereo_calib -w=<board_width default=9> -h=<board_height default=6> -s=<square_size default=1.0> <image list XML/YML file default=../data/stereo_calib.xml>\n" << endl;
return 0; return 0;
} }
static void static void
StereoCalib(const vector<string>& imagelist, Size boardSize,bool displayCorners = false, bool useCalibrated=true, bool showRectified=true) StereoCalib(const vector<string>& imagelist, Size boardSize, float squareSize, bool displayCorners = false, bool useCalibrated=true, bool showRectified=true)
{ {
if( imagelist.size() % 2 != 0 ) if( imagelist.size() % 2 != 0 )
{ {
@ -65,7 +65,6 @@ StereoCalib(const vector<string>& imagelist, Size boardSize,bool displayCorners
} }
const int maxScale = 2; const int maxScale = 2;
const float squareSize = 1.f; // Set this to your actual square size
// ARRAY AND VECTOR STORAGE: // ARRAY AND VECTOR STORAGE:
vector<vector<Point2f> > imagePoints[2]; vector<vector<Point2f> > imagePoints[2];
@ -348,13 +347,14 @@ int main(int argc, char** argv)
Size boardSize; Size boardSize;
string imagelistfn; string imagelistfn;
bool showRectified; bool showRectified;
cv::CommandLineParser parser(argc, argv, "{w|9|}{h|6|}{nr||}{help||}{@input|../data/stereo_calib.xml|}"); cv::CommandLineParser parser(argc, argv, "{w|9|}{h|6|}{s|1.0|}{nr||}{help||}{@input|../data/stereo_calib.xml|}");
if (parser.has("help")) if (parser.has("help"))
return print_help(); return print_help();
showRectified = !parser.has("nr"); showRectified = !parser.has("nr");
imagelistfn = parser.get<string>("@input"); imagelistfn = parser.get<string>("@input");
boardSize.width = parser.get<int>("w"); boardSize.width = parser.get<int>("w");
boardSize.height = parser.get<int>("h"); boardSize.height = parser.get<int>("h");
float squareSize = parser.get<float>("s");
if (!parser.check()) if (!parser.check())
{ {
parser.printErrors(); parser.printErrors();
@ -368,6 +368,6 @@ int main(int argc, char** argv)
return print_help(); return print_help();
} }
StereoCalib(imagelist, boardSize,false, true, showRectified); StereoCalib(imagelist, boardSize, squareSize, false, true, showRectified);
return 0; return 0;
} }