22 #ifndef OV_CORE_CAM_EQUI_H
23 #define OV_CORE_CAM_EQUI_H
108 Eigen::Vector2f
undistort_f(
const Eigen::Vector2f &uv_dist)
override {
115 cv::Mat mat(1, 2, CV_32F);
116 mat.at<
float>(0, 0) = uv_dist(0);
117 mat.at<
float>(0, 1) = uv_dist(1);
118 mat = mat.reshape(2);
121 cv::fisheye::undistortPoints(mat, mat, camK, camD);
124 Eigen::Vector2f pt_out;
125 mat = mat.reshape(1);
126 pt_out(0) = mat.at<
float>(0, 0);
127 pt_out(1) = mat.at<
float>(0, 1);
136 Eigen::Vector2f
distort_f(
const Eigen::Vector2f &uv_norm)
override {
142 double r = std::sqrt(uv_norm(0) * uv_norm(0) + uv_norm(1) * uv_norm(1));
143 double theta = std::atan(r);
144 double theta_d = theta + cam_d(4) * std::pow(theta, 3) + cam_d(5) * std::pow(theta, 5) + cam_d(6) * std::pow(theta, 7) +
145 cam_d(7) * std::pow(theta, 9);
148 double inv_r = (r > 1e-8) ? 1.0 / r : 1.0;
149 double cdist = (r > 1e-8) ? theta_d * inv_r : 1.0;
152 Eigen::Vector2f uv_dist;
153 double x1 = uv_norm(0) * cdist;
154 double y1 = uv_norm(1) * cdist;
155 uv_dist(0) = (float)(cam_d(0) * x1 + cam_d(2));
156 uv_dist(1) = (float)(cam_d(1) * y1 + cam_d(3));
172 double r = std::sqrt(uv_norm(0) * uv_norm(0) + uv_norm(1) * uv_norm(1));
173 double theta = std::atan(r);
174 double theta_d = theta + cam_d(4) * std::pow(theta, 3) + cam_d(5) * std::pow(theta, 5) + cam_d(6) * std::pow(theta, 7) +
175 cam_d(7) * std::pow(theta, 9);
178 double inv_r = (r > 1e-8) ? 1.0 / r : 1.0;
179 double cdist = (r > 1e-8) ? theta_d * inv_r : 1.0;
182 Eigen::Matrix<double, 2, 2> duv_dxy = Eigen::Matrix<double, 2, 2>::Zero();
183 duv_dxy << cam_d(0), 0, 0, cam_d(1);
186 Eigen::Matrix<double, 2, 2> dxy_dxyn = Eigen::Matrix<double, 2, 2>::Zero();
187 dxy_dxyn << theta_d * inv_r, 0, 0, theta_d * inv_r;
190 Eigen::Matrix<double, 2, 1> dxy_dr = Eigen::Matrix<double, 2, 1>::Zero();
191 dxy_dr << -uv_norm(0) * theta_d * inv_r * inv_r, -uv_norm(1) * theta_d * inv_r * inv_r;
194 Eigen::Matrix<double, 1, 2> dr_dxyn = Eigen::Matrix<double, 1, 2>::Zero();
195 dr_dxyn << uv_norm(0) * inv_r, uv_norm(1) * inv_r;
198 Eigen::Matrix<double, 2, 1> dxy_dthd = Eigen::Matrix<double, 2, 1>::Zero();
199 dxy_dthd << uv_norm(0) * inv_r, uv_norm(1) * inv_r;
202 double dthd_dth = 1 + 3 * cam_d(4) * std::pow(theta, 2) + 5 * cam_d(5) * std::pow(theta, 4) + 7 * cam_d(6) * std::pow(theta, 6) +
203 9 * cam_d(7) * std::pow(theta, 8);
206 double dth_dr = 1 / (r * r + 1);
209 H_dz_dzn = Eigen::MatrixXd::Zero(2, 2);
210 H_dz_dzn = duv_dxy * (dxy_dxyn + (dxy_dr + dxy_dthd * dthd_dth * dth_dr) * dr_dxyn);
213 double x1 = uv_norm(0) * cdist;
214 double y1 = uv_norm(1) * cdist;
217 H_dz_dzeta = Eigen::MatrixXd::Zero(2, 8);
218 H_dz_dzeta(0, 0) = x1;
219 H_dz_dzeta(0, 2) = 1;
220 H_dz_dzeta(0, 4) = cam_d(0) * uv_norm(0) * inv_r * std::pow(theta, 3);
221 H_dz_dzeta(0, 5) = cam_d(0) * uv_norm(0) * inv_r * std::pow(theta, 5);
222 H_dz_dzeta(0, 6) = cam_d(0) * uv_norm(0) * inv_r * std::pow(theta, 7);
223 H_dz_dzeta(0, 7) = cam_d(0) * uv_norm(0) * inv_r * std::pow(theta, 9);
224 H_dz_dzeta(1, 1) = y1;
225 H_dz_dzeta(1, 3) = 1;
226 H_dz_dzeta(1, 4) = cam_d(1) * uv_norm(1) * inv_r * std::pow(theta, 3);
227 H_dz_dzeta(1, 5) = cam_d(1) * uv_norm(1) * inv_r * std::pow(theta, 5);
228 H_dz_dzeta(1, 6) = cam_d(1) * uv_norm(1) * inv_r * std::pow(theta, 7);
229 H_dz_dzeta(1, 7) = cam_d(1) * uv_norm(1) * inv_r * std::pow(theta, 9);