32 Chandrayaan1M3DistortionMap::Chandrayaan1M3DistortionMap(Camera *parent,
34 double k1,
double k2,
double k3,
35 double p1,
double p2) :
36 CameraDistortionMap(parent, 1.0) {
69 double rr = x * x + y * y;
73 double dr = p_k1 + p_k2 * rr +
p_k3 * rr * rr;
77 double dtx = p_p1 * (rr + 2.0 * x * x) + 2.0 *
p_p2 * x * y;
78 double dty = 2.0 * p_p1 * x * y +
p_p2 * (rr + 2 * y * y);
82 p_undistortedFocalPlaneX = dx + x * dr + dtx;
83 p_undistortedFocalPlaneY = dy + y * dr + dty;
106 double xx, yy, rr, dr;
107 double xdistortion, ydistortion;
108 double xdistorted, ydistorted;
109 double xprevious, yprevious;
114 xprevious = 1000000.0;
115 yprevious = 1000000.0;
117 double tolerance = 0.000001;
119 bool bConverged =
false;
124 for (
int i = 0; i < 50; i++) {
133 dr = p_k1 + p_k2 * rr +
p_k3 * rr * rr;
135 double dtx = p_p1 * (rr + 2.0 * xt * xt) + 2.0 *
p_p2 * xt * yt;
136 double dty = 2.0 * p_p1 * xt * yt +
p_p2 * (rr + 2 * yt * yt);
139 xdistortion = dr * xt + dtx;
140 ydistortion = dr * yt + dty;
143 xt = ux - xdistortion;
144 yt = uy - ydistortion;
147 xdistorted = xt + p_xp;
148 ydistorted = yt +
p_yp;
151 if ((fabs(xt - xprevious) <= tolerance) && (fabs(yt - yprevious) <= tolerance)) {
161 p_undistortedFocalPlaneX = ux;
162 p_undistortedFocalPlaneY = uy;
164 p_focalPlaneX = xdistorted;
165 p_focalPlaneY = ydistorted;
double p_yp
principal point coordinates
double p_p2
coefficients of decentering distortion
bool SetUndistortedFocalPlane(const double ux, const double uy)
Compute distorted focal plane x/y.
bool SetFocalPlane(const double dx, const double dy)
Compute undistorted focal plane x/y.
double p_k3
coefficients of radial distortion