Commit eea43c6a authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

added CV_CALIB_RATIONAL_MODEL for better backward compatibility

parent a937d9d4
This diff is collapsed.
......@@ -223,6 +223,7 @@ CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
#define CV_CALIB_FIX_K4 2048
#define CV_CALIB_FIX_K5 4096
#define CV_CALIB_FIX_K6 8192
#define CV_CALIB_RATIONAL_MODEL 16384
/* Finds intrinsic and extrinsic camera parameters
from a few views of known calibration pattern */
......@@ -542,17 +543,18 @@ enum
CALIB_FIX_PRINCIPAL_POINT = 4,
CALIB_ZERO_TANGENT_DIST = 8,
CALIB_FIX_FOCAL_LENGTH = 16,
CALIB_FIX_K1 = 32,
CALIB_FIX_K2 = 64,
CALIB_FIX_K3 = 128,
CALIB_FIX_K4 = 2048,
CALIB_FIX_K5 = 4096,
CALIB_FIX_K6 = 8192,
CALIB_FIX_K1 = CV_CALIB_FIX_K1,
CALIB_FIX_K2 = CV_CALIB_FIX_K2,
CALIB_FIX_K3 = CV_CALIB_FIX_K3,
CALIB_FIX_K4 = CV_CALIB_FIX_K4,
CALIB_FIX_K5 = CV_CALIB_FIX_K5,
CALIB_FIX_K6 = CV_CALIB_FIX_K6,
CALIB_RATIONAL_MODEL = CV_CALIB_RATIONAL_MODEL,
// only for stereo
CALIB_FIX_INTRINSIC = 256,
CALIB_SAME_FOCAL_LENGTH = 512,
CALIB_FIX_INTRINSIC = CV_CALIB_FIX_INTRINSIC,
CALIB_SAME_FOCAL_LENGTH = CV_CALIB_SAME_FOCAL_LENGTH,
// for stereo rectification
CALIB_ZERO_DISPARITY = 1024
CALIB_ZERO_DISPARITY = CV_CALIB_ZERO_DISPARITY
};
//! finds intrinsic and extrinsic camera parameters from several fews of a known calibration pattern.
......
......@@ -1596,6 +1596,8 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints,
param[6] = param[7] = 0;
mask[6] = mask[7] = 0;
}
if( !(flags & CV_CALIB_RATIONAL_MODEL) )
flags |= CV_CALIB_FIX_K4 + CV_CALIB_FIX_K5 + CV_CALIB_FIX_K6;
if( flags & CV_CALIB_FIX_K1 )
mask[4] = 0;
if( flags & CV_CALIB_FIX_K2 )
......@@ -1928,6 +1930,8 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1
if( recomputeIntrinsics )
{
uchar* imask = solver.mask->data.ptr + nparams - NINTRINSIC*2;
if( !(flags & CV_CALIB_RATIONAL_MODEL) )
flags |= CV_CALIB_FIX_K4 | CV_CALIB_FIX_K5 | CV_CALIB_FIX_K6;
if( flags & CV_CALIB_FIX_ASPECT_RATIO )
imask[0] = imask[NINTRINSIC] = 0;
if( flags & CV_CALIB_FIX_FOCAL_LENGTH )
......@@ -3293,6 +3297,8 @@ double cv::calibrateCamera( const vector<vector<Point3f> >& objectPoints,
int rtype = CV_64F;
cameraMatrix = prepareCameraMatrix(cameraMatrix, rtype);
distCoeffs = prepareDistCoeffs(distCoeffs, rtype);
if( !(flags & CALIB_RATIONAL_MODEL) )
distCoeffs = distCoeffs.rows == 1 ? distCoeffs.colRange(0, 5) : distCoeffs.rowRange(0, 5);
size_t i, nimages = objectPoints.size();
CV_Assert( nimages > 0 );
......@@ -3341,6 +3347,13 @@ double cv::stereoCalibrate( const vector<vector<Point3f> >& objectPoints,
cameraMatrix2 = prepareCameraMatrix(cameraMatrix2, rtype);
distCoeffs1 = prepareDistCoeffs(distCoeffs1, rtype);
distCoeffs2 = prepareDistCoeffs(distCoeffs2, rtype);
if( !(flags & CALIB_RATIONAL_MODEL) )
{
distCoeffs1 = distCoeffs1.rows == 1 ? distCoeffs1.colRange(0, 5) : distCoeffs1.rowRange(0, 5);
distCoeffs2 = distCoeffs2.rows == 1 ? distCoeffs2.colRange(0, 5) : distCoeffs2.rowRange(0, 5);
}
R.create(3, 3, rtype);
T.create(3, 1, rtype);
E.create(3, 3, rtype);
......
......@@ -160,8 +160,6 @@ StereoCalib(const vector<string>& imagelist, Size boardSize, bool useCalibrated=
Mat cameraMatrix[2], distCoeffs[2];
cameraMatrix[0] = Mat::eye(3, 3, CV_64F);
cameraMatrix[1] = Mat::eye(3, 3, CV_64F);
distCoeffs[0] = Mat::zeros(8, 1, CV_64F);
distCoeffs[1] = Mat::zeros(8, 1, CV_64F);
Mat R, T, E, F;
stereoCalibrate(objectPoints, imagePoints[0], imagePoints[1],
......@@ -171,8 +169,7 @@ StereoCalib(const vector<string>& imagelist, Size boardSize, bool useCalibrated=
TermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, 1e-5),
CV_CALIB_FIX_ASPECT_RATIO +
CV_CALIB_ZERO_TANGENT_DIST +
CV_CALIB_SAME_FOCAL_LENGTH +
CV_CALIB_FIX_K3 + CV_CALIB_FIX_K4 + CV_CALIB_FIX_K5);
CV_CALIB_SAME_FOCAL_LENGTH);
cout << "done\n";
// CALIBRATION QUALITY CHECK
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment