提交 2b660bf5 编写于 作者: V Vadim Pisarevsky

added flag to treat input file as a videofile (patch by Ethan Rublee; ticket #392)

上级 bad4ca2a
......@@ -60,6 +60,8 @@ void help()
" [-a <aspectRatio>] # fix aspect ratio (fx/fy)\n"
" [-p] # fix the principal point at the center\n"
" [-v] # flip the captured images around the horizontal axis\n"
" [-V] # use a video file, and not an image list, uses\n"
" # [input_data] string for the video file name\n"
" [-su] # show undistorted images after calibration\n"
" [input_data] # input data, one of the following:\n"
" # - text file with a list of the images of the board\n"
......@@ -129,7 +131,8 @@ static bool runCalibration( vector<vector<Point2f> > imagePoints,
objectPoints.resize(imagePoints.size(),objectPoints[0]);
calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix,
distCoeffs, rvecs, tvecs, flags|CV_CALIB_FIX_K4|CV_CALIB_FIX_K5);///*|CV_CALIB_FIX_K3*/|CV_CALIB_FIX_K4|CV_CALIB_FIX_K5);
distCoeffs, rvecs, tvecs, flags|CV_CALIB_FIX_K4|CV_CALIB_FIX_K5);
///*|CV_CALIB_FIX_K3*/|CV_CALIB_FIX_K4|CV_CALIB_FIX_K5);
bool ok = checkRange(cameraMatrix) && checkRange(distCoeffs);
......@@ -277,6 +280,7 @@ int main( int argc, char** argv )
VideoCapture capture;
bool flipVertical = false;
bool showUndistorted = false;
bool videofile = false;
int delay = 1000;
clock_t prevTimestamp = 0;
int mode = DETECTION;
......@@ -284,7 +288,6 @@ int main( int argc, char** argv )
vector<vector<Point2f> > imagePoints;
vector<string> imageList;
if( argc < 2 )
{
help();
......@@ -327,11 +330,11 @@ int main( int argc, char** argv )
}
else if( strcmp( s, "-op" ) == 0 )
{
writePoints = 1;
writePoints = true;
}
else if( strcmp( s, "-oe" ) == 0 )
{
writeExtrinsics = 1;
writeExtrinsics = true;
}
else if( strcmp( s, "-zt" ) == 0 )
{
......@@ -343,7 +346,11 @@ int main( int argc, char** argv )
}
else if( strcmp( s, "-v" ) == 0 )
{
flipVertical = 1;
flipVertical = true;
}
else if( strcmp( s, "-V" ) == 0 )
{
videofile = true;
}
else if( strcmp( s, "-o" ) == 0 )
{
......@@ -366,7 +373,7 @@ int main( int argc, char** argv )
if( inputFilename )
{
if( readStringList(inputFilename, imageList) )
if( !videofile && readStringList(inputFilename, imageList) )
mode = CAPTURING;
else
capture.open(inputFilename);
......@@ -415,12 +422,10 @@ int main( int argc, char** argv )
flip( view, view, 0 );
vector<Point2f> pointbuf;
cvtColor(view, viewGray, CV_BGR2GRAY);
bool found = findChessboardCorners( view, boardSize, pointbuf, CV_CALIB_CB_ADAPTIVE_THRESH & CV_CALIB_CB_FAST_CHECK & CV_CALIB_CB_NORMALIZE_IMAGE);
bool found = findChessboardCorners( view, boardSize, pointbuf,
CV_CALIB_CB_ADAPTIVE_THRESH & CV_CALIB_CB_FAST_CHECK & CV_CALIB_CB_NORMALIZE_IMAGE);
// improve the found corners' coordinate accuracy
if(found) cornerSubPix( viewGray, pointbuf, Size(11,11),
......@@ -433,9 +438,9 @@ int main( int argc, char** argv )
prevTimestamp = clock();
blink = capture.isOpened();
}
if(found) drawChessboardCorners( view, boardSize, Mat(pointbuf), found );
if(found)
drawChessboardCorners( view, boardSize, Mat(pointbuf), found );
string msg = mode == CAPTURING ? "100/100" :
mode == CALIBRATED ? "Calibrated" : "Press 'g' to start";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册