added flag to treat input file as a videofile (patch by Ethan Rublee; ticket #392)
This commit is contained in:
parent
bad4ca2a51
commit
2b660bf554
@ -60,6 +60,8 @@ void help()
|
|||||||
" [-a <aspectRatio>] # fix aspect ratio (fx/fy)\n"
|
" [-a <aspectRatio>] # fix aspect ratio (fx/fy)\n"
|
||||||
" [-p] # fix the principal point at the center\n"
|
" [-p] # fix the principal point at the center\n"
|
||||||
" [-v] # flip the captured images around the horizontal axis\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"
|
" [-su] # show undistorted images after calibration\n"
|
||||||
" [input_data] # input data, one of the following:\n"
|
" [input_data] # input data, one of the following:\n"
|
||||||
" # - text file with a list of the images of the board\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]);
|
objectPoints.resize(imagePoints.size(),objectPoints[0]);
|
||||||
|
|
||||||
calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix,
|
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);
|
bool ok = checkRange(cameraMatrix) && checkRange(distCoeffs);
|
||||||
|
|
||||||
@ -277,6 +280,7 @@ int main( int argc, char** argv )
|
|||||||
VideoCapture capture;
|
VideoCapture capture;
|
||||||
bool flipVertical = false;
|
bool flipVertical = false;
|
||||||
bool showUndistorted = false;
|
bool showUndistorted = false;
|
||||||
|
bool videofile = false;
|
||||||
int delay = 1000;
|
int delay = 1000;
|
||||||
clock_t prevTimestamp = 0;
|
clock_t prevTimestamp = 0;
|
||||||
int mode = DETECTION;
|
int mode = DETECTION;
|
||||||
@ -284,7 +288,6 @@ int main( int argc, char** argv )
|
|||||||
vector<vector<Point2f> > imagePoints;
|
vector<vector<Point2f> > imagePoints;
|
||||||
vector<string> imageList;
|
vector<string> imageList;
|
||||||
|
|
||||||
|
|
||||||
if( argc < 2 )
|
if( argc < 2 )
|
||||||
{
|
{
|
||||||
help();
|
help();
|
||||||
@ -327,11 +330,11 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
else if( strcmp( s, "-op" ) == 0 )
|
else if( strcmp( s, "-op" ) == 0 )
|
||||||
{
|
{
|
||||||
writePoints = 1;
|
writePoints = true;
|
||||||
}
|
}
|
||||||
else if( strcmp( s, "-oe" ) == 0 )
|
else if( strcmp( s, "-oe" ) == 0 )
|
||||||
{
|
{
|
||||||
writeExtrinsics = 1;
|
writeExtrinsics = true;
|
||||||
}
|
}
|
||||||
else if( strcmp( s, "-zt" ) == 0 )
|
else if( strcmp( s, "-zt" ) == 0 )
|
||||||
{
|
{
|
||||||
@ -343,7 +346,11 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
else if( strcmp( s, "-v" ) == 0 )
|
else if( strcmp( s, "-v" ) == 0 )
|
||||||
{
|
{
|
||||||
flipVertical = 1;
|
flipVertical = true;
|
||||||
|
}
|
||||||
|
else if( strcmp( s, "-V" ) == 0 )
|
||||||
|
{
|
||||||
|
videofile = true;
|
||||||
}
|
}
|
||||||
else if( strcmp( s, "-o" ) == 0 )
|
else if( strcmp( s, "-o" ) == 0 )
|
||||||
{
|
{
|
||||||
@ -366,7 +373,7 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
if( inputFilename )
|
if( inputFilename )
|
||||||
{
|
{
|
||||||
if( readStringList(inputFilename, imageList) )
|
if( !videofile && readStringList(inputFilename, imageList) )
|
||||||
mode = CAPTURING;
|
mode = CAPTURING;
|
||||||
else
|
else
|
||||||
capture.open(inputFilename);
|
capture.open(inputFilename);
|
||||||
@ -415,12 +422,10 @@ int main( int argc, char** argv )
|
|||||||
flip( view, view, 0 );
|
flip( view, view, 0 );
|
||||||
|
|
||||||
vector<Point2f> pointbuf;
|
vector<Point2f> pointbuf;
|
||||||
|
|
||||||
|
|
||||||
cvtColor(view, viewGray, CV_BGR2GRAY);
|
cvtColor(view, viewGray, CV_BGR2GRAY);
|
||||||
|
|
||||||
|
bool found = findChessboardCorners( view, boardSize, pointbuf,
|
||||||
bool found = findChessboardCorners( view, boardSize, pointbuf, CV_CALIB_CB_ADAPTIVE_THRESH & CV_CALIB_CB_FAST_CHECK & CV_CALIB_CB_NORMALIZE_IMAGE);
|
CV_CALIB_CB_ADAPTIVE_THRESH & CV_CALIB_CB_FAST_CHECK & CV_CALIB_CB_NORMALIZE_IMAGE);
|
||||||
|
|
||||||
// improve the found corners' coordinate accuracy
|
// improve the found corners' coordinate accuracy
|
||||||
if(found) cornerSubPix( viewGray, pointbuf, Size(11,11),
|
if(found) cornerSubPix( viewGray, pointbuf, Size(11,11),
|
||||||
@ -433,9 +438,9 @@ int main( int argc, char** argv )
|
|||||||
prevTimestamp = clock();
|
prevTimestamp = clock();
|
||||||
blink = capture.isOpened();
|
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" :
|
string msg = mode == CAPTURING ? "100/100" :
|
||||||
mode == CALIBRATED ? "Calibrated" : "Press 'g' to start";
|
mode == CALIBRATED ? "Calibrated" : "Press 'g' to start";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user