21#ifndef LIBMV_SIMPLE_PIPELINE_DISTORTION_MODELS_H_
22#define LIBMV_SIMPLE_PIPELINE_DISTORTION_MODELS_H_
39 const double focal_length_y,
40 const double principal_point_x,
41 const double principal_point_y,
50 double* normalized_y);
58 const T& focal_length_y,
59 const T& principal_point_x,
60 const T& principal_point_y,
66 const T& normalized_x,
67 const T& normalized_y,
77 T r_coeff = (
T(1) + k1 * r2 + k2 * r4 + k3 * r6);
78 T xd =
x * r_coeff +
T(2) * p1 *
x *
y + p2 * (r2 +
T(2) *
x *
x);
79 T yd =
y * r_coeff +
T(2) * p2 *
x *
y + p1 * (r2 +
T(2) *
y *
y);
82 *image_x = focal_length_x * xd + principal_point_x;
83 *image_y = focal_length_y * yd + principal_point_y;
92 const double focal_length_y,
93 const double principal_point_x,
94 const double principal_point_y,
100 double* normalized_y);
110 const T& focal_length_y,
111 const T& principal_point_x,
112 const T& principal_point_y,
115 const T& normalized_x,
116 const T& normalized_y,
121 T r2 =
x *
x +
y *
y;
124 T xd =
x / (
T(1) + k1 * r2 + k2 * r4);
125 T yd =
y / (
T(1) + k1 * r2 + k2 * r4);
128 *image_x = focal_length_x * xd + principal_point_x;
129 *image_y = focal_length_y * yd + principal_point_y;
139 const T& focal_length_y,
140 const T& principal_point_x,
141 const T& principal_point_y,
142 const int image_width,
143 const int image_height,
168 const int max_image_size = std::max(image_width, image_height);
169 const double max_half_image_size = max_image_size * 0.5;
171 if (max_half_image_size == 0.0) {
172 *normalized_x = image_x * max_half_image_size / focal_length_x;
173 *normalized_y = image_y * max_half_image_size / focal_length_y;
177 const T xd = (image_x - principal_point_x) / max_half_image_size;
178 const T yd = (image_y - principal_point_y) / max_half_image_size;
184 T xu = xd / (
T(1) + k1 * rd2 + k2 * rd4 + p1 * yd2);
185 T yu = yd / (
T(1) + k1 * rd2 + k2 * rd4 + p2 * xd2);
187 *normalized_x = xu * max_half_image_size / focal_length_x;
188 *normalized_y = yu * max_half_image_size / focal_length_y;
198 const double focal_length_y,
199 const double principal_point_x,
200 const double principal_point_y,
201 const int image_width,
202 const int image_height,
207 const double normalized_x,
208 const double normalized_y,
216 const double focal_length_y,
217 const double principal_point_x,
218 const double principal_point_y,
225 const double image_x,
226 const double image_y,
227 double* normalized_x,
228 double* normalized_y);
232 const T& focal_length_y,
233 const T& principal_point_x,
234 const T& principal_point_y,
241 const T& normalized_x,
242 const T& normalized_y,
251 T xy2 =
T(2) *
x *
y;
253 T r_coeff =
T(1) + (((k4 * r2 + k3) * r2 + k2) * r2 + k1) * r2;
254 T tx = p1 * (r2 +
T(2) * x2) + p2 * xy2;
255 T ty = p2 * (r2 +
T(2) * y2) + p1 * xy2;
256 T xd =
x * r_coeff + tx;
257 T yd =
y * r_coeff + ty;
260 *image_x = focal_length_x * xd + principal_point_x;
261 *image_y = focal_length_y * yd + principal_point_y;
void InvertPolynomialDistortionModel(const double focal_length_x, const double focal_length_y, const double principal_point_x, const double principal_point_y, const double k1, const double k2, const double k3, const double p1, const double p2, const double image_x, const double image_y, double *normalized_x, double *normalized_y)
void ApplyPolynomialDistortionModel(const T &focal_length_x, const T &focal_length_y, const T &principal_point_x, const T &principal_point_y, const T &k1, const T &k2, const T &k3, const T &p1, const T &p2, const T &normalized_x, const T &normalized_y, T *image_x, T *image_y)
void ApplyDivisionDistortionModel(const T &focal_length_x, const T &focal_length_y, const T &principal_point_x, const T &principal_point_y, const T &k1, const T &k2, const T &normalized_x, const T &normalized_y, T *image_x, T *image_y)
void ApplyNukeDistortionModel(const double focal_length_x, const double focal_length_y, const double principal_point_x, const double principal_point_y, const int image_width, const int image_height, const double k1, const double k2, const double p1, const double p2, const double normalized_x, const double normalized_y, double *image_x, double *image_y)
void InvertBrownDistortionModel(const double focal_length_x, const double focal_length_y, const double principal_point_x, const double principal_point_y, const double k1, const double k2, const double k3, const double k4, const double p1, const double p2, const double image_x, const double image_y, double *normalized_x, double *normalized_y)
void InvertDivisionDistortionModel(const double focal_length_x, const double focal_length_y, const double principal_point_x, const double principal_point_y, const double k1, const double k2, const double image_x, const double image_y, double *normalized_x, double *normalized_y)
@ DISTORTION_MODEL_POLYNOMIAL
@ DISTORTION_MODEL_DIVISION
void InvertNukeDistortionModel(const T &focal_length_x, const T &focal_length_y, const T &principal_point_x, const T &principal_point_y, const int image_width, const int image_height, const T &k1, const T &k2, const T &p1, const T &p2, const T &image_x, const T &image_y, T *normalized_x, T *normalized_y)
void ApplyBrownDistortionModel(const T &focal_length_x, const T &focal_length_y, const T &principal_point_x, const T &principal_point_y, const T &k1, const T &k2, const T &k3, const T &k4, const T &p1, const T &p2, const T &normalized_x, const T &normalized_y, T *image_x, T *image_y)