1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

mostly removed obsolete C API from calib3d (at least at the interface level) (#13081)

This commit is contained in:
Vadim Pisarevsky
2018-11-09 16:12:22 +03:00
committed by GitHub
parent 8cdf7bb84b
commit 8f15a609af
28 changed files with 1219 additions and 2451 deletions
+42 -12
View File
@@ -2810,29 +2810,57 @@ Mat calcLaplaceKernel2D( int aperture_size )
}
void initUndistortMap( const Mat& _a0, const Mat& _k0, Size sz, Mat& _mapx, Mat& _mapy )
void initUndistortMap( const Mat& _a0, const Mat& _k0, const Mat& _R0, const Mat& _new_cam0, Size sz, Mat& __mapx, Mat& __mapy, int map_type )
{
_mapx.create(sz, CV_32F);
_mapy.create(sz, CV_32F);
Mat _mapx(sz, CV_32F), _mapy(sz, CV_32F);
double a[9], k[5]={0,0,0,0,0};
Mat _a(3, 3, CV_64F, a);
double a[9], k[5]={0,0,0,0,0}, iR[9]={1, 0, 0, 0, 1, 0, 0, 0, 1}, a1[9];
Mat _a(3, 3, CV_64F, a), _a1(3, 3, CV_64F, a1);
Mat _k(_k0.rows,_k0.cols, CV_MAKETYPE(CV_64F,_k0.channels()),k);
Mat _iR(3, 3, CV_64F, iR);
double fx, fy, cx, cy, ifx, ify, cxn, cyn;
CV_Assert(_k0.empty() ||
_k0.size() == Size(5, 1) ||
_k0.size() == Size(1, 5) ||
_k0.size() == Size(4, 1) ||
_k0.size() == Size(1, 4));
CV_Assert(_a0.size() == Size(3, 3));
_a0.convertTo(_a, CV_64F);
_k0.convertTo(_k, CV_64F);
if( !_k0.empty() )
_k0.convertTo(_k, CV_64F);
if( !_R0.empty() )
{
CV_Assert(_R0.size() == Size(3, 3));
Mat tmp;
_R0.convertTo(tmp, CV_64F);
invert(tmp, _iR, DECOMP_LU);
}
if( !_new_cam0.empty() )
{
CV_Assert(_new_cam0.size() == Size(3, 3));
_new_cam0.convertTo(_a1, CV_64F);
}
else
_a.copyTo(_a1);
fx = a[0]; fy = a[4]; cx = a[2]; cy = a[5];
ifx = 1./fx; ify = 1./fy;
cxn = cx;
cyn = cy;
ifx = 1./a1[0]; ify = 1./a1[4];
cxn = a1[2];
cyn = a1[5];
for( int v = 0; v < sz.height; v++ )
{
for( int u = 0; u < sz.width; u++ )
{
double x = (u - cxn)*ifx;
double y = (v - cyn)*ify;
double x_ = (u - cxn)*ifx;
double y_ = (v - cyn)*ify;
double X = iR[0]*x_ + iR[1]*y_ + iR[2];
double Y = iR[3]*x_ + iR[4]*y_ + iR[5];
double Z = iR[6]*x_ + iR[7]*y_ + iR[8];
double x = X/Z;
double y = Y/Z;
double x2 = x*x, y2 = y*y;
double r2 = x2 + y2;
double cdist = 1 + (k[0] + (k[1] + k[4]*r2)*r2)*r2;
@@ -2843,8 +2871,10 @@ void initUndistortMap( const Mat& _a0, const Mat& _k0, Size sz, Mat& _mapx, Mat&
_mapx.at<float>(v, u) = (float)(x1*fx + cx);
}
}
}
_mapx.convertTo(__mapx, map_type);
_mapy.convertTo(__mapy, map_type);
}
std::ostream& operator << (std::ostream& out, const MatInfo& m)
{