73 const Eigen::VectorXd & parameters)
87 const Eigen::Vector2d & pointUndistorted,
88 Eigen::Vector2d * pointDistorted)
const
91 const double u0 = pointUndistorted[0];
92 const double u1 = pointUndistorted[1];
93 const double mx_u = u0 * u0;
94 const double my_u = u1 * u1;
95 const double mxy_u = u0 * u1;
96 const double rho_u = mx_u + my_u;
97 const double rad_dist_u =
k1_ * rho_u +
k2_ * rho_u * rho_u;
98 (*pointDistorted)[0] = u0 + u0 * rad_dist_u + 2.0 *
p1_ * mxy_u
99 +
p2_ * (rho_u + 2.0 * mx_u);
100 (*pointDistorted)[1] = u1 + u1 * rad_dist_u + 2.0 *
p2_ * mxy_u
101 +
p1_ * (rho_u + 2.0 * my_u);
106 const Eigen::Vector2d & pointUndistorted, 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 mx_u = u0 * u0;
114 const double my_u = u1 * u1;
115 const double mxy_u = u0 * u1;
116 const double rho_u = mx_u + my_u;
117 const double rad_dist_u =
k1_ * rho_u +
k2_ * rho_u * rho_u;
118 (*pointDistorted)[0] = u0 + u0 * rad_dist_u + 2.0 *
p1_ * mxy_u
119 +
p2_ * (rho_u + 2.0 * mx_u);
120 (*pointDistorted)[1] = u1 + u1 * rad_dist_u + 2.0 *
p2_ * mxy_u
121 +
p1_ * (rho_u + 2.0 * my_u);
124 Eigen::Matrix2d & J = *pointJacobian;
125 J(0, 0) = 1 + rad_dist_u +
k1_ * 2.0 * mx_u +
k2_ * rho_u * 4 * mx_u
126 + 2.0 *
p1_ * u1 + 6 *
p2_ * u0;
127 J(1, 0) =
k1_ * 2.0 * u0 * u1 +
k2_ * 4 * rho_u * u0 * u1 +
p1_ * 2.0 * u0
130 J(1, 1) = 1 + rad_dist_u +
k1_ * 2.0 * my_u +
k2_ * rho_u * 4 * my_u
131 + 6 *
p1_ * u1 + 2.0 *
p2_ * u0;
133 if (parameterJacobian) {
135 Eigen::Matrix2Xd & J2 = *parameterJacobian;
137 const double r2 = rho_u;
138 const double r4 = r2 * r2;
145 J2(0, 2) = 2.0 * u0 * u1;
146 J2(0, 3) = r2 + 2.0 * u0 * u0;
150 J2(1, 2) = r2 + 2.0 * u1 * u1;
151 J2(1, 3) = 2.0 * u0 * u1;
156 const Eigen::Vector2d & pointUndistorted,
157 const Eigen::VectorXd & parameters, Eigen::Vector2d * pointDistorted,
158 Eigen::Matrix2d * pointJacobian,
159 Eigen::Matrix2Xd * parameterJacobian)
const
161 const double k1 = parameters[0];
162 const double k2 = parameters[1];
163 const double p1 = parameters[2];
164 const double p2 = parameters[3];
166 const double u0 = pointUndistorted[0];
167 const double u1 = pointUndistorted[1];
168 const double mx_u = u0 * u0;
169 const double my_u = u1 * u1;
170 const double mxy_u = u0 * u1;
171 const double rho_u = mx_u + my_u;
172 const double rad_dist_u = k1 * rho_u + k2 * rho_u * rho_u;
173 (*pointDistorted)[0] = u0 + u0 * rad_dist_u + 2.0 * p1 * mxy_u
174 + p2 * (rho_u + 2.0 * mx_u);
175 (*pointDistorted)[1] = u1 + u1 * rad_dist_u + 2.0 * p2 * mxy_u
176 + p1 * (rho_u + 2.0 * my_u);
179 Eigen::Matrix2d & J = *pointJacobian;
180 J(0, 0) = 1 + rad_dist_u + k1 * 2.0 * mx_u + k2 * rho_u * 4 * mx_u
181 + 2.0 * p1 * u1 + 6 * p2 * u0;
182 J(1, 0) = k1 * 2.0 * u0 * u1 + k2 * 4 * rho_u * u0 * u1 + p1 * 2.0 * u0
185 J(1, 1) = 1 + rad_dist_u + k1 * 2.0 * my_u + k2 * rho_u * 4 * my_u
186 + 6 * p1 * u1 + 2.0 * p2 * u0;
188 if (parameterJacobian) {
190 Eigen::Matrix2Xd & J2 = *parameterJacobian;
192 const double r2 =rho_u;
193 const double r4 = r2 * r2;
200 J2(0, 2) = 2.0 * u0 * u1;
201 J2(0, 3) = r2 + 2.0 * u0 * u0;
205 J2(1, 2) = r2 + 2.0 * u1 * u1;
206 J2(1, 3) = 2.0 * u0 * u1;
211 const Eigen::Vector2d & pointDistorted,
212 Eigen::Vector2d * pointUndistorted)
const
215 Eigen::Vector2d x_bar = pointDistorted;
219 bool success =
false;
220 for (
int i = 0; i < n; i++) {
222 Eigen::Vector2d x_tmp;
226 Eigen::Vector2d e(pointDistorted - x_tmp);
227 Eigen::Matrix2d E2 = (E.transpose() * E);
228 Eigen::Vector2d du = E2.inverse() * E.transpose() * e;
232 const double chi2 = e.dot(e);
242 *pointUndistorted = x_bar;
245 std::cout<<(E.transpose() * E)<<std::endl;
251 const Eigen::Vector2d & pointDistorted, Eigen::Vector2d * pointUndistorted,
252 Eigen::Matrix2d * pointJacobian)
const
255 Eigen::Vector2d x_bar = pointDistorted;
259 bool success =
false;
260 for (
int i = 0; i < n; i++) {
262 Eigen::Vector2d x_tmp;
266 Eigen::Vector2d e(pointDistorted - x_tmp);
267 Eigen::Vector2d dx = (E.transpose() * E).inverse() * E.transpose() * e;
271 const double chi2 = e.dot(e);
281 *pointUndistorted = x_bar;
284 *pointJacobian = E.inverse();
Eigen::Matrix< double, NumDistortionIntrinsics, 1 > parameters_
all distortion parameters
Definition: RadialTangentialDistortion.hpp:167
double k1_
radial parameter 1
Definition: RadialTangentialDistortion.hpp:169
bool distort(const Eigen::Vector2d &pointUndistorted, Eigen::Vector2d *pointDistorted) const
Distortion only.
Definition: RadialTangentialDistortion.hpp:86
double p1_
tangential parameter 1
Definition: RadialTangentialDistortion.hpp:171
double p2_
tangential parameter 2
Definition: RadialTangentialDistortion.hpp:172
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: RadialTangentialDistortion.hpp:155
bool setParameters(const Eigen::VectorXd ¶meters)
set the generic parameters
Definition: RadialTangentialDistortion.hpp:72
bool undistort(const Eigen::Vector2d &pointDistorted, Eigen::Vector2d *pointUndistorted) const
Undistortion only.
Definition: RadialTangentialDistortion.hpp:210
double k2_
radial parameter 2
Definition: RadialTangentialDistortion.hpp:170
static const int NumDistortionIntrinsics
Definition: RadialTangentialDistortion.hpp:94
EIGEN_MAKE_ALIGNED_OPERATOR_NEW RadialTangentialDistortion()
The default constructor with all zero ki.
Definition: RadialTangentialDistortion.hpp:49