mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 13:47:32 +08:00
Added checking whether aspect ratio is valid or not
This commit is contained in:
parent
4c58fff3f7
commit
3517be757b
@ -1548,6 +1548,8 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints,
|
||||
flags |= CV_CALIB_FIX_K3;
|
||||
flags |= CV_CALIB_FIX_K4 | CV_CALIB_FIX_K5 | CV_CALIB_FIX_K6;
|
||||
}
|
||||
const double minValidAspectRatio = 0.01;
|
||||
const double maxValidAspectRatio = 100.0;
|
||||
|
||||
// 1. initialize intrinsic parameters & LM solver
|
||||
if( flags & CV_CALIB_USE_INTRINSIC_GUESS )
|
||||
@ -1568,7 +1570,13 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints,
|
||||
A[8] = 1.;
|
||||
|
||||
if( flags & CV_CALIB_FIX_ASPECT_RATIO )
|
||||
{
|
||||
aspectRatio = A[0]/A[4];
|
||||
|
||||
if( aspectRatio < minValidAspectRatio || aspectRatio > maxValidAspectRatio )
|
||||
CV_Error( CV_StsOutOfRange,
|
||||
"The specified aspect ratio (= cameraMatrix[0][0] / cameraMatrix[1][1]) is incorrect" );
|
||||
}
|
||||
cvConvert( distCoeffs, &_k );
|
||||
}
|
||||
else
|
||||
@ -1585,9 +1593,9 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints,
|
||||
{
|
||||
aspectRatio = cvmGet(cameraMatrix,0,0);
|
||||
aspectRatio /= cvmGet(cameraMatrix,1,1);
|
||||
if( aspectRatio < 0.01 || aspectRatio > 100 )
|
||||
if( aspectRatio < minValidAspectRatio || aspectRatio > maxValidAspectRatio )
|
||||
CV_Error( CV_StsOutOfRange,
|
||||
"The specified aspect ratio (=A[0][0]/A[1][1]) is incorrect" );
|
||||
"The specified aspect ratio (= cameraMatrix[0][0] / cameraMatrix[1][1]) is incorrect" );
|
||||
}
|
||||
cvInitIntrinsicParams2D( matM, _m, npoints, imageSize, &matA, aspectRatio );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user