86 Eigen::Vector2d * pointDistorted)
const
89 const double u0 = pointUndistorted[0];
90 const double u1 = pointUndistorted[1];
91 const double r = sqrt(u0 * u0 + u1 * u1);
92 const double theta = atan(r);
93 const double theta2 = theta * theta;
94 const double theta4 = theta2 * theta2;
95 const double theta6 = theta4 * theta2;
96 const double theta8 = theta4 * theta4;
97 const double thetad = theta
98 * (1 +
k1_ * theta2 +
k2_ * theta4 +
k3_ * theta6 +
k4_ * theta8);
100 const double scaling = (r > 1e-8) ? thetad / r : 1.0;
101 (*pointDistorted)[0] = scaling * u0;
102 (*pointDistorted)[1] = scaling * u1;
106 Eigen::Vector2d * pointDistorted,
107 Eigen::Matrix2d * pointJacobian,
108 Eigen::Matrix2Xd * parameterJacobian)
const
111 const double u0 = pointUndistorted[0];
112 const double u1 = pointUndistorted[1];
113 const double r = sqrt(u0 * u0 + u1 * u1);
114 const double theta = atan(r);
115 const double theta2 = theta * theta;
116 const double theta4 = theta2 * theta2;
117 const double theta6 = theta4 * theta2;
118 const double theta8 = theta4 * theta4;
119 const double thetad = theta
120 * (1 +
k1_ * theta2 +
k2_ * theta4 +
k3_ * theta6 +
k4_ * theta8);
122 const double scaling = (r > 1e-8) ? thetad / r : 1.0;
123 (*pointDistorted)[0] = scaling * u0;
124 (*pointDistorted)[1] = scaling * u1;
126 Eigen::Matrix2d & J = *pointJacobian;
150 t11 = 1.0 / ((t2 + t3) + 1.0);
151 t17 = (((
k1_ * t7 +
k2_ * t9) +
k3_ * t7 * t9) +
k4_ * (t9 * t9)) + 1.0;
153 t19 = 1.0 / sqrt(t4 * t4 * t4);
155 t25 = ((
k2_ * t6 * t7 * t8 * t11 * u1 * 4.0
156 +
k3_ * t6 * t8 * t9 * t11 * u1 * 6.0)
157 +
k4_ * t6 * t7 * t8 * t9 * t11 * u1 * 8.0)
158 +
k1_ * t6 * t8 * t11 * u1 * 2.0;
159 t4 = ((
k2_ * t6 * t7 * t8 * t11 * u0 * 4.0
160 +
k3_ * t6 * t8 * t9 * t11 * u0 * 6.0)
161 +
k4_ * t6 * t7 * t8 * t9 * t11 * u0 * 8.0)
162 +
k1_ * t6 * t8 * t11 * u0 * 2.0;
163 t7 = t11 * t17 * t18 * u0 * u1;
164 J(0, 1) = (t7 + t6 * t8 * t25 * u0) - t6 * t17 * t19 * u0 * u1;
165 J(1, 1) = ((t20 - t3 * t6 * t17 * t19) + t3 * t11 * t17 * t18)
166 + t6 * t8 * t25 * u1;
167 J(0, 0) = ((t20 - t2 * t6 * t17 * t19) + t2 * t11 * t17 * t18)
169 J(1, 0) = (t7 + t6 * t8 * t4 * u1) - t6 * t17 * t19 * u0 * u1;
171 if (parameterJacobian) {
172 Eigen::Matrix2Xd & Ji = *parameterJacobian;
181 t6 = u0 * u0 + u1 * u1;
187 Ji(0, 0) = t2 * t3 * t6 * u0;
188 Ji(1, 0) = t2 * t3 * t6 * u1;
189 Ji(0, 1) = t2 * t8 * t6 * u0;
190 Ji(1, 1) = t2 * t8 * t6 * u1;
191 Ji(0, 2) = t2 * t3 * t8 * t6 * u0;
192 Ji(1, 2) = t2 * t3 * t8 * t6 * u1;
193 Ji(0, 3) = t2 * t6 * t10 * u0;
194 Ji(1, 3) = t2 * t6 * t10 * u1;
199 if (parameterJacobian) {
201 parameterJacobian->setZero();
209 const Eigen::Vector2d & pointUndistorted,
210 const Eigen::VectorXd & parameters, Eigen::Vector2d * pointDistorted,
211 Eigen::Matrix2d * pointJacobian, Eigen::Matrix2Xd * parameterJacobian)
const
215 const double k1 = parameters[0];
216 const double k2 = parameters[1];
217 const double k3 = parameters[2];
218 const double k4 = parameters[3];
220 const double u0 = pointUndistorted[0];
221 const double u1 = pointUndistorted[1];
222 const double r = sqrt(u0 * u0 + u1 * u1);
223 const double theta = atan(r);
224 const double theta2 = theta * theta;
225 const double theta4 = theta2 * theta2;
226 const double theta6 = theta4 * theta2;
227 const double theta8 = theta4 * theta4;
228 const double thetad = theta
229 * (1 + k1 * theta2 + k2 * theta4 + k3 * theta6 + k4 * theta8);
231 const double scaling = (r > 1e-8) ? thetad / r : 1.0;
232 (*pointDistorted)[0] = scaling * u0;
233 (*pointDistorted)[1] = scaling * u1;
235 Eigen::Matrix2d & J = *pointJacobian;
259 t11 = 1.0 / ((t2 + t3) + 1.0);
260 t17 = (((k1 * t7 + k2 * t9) + k3 * t7 * t9) + k4 * (t9 * t9)) + 1.0;
262 t19 = 1.0 / sqrt(t4 * t4 * t4);
264 t25 = ((k2 * t6 * t7 * t8 * t11 * u1 * 4.0
265 + k3 * t6 * t8 * t9 * t11 * u1 * 6.0)
266 + k4 * t6 * t7 * t8 * t9 * t11 * u1 * 8.0)
267 + k1 * t6 * t8 * t11 * u1 * 2.0;
268 t4 = ((k2 * t6 * t7 * t8 * t11 * u0 * 4.0
269 + k3 * t6 * t8 * t9 * t11 * u0 * 6.0)
270 + k4 * t6 * t7 * t8 * t9 * t11 * u0 * 8.0)
271 + k1 * t6 * t8 * t11 * u0 * 2.0;
272 t7 = t11 * t17 * t18 * u0 * u1;
273 J(0, 0) = (t7 + t6 * t8 * t25 * u0) - t6 * t17 * t19 * u0 * u1;
274 J(1, 0) = ((t20 - t3 * t6 * t17 * t19) + t3 * t11 * t17 * t18)
275 + t6 * t8 * t25 * u1;
276 J(0, 1) = ((t20 - t2 * t6 * t17 * t19) + t2 * t11 * t17 * t18)
278 J(1, 1) = (t7 + t6 * t8 * t4 * u1) - t6 * t17 * t19 * u0 * u1;
279 if (parameterJacobian) {
280 Eigen::Matrix2Xd & Ji = *parameterJacobian;
289 t6 = u0 * u0 + u1 * u1;
295 Ji(0, 0) = t2 * t3 * t6 * u0;
296 Ji(1, 0) = t2 * t3 * t6 * u1;
297 Ji(0, 1) = t2 * t8 * t6 * u0;
298 Ji(1, 1) = t2 * t8 * t6 * u1;
299 Ji(0, 2) = t2 * t3 * t8 * t6 * u0;
300 Ji(1, 2) = t2 * t3 * t8 * t6 * u1;
301 Ji(0, 3) = t2 * t6 * t10 * u0;
302 Ji(1, 3) = t2 * t6 * t10 * u1;
307 if (parameterJacobian) {
309 parameterJacobian->setZero();
317 Eigen::Vector2d * pointUndistorted)
const
320 Eigen::Vector2d x_bar = pointDistorted;
324 bool success =
false;
325 for (
int i = 0; i < n; i++) {
327 Eigen::Vector2d x_tmp;
331 Eigen::Vector2d e(pointDistorted - x_tmp);
332 Eigen::Vector2d du = (E.transpose() * E).inverse() * E.transpose() * e;
336 const double chi2 = e.dot(e);
347 *pointUndistorted = x_bar;
352 Eigen::Vector2d * pointUndistorted,
353 Eigen::Matrix2d * pointJacobian)
const
356 Eigen::Vector2d x_bar = pointDistorted;
360 bool success =
false;
361 for (
int i = 0; i < n; i++) {
363 Eigen::Vector2d x_tmp;
367 Eigen::Vector2d e(pointDistorted - x_tmp);
368 Eigen::Vector2d dx = (E.transpose() * E).inverse() * E.transpose() * e;
372 const double chi2 = e.dot(e);
382 *pointUndistorted = x_bar;
385 *pointJacobian = E.inverse();
Eigen::Matrix< double, NumDistortionIntrinsics, 1 > parameters_
all distortion parameters
Definition: EquidistantDistortion.hpp:167
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EquidistantDistortion()
The default constructor with all zero ki.
Definition: EquidistantDistortion.hpp:49
double k2_
radial parameter 2
Definition: EquidistantDistortion.hpp:170
bool setParameters(const Eigen::VectorXd ¶meters)
set the generic parameters
Definition: EquidistantDistortion.hpp:72
double k1_
radial parameter 1
Definition: EquidistantDistortion.hpp:169
static const int NumDistortionIntrinsics
Definition: EquidistantDistortion.hpp:94
bool distort(const Eigen::Vector2d &pointUndistorted, Eigen::Vector2d *pointDistorted) const
Distortion only.
Definition: EquidistantDistortion.hpp:85
double k4_
tangential parameter 2
Definition: EquidistantDistortion.hpp:172
double k3_
tangential parameter 1
Definition: EquidistantDistortion.hpp:171
bool distortWithExternalParameters(const Eigen::Vector2d &pointUndistorted, const Eigen::VectorXd ¶meters, Eigen::Vector2d *pointDistorted, Eigen::Matrix2d *pointJacobian=NULL, Eigen::Matrix2Xd *parameterJacobian=NULL) const
Distortion and Jacobians using external distortion intrinsics parameters.
Definition: EquidistantDistortion.hpp:208
bool undistort(const Eigen::Vector2d &pointDistorted, Eigen::Vector2d *pointUndistorted) const
Undistortion only.
Definition: EquidistantDistortion.hpp:316