calib3d: fix InputArray -> CvMat

pull/7915/head
Alexander Alekhin 8 years ago
parent be7d060ea4
commit ca6beb9ca8
  1. 2
      modules/calib3d/src/calibinit.cpp
  2. 132
      modules/calib3d/src/calibration.cpp
  3. 3
      modules/calib3d/test/test_cameracalibration.cpp

@ -2085,7 +2085,7 @@ void cv::drawChessboardCorners( InputOutputArray _image, Size patternSize,
Mat corners = _corners.getMat(); Mat corners = _corners.getMat();
if( corners.empty() ) if( corners.empty() )
return; return;
Mat image = _image.getMat(); CvMat c_image = _image.getMat(); Mat image = _image.getMat(); CvMat c_image = image;
int nelems = corners.checkVector(2, CV_32F, true); int nelems = corners.checkVector(2, CV_32F, true);
CV_Assert(nelems >= 0); CV_Assert(nelems >= 0);
cvDrawChessboardCorners( &c_image, patternSize, corners.ptr<CvPoint2D32f>(), cvDrawChessboardCorners( &c_image, patternSize, corners.ptr<CvPoint2D32f>(),

@ -3234,54 +3234,20 @@ void cv::composeRT( InputArray _rvec1, InputArray _tvec1,
c_tvec2 = tvec2, c_rvec3 = rvec3, c_tvec3 = tvec3; c_tvec2 = tvec2, c_rvec3 = rvec3, c_tvec3 = tvec3;
CvMat c_dr3dr1, c_dr3dt1, c_dr3dr2, c_dr3dt2, c_dt3dr1, c_dt3dt1, c_dt3dr2, c_dt3dt2; CvMat c_dr3dr1, c_dr3dt1, c_dr3dr2, c_dr3dt2, c_dt3dr1, c_dt3dt1, c_dt3dr2, c_dt3dt2;
CvMat *p_dr3dr1=0, *p_dr3dt1=0, *p_dr3dr2=0, *p_dr3dt2=0, *p_dt3dr1=0, *p_dt3dt1=0, *p_dt3dr2=0, *p_dt3dt2=0; CvMat *p_dr3dr1=0, *p_dr3dt1=0, *p_dr3dr2=0, *p_dr3dt2=0, *p_dt3dr1=0, *p_dt3dt1=0, *p_dt3dr2=0, *p_dt3dt2=0;
#define CV_COMPOSE_RT_PARAM(name) \
if( _dr3dr1.needed() ) Mat name; \
{ if (_ ## name.needed())\
_dr3dr1.create(3, 3, rtype); { \
p_dr3dr1 = &(c_dr3dr1 = _dr3dr1.getMat()); _ ## name.create(3, 3, rtype); \
} name = _ ## name.getMat(); \
p_ ## name = &(c_ ## name = name); \
if( _dr3dt1.needed() )
{
_dr3dt1.create(3, 3, rtype);
p_dr3dt1 = &(c_dr3dt1 = _dr3dt1.getMat());
}
if( _dr3dr2.needed() )
{
_dr3dr2.create(3, 3, rtype);
p_dr3dr2 = &(c_dr3dr2 = _dr3dr2.getMat());
}
if( _dr3dt2.needed() )
{
_dr3dt2.create(3, 3, rtype);
p_dr3dt2 = &(c_dr3dt2 = _dr3dt2.getMat());
}
if( _dt3dr1.needed() )
{
_dt3dr1.create(3, 3, rtype);
p_dt3dr1 = &(c_dt3dr1 = _dt3dr1.getMat());
}
if( _dt3dt1.needed() )
{
_dt3dt1.create(3, 3, rtype);
p_dt3dt1 = &(c_dt3dt1 = _dt3dt1.getMat());
}
if( _dt3dr2.needed() )
{
_dt3dr2.create(3, 3, rtype);
p_dt3dr2 = &(c_dt3dr2 = _dt3dr2.getMat());
} }
if( _dt3dt2.needed() ) CV_COMPOSE_RT_PARAM(dr3dr1); CV_COMPOSE_RT_PARAM(dr3dt1);
{ CV_COMPOSE_RT_PARAM(dr3dr2); CV_COMPOSE_RT_PARAM(dr3dt2);
_dt3dt2.create(3, 3, rtype); CV_COMPOSE_RT_PARAM(dt3dr1); CV_COMPOSE_RT_PARAM(dt3dt1);
p_dt3dt2 = &(c_dt3dt2 = _dt3dt2.getMat()); CV_COMPOSE_RT_PARAM(dt3dr2); CV_COMPOSE_RT_PARAM(dt3dt2);
} #undef CV_COMPOSE_RT_PARAM
cvComposeRT(&c_rvec1, &c_tvec1, &c_rvec2, &c_tvec2, &c_rvec3, &c_tvec3, cvComposeRT(&c_rvec1, &c_tvec1, &c_rvec2, &c_tvec2, &c_rvec3, &c_tvec3,
p_dr3dr1, p_dr3dt1, p_dr3dr2, p_dr3dt2, p_dr3dr1, p_dr3dt1, p_dr3dr2, p_dr3dt2,
@ -3306,7 +3272,8 @@ void cv::projectPoints( InputArray _opoints,
CvMat *pdpdrot=0, *pdpdt=0, *pdpdf=0, *pdpdc=0, *pdpddist=0; CvMat *pdpdrot=0, *pdpdt=0, *pdpdf=0, *pdpdc=0, *pdpddist=0;
_ipoints.create(npoints, 1, CV_MAKETYPE(depth, 2), -1, true); _ipoints.create(npoints, 1, CV_MAKETYPE(depth, 2), -1, true);
CvMat c_imagePoints = _ipoints.getMat(); Mat imagePoints = _ipoints.getMat();
CvMat c_imagePoints(imagePoints);
CvMat c_objectPoints = opoints; CvMat c_objectPoints = opoints;
Mat cameraMatrix = _cameraMatrix.getMat(); Mat cameraMatrix = _cameraMatrix.getMat();
@ -3674,24 +3641,25 @@ cv::Vec3d cv::RQDecomp3x3( InputArray _Mmat,
Mat M = _Mmat.getMat(); Mat M = _Mmat.getMat();
_Rmat.create(3, 3, M.type()); _Rmat.create(3, 3, M.type());
_Qmat.create(3, 3, M.type()); _Qmat.create(3, 3, M.type());
Mat Rmat = _Rmat.getMat();
Mat Qmat = _Qmat.getMat();
Vec3d eulerAngles; Vec3d eulerAngles;
CvMat matM = M, matR = _Rmat.getMat(), matQ = _Qmat.getMat(), Qx, Qy, Qz, *pQx=0, *pQy=0, *pQz=0; CvMat matM = M, matR = Rmat, matQ = Qmat;
if( _Qx.needed() ) #define CV_RQDecomp3x3_PARAM(name) \
{ Mat name; \
_Qx.create(3, 3, M.type()); CvMat c_ ## name, *p ## name = NULL; \
pQx = &(Qx = _Qx.getMat()); if( _ ## name.needed() ) \
} { \
if( _Qy.needed() ) _ ## name.create(3, 3, M.type()); \
{ name = _ ## name.getMat(); \
_Qy.create(3, 3, M.type()); c_ ## name = name; p ## name = &c_ ## name; \
pQy = &(Qy = _Qy.getMat()); }
}
if( _Qz.needed() ) CV_RQDecomp3x3_PARAM(Qx);
{ CV_RQDecomp3x3_PARAM(Qy);
_Qz.create(3, 3, M.type()); CV_RQDecomp3x3_PARAM(Qz);
pQz = &(Qz = _Qz.getMat()); #undef CV_RQDecomp3x3_PARAM
}
cvRQDecomp3x3(&matM, &matR, &matQ, pQx, pQy, pQz, (CvPoint3D64f*)&eulerAngles[0]); cvRQDecomp3x3(&matM, &matR, &matQ, pQx, pQy, pQz, (CvPoint3D64f*)&eulerAngles[0]);
return eulerAngles; return eulerAngles;
} }
@ -3709,28 +3677,28 @@ void cv::decomposeProjectionMatrix( InputArray _projMatrix, OutputArray _cameraM
_cameraMatrix.create(3, 3, type); _cameraMatrix.create(3, 3, type);
_rotMatrix.create(3, 3, type); _rotMatrix.create(3, 3, type);
_transVect.create(4, 1, type); _transVect.create(4, 1, type);
CvMat c_projMatrix = projMatrix, c_cameraMatrix = _cameraMatrix.getMat(); Mat cameraMatrix = _cameraMatrix.getMat();
CvMat c_rotMatrix = _rotMatrix.getMat(), c_transVect = _transVect.getMat(); Mat rotMatrix = _rotMatrix.getMat();
CvMat c_rotMatrixX, *p_rotMatrixX = 0; Mat transVect = _transVect.getMat();
CvMat c_rotMatrixY, *p_rotMatrixY = 0; CvMat c_projMatrix = projMatrix, c_cameraMatrix = cameraMatrix;
CvMat c_rotMatrixZ, *p_rotMatrixZ = 0; CvMat c_rotMatrix = rotMatrix, c_transVect = transVect;
CvPoint3D64f *p_eulerAngles = 0; CvPoint3D64f *p_eulerAngles = 0;
if( _rotMatrixX.needed() ) #define CV_decomposeProjectionMatrix_PARAM(name) \
{ Mat name; \
_rotMatrixX.create(3, 3, type); CvMat c_ ## name, *p_ ## name = NULL; \
p_rotMatrixX = &(c_rotMatrixX = _rotMatrixX.getMat()); if( _ ## name.needed() ) \
} { \
if( _rotMatrixY.needed() ) _ ## name.create(3, 3, type); \
{ name = _ ## name.getMat(); \
_rotMatrixY.create(3, 3, type); c_ ## name = name; p_ ## name = &c_ ## name; \
p_rotMatrixY = &(c_rotMatrixY = _rotMatrixY.getMat());
}
if( _rotMatrixZ.needed() )
{
_rotMatrixZ.create(3, 3, type);
p_rotMatrixZ = &(c_rotMatrixZ = _rotMatrixZ.getMat());
} }
CV_decomposeProjectionMatrix_PARAM(rotMatrixX);
CV_decomposeProjectionMatrix_PARAM(rotMatrixY);
CV_decomposeProjectionMatrix_PARAM(rotMatrixZ);
#undef CV_decomposeProjectionMatrix_PARAM
if( _eulerAngles.needed() ) if( _eulerAngles.needed() )
{ {
_eulerAngles.create(3, 1, CV_64F, -1, true); _eulerAngles.create(3, 1, CV_64F, -1, true);

@ -1306,7 +1306,8 @@ void CV_ProjectPointsTest_C::project( const Mat& opoints, const Mat& rvec, const
dpdf.create(npoints*2, 2, CV_64F); dpdf.create(npoints*2, 2, CV_64F);
dpdc.create(npoints*2, 2, CV_64F); dpdc.create(npoints*2, 2, CV_64F);
dpddist.create(npoints*2, distCoeffs.rows + distCoeffs.cols - 1, CV_64F); dpddist.create(npoints*2, distCoeffs.rows + distCoeffs.cols - 1, CV_64F);
CvMat _objectPoints = opoints, _imagePoints = Mat(ipoints); Mat imagePoints(ipoints);
CvMat _objectPoints = opoints, _imagePoints = imagePoints;
CvMat _rvec = rvec, _tvec = tvec, _cameraMatrix = cameraMatrix, _distCoeffs = distCoeffs; CvMat _rvec = rvec, _tvec = tvec, _cameraMatrix = cameraMatrix, _distCoeffs = distCoeffs;
CvMat _dpdrot = dpdrot, _dpdt = dpdt, _dpdf = dpdf, _dpdc = dpdc, _dpddist = dpddist; CvMat _dpdrot = dpdrot, _dpdt = dpdt, _dpdf = dpdf, _dpdc = dpdc, _dpddist = dpddist;

Loading…
Cancel
Save