Skip to content

Commit 99fae81

Browse files
committed
Merge pull request opencv#9626 from T0ny0:fisheye_fix_
2 parents 9dea296 + 2f0036c commit 99fae81

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

modules/calib3d/src/fisheye.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,17 +475,26 @@ void cv::fisheye::initUndistortRectifyMap( InputArray K, InputArray D, InputArra
475475

476476
for( int j = 0; j < size.width; ++j)
477477
{
478-
double x = _x/_w, y = _y/_w;
478+
double u, v;
479+
if( _w <= 0)
480+
{
481+
u = (_x > 0) ? -std::numeric_limits<double>::infinity() : std::numeric_limits<double>::infinity();
482+
v = (_y > 0) ? -std::numeric_limits<double>::infinity() : std::numeric_limits<double>::infinity();
483+
}
484+
else
485+
{
486+
double x = _x/_w, y = _y/_w;
479487

480-
double r = sqrt(x*x + y*y);
481-
double theta = atan(r);
488+
double r = sqrt(x*x + y*y);
489+
double theta = atan(r);
482490

483-
double theta2 = theta*theta, theta4 = theta2*theta2, theta6 = theta4*theta2, theta8 = theta4*theta4;
484-
double theta_d = theta * (1 + k[0]*theta2 + k[1]*theta4 + k[2]*theta6 + k[3]*theta8);
491+
double theta2 = theta*theta, theta4 = theta2*theta2, theta6 = theta4*theta2, theta8 = theta4*theta4;
492+
double theta_d = theta * (1 + k[0]*theta2 + k[1]*theta4 + k[2]*theta6 + k[3]*theta8);
485493

486-
double scale = (r == 0) ? 1.0 : theta_d / r;
487-
double u = f[0]*x*scale + c[0];
488-
double v = f[1]*y*scale + c[1];
494+
double scale = (r == 0) ? 1.0 : theta_d / r;
495+
u = f[0]*x*scale + c[0];
496+
v = f[1]*y*scale + c[1];
497+
}
489498

490499
if( m1type == CV_16SC2 )
491500
{

0 commit comments

Comments
 (0)