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);
108 template <
typename T>
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;
137 template <
typename T>
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,
164 const int max_image_size =
std::max(image_width, image_height);
165 const double max_half_image_size = max_image_size * 0.5;
167 if (max_half_image_size == 0.0) {
168 *normalized_x = image_x * max_half_image_size / focal_length_x;
169 *normalized_y = image_y * max_half_image_size / focal_length_y;
173 const T xd = (image_x - principal_point_x) / max_half_image_size;
174 const T yd = (image_y - principal_point_y) / max_half_image_size;
176 T rd2 = xd * xd + yd * yd;
178 T r_coeff =
T(1) / (
T(1) + k1 * rd2 + k2 * rd4);
182 *normalized_x = xu * max_half_image_size / focal_length_x;
183 *normalized_y = yu * max_half_image_size / focal_length_y;
193 const double focal_length_y,
194 const double principal_point_x,
195 const double principal_point_y,
196 const int image_width,
197 const int image_height,
200 const double normalized_x,
201 const double normalized_y,
209 const double focal_length_y,
210 const double principal_point_x,
211 const double principal_point_y,
218 const double image_x,
219 const double image_y,
220 double* normalized_x,
221 double* normalized_y);
223 template <
typename T>
225 const T& focal_length_y,
226 const T& principal_point_x,
227 const T& principal_point_y,
234 const T& normalized_x,
235 const T& normalized_y,
244 T xy2 =
T(2) *
x *
y;
246 T r_coeff =
T(1) + (((k4 * r2 + k3) * r2 + k2) * r2 + k1) * r2;
247 T tx = p1 * (r2 +
T(2) *
x2) + p2 * xy2;
248 T ty = p2 * (r2 +
T(2) * y2) + p1 * xy2;
249 T xd =
x * r_coeff + tx;
250 T yd =
y * r_coeff + ty;
253 *image_x = focal_length_x * xd + principal_point_x;
254 *image_y = focal_length_y * yd + principal_point_y;
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble x2
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 &image_x, const T &image_y, T *normalized_x, T *normalized_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 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 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)