mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Merge pull request #26988 from DanBmh:opt_undistort
Optimize undistort points #26988 Skips unnecessary rotation with identity matrix if no R or P mats are given. --------- Co-authored-by: Daniel <daniel@mail.de>
This commit is contained in:
parent
a62b78d6e3
commit
8a24d41b54
@ -478,10 +478,18 @@ void cv::fisheye::undistortPoints( InputArray distorted, OutputArray undistorted
|
||||
if ((converged || !isEps) && !theta_flipped)
|
||||
{
|
||||
Vec2d pu = pw * scale; //undistorted point
|
||||
Vec2d fi;
|
||||
|
||||
// reproject
|
||||
Vec3d pr = RR * Vec3d(pu[0], pu[1], 1.0); // rotated point optionally multiplied by new camera matrix
|
||||
Vec2d fi(pr[0]/pr[2], pr[1]/pr[2]); // final
|
||||
if (!R.empty() || !P.empty())
|
||||
{
|
||||
// reproject
|
||||
Vec3d pr = RR * Vec3d(pu[0], pu[1], 1.0); // rotated point optionally multiplied by new camera matrix
|
||||
fi = Vec2d(pr[0]/pr[2], pr[1]/pr[2]); // final
|
||||
}
|
||||
else
|
||||
{
|
||||
fi = pu;
|
||||
}
|
||||
|
||||
if( sdepth == CV_32F )
|
||||
dstf[i] = fi;
|
||||
|
@ -488,11 +488,14 @@ static void cvUndistortPointsInternal( const CvMat* _src, CvMat* _dst, const CvM
|
||||
}
|
||||
}
|
||||
|
||||
double xx = RR[0][0]*x + RR[0][1]*y + RR[0][2];
|
||||
double yy = RR[1][0]*x + RR[1][1]*y + RR[1][2];
|
||||
double ww = 1./(RR[2][0]*x + RR[2][1]*y + RR[2][2]);
|
||||
x = xx*ww;
|
||||
y = yy*ww;
|
||||
if( matR || matP )
|
||||
{
|
||||
double xx = RR[0][0]*x + RR[0][1]*y + RR[0][2];
|
||||
double yy = RR[1][0]*x + RR[1][1]*y + RR[1][2];
|
||||
double ww = 1./(RR[2][0]*x + RR[2][1]*y + RR[2][2]);
|
||||
x = xx*ww;
|
||||
y = yy*ww;
|
||||
}
|
||||
|
||||
if( dtype == CV_32FC2 )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user