22 #ifndef OV_CORE_CAM_RADTAN_H
23 #define OV_CORE_CAM_RADTAN_H
99 Eigen::Vector2f
undistort_f(
const Eigen::Vector2f &uv_dist)
override {
106 cv::Mat mat(1, 2, CV_32F);
107 mat.at<
float>(0, 0) = uv_dist(0);
108 mat.at<
float>(0, 1) = uv_dist(1);
109 mat = mat.reshape(2);
112 cv::undistortPoints(mat, mat, camK, camD);
115 Eigen::Vector2f pt_out;
116 mat = mat.reshape(1);
117 pt_out(0) = mat.at<
float>(0, 0);
118 pt_out(1) = mat.at<
float>(0, 1);
127 Eigen::Vector2f
distort_f(
const Eigen::Vector2f &uv_norm)
override {
133 double r = std::sqrt(uv_norm(0) * uv_norm(0) + uv_norm(1) * uv_norm(1));
135 double r_4 = r_2 * r_2;
136 double x1 = uv_norm(0) * (1 + cam_d(4) * r_2 + cam_d(5) * r_4) + 2 * cam_d(6) * uv_norm(0) * uv_norm(1) +
137 cam_d(7) * (r_2 + 2 * uv_norm(0) * uv_norm(0));
138 double y1 = uv_norm(1) * (1 + cam_d(4) * r_2 + cam_d(5) * r_4) + cam_d(6) * (r_2 + 2 * uv_norm(1) * uv_norm(1)) +
139 2 * cam_d(7) * uv_norm(0) * uv_norm(1);
142 Eigen::Vector2f uv_dist;
143 uv_dist(0) = (float)(cam_d(0) * x1 + cam_d(2));
144 uv_dist(1) = (float)(cam_d(1) * y1 + cam_d(3));
160 double r = std::sqrt(uv_norm(0) * uv_norm(0) + uv_norm(1) * uv_norm(1));
162 double r_4 = r_2 * r_2;
165 H_dz_dzn = Eigen::MatrixXd::Zero(2, 2);
166 double x = uv_norm(0);
167 double y = uv_norm(1);
168 double x_2 = uv_norm(0) * uv_norm(0);
169 double y_2 = uv_norm(1) * uv_norm(1);
170 double x_y = uv_norm(0) * uv_norm(1);
171 H_dz_dzn(0, 0) = cam_d(0) * ((1 + cam_d(4) * r_2 + cam_d(5) * r_4) + (2 * cam_d(4) * x_2 + 4 * cam_d(5) * x_2 * r_2) +
172 2 * cam_d(6) * y + (2 * cam_d(7) * x + 4 * cam_d(7) * x));
173 H_dz_dzn(0, 1) = cam_d(0) * (2 * cam_d(4) * x_y + 4 * cam_d(5) * x_y * r_2 + 2 * cam_d(6) * x + 2 * cam_d(7) * y);
174 H_dz_dzn(1, 0) = cam_d(1) * (2 * cam_d(4) * x_y + 4 * cam_d(5) * x_y * r_2 + 2 * cam_d(6) * x + 2 * cam_d(7) * y);
175 H_dz_dzn(1, 1) = cam_d(1) * ((1 + cam_d(4) * r_2 + cam_d(5) * r_4) + (2 * cam_d(4) * y_2 + 4 * cam_d(5) * y_2 * r_2) +
176 2 * cam_d(7) * x + (2 * cam_d(6) * y + 4 * cam_d(6) * y));
179 double x1 = uv_norm(0) * (1 + cam_d(4) * r_2 + cam_d(5) * r_4) + 2 * cam_d(6) * uv_norm(0) * uv_norm(1) +
180 cam_d(7) * (r_2 + 2 * uv_norm(0) * uv_norm(0));
181 double y1 = uv_norm(1) * (1 + cam_d(4) * r_2 + cam_d(5) * r_4) + cam_d(6) * (r_2 + 2 * uv_norm(1) * uv_norm(1)) +
182 2 * cam_d(7) * uv_norm(0) * uv_norm(1);
185 H_dz_dzeta = Eigen::MatrixXd::Zero(2, 8);
186 H_dz_dzeta(0, 0) = x1;
187 H_dz_dzeta(0, 2) = 1;
188 H_dz_dzeta(0, 4) = cam_d(0) * uv_norm(0) * r_2;
189 H_dz_dzeta(0, 5) = cam_d(0) * uv_norm(0) * r_4;
190 H_dz_dzeta(0, 6) = 2 * cam_d(0) * uv_norm(0) * uv_norm(1);
191 H_dz_dzeta(0, 7) = cam_d(0) * (r_2 + 2 * uv_norm(0) * uv_norm(0));
192 H_dz_dzeta(1, 1) = y1;
193 H_dz_dzeta(1, 3) = 1;
194 H_dz_dzeta(1, 4) = cam_d(1) * uv_norm(1) * r_2;
195 H_dz_dzeta(1, 5) = cam_d(1) * uv_norm(1) * r_4;
196 H_dz_dzeta(1, 6) = cam_d(1) * (r_2 + 2 * uv_norm(1) * uv_norm(1));
197 H_dz_dzeta(1, 7) = 2 * cam_d(1) * uv_norm(0) * uv_norm(1);