[69607b]: core / vpgl / vpgl_poly_radial_distortion.h Maximize Restore History

Download this file

vpgl_poly_radial_distortion.h    88 lines (75 with data), 2.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// This is core/vpgl/vpgl_poly_radial_distortion.h
#ifndef vpgl_poly_radial_distortion_h_
#define vpgl_poly_radial_distortion_h_
//:
// \file
// \brief A class for polynomial radial lens distortions.
// \author Matt Leotta
// \date Aug 19, 2005
//
// A radial lens distortion is a 2D warping of the image plane that is radial symmetric
// about some center of distortion. It is assumed that the map is
// bijective, though a closed form solution for the inverse may not exist in general.
// A default iterative solver is implemented to solve
#include "vpgl_radial_distortion.h"
#include <vgl/vgl_point_2d.h>
#include <vcl_vector.h>
#include <vcl_cassert.h>
//: A class for nth order polynomial radial lens distortion
template <class T, int n>
class vpgl_poly_radial_distortion : public vpgl_radial_distortion<T>
{
public:
//: Constructor
vpgl_poly_radial_distortion<T,n>(const vgl_point_2d<T>& center, const T* k)
: vpgl_radial_distortion<T>(center,true)
{
set_coefficients(k);
}
//: Constructor
vpgl_poly_radial_distortion<T,n>(const vgl_point_2d<T>& center,
const vgl_point_2d<T>& distorted_center,
const T* k)
: vpgl_radial_distortion<T>(center,distorted_center,true)
{
set_coefficients(k);
}
//: Constructor
vpgl_poly_radial_distortion<T,n>(const vgl_point_2d<T>& center,
const vcl_vector<T>& k)
: vpgl_radial_distortion<T>(center)
{
set_coefficients(k);
}
//: Constructor
vpgl_poly_radial_distortion<T,n>(const vgl_point_2d<T>& center,
const vgl_point_2d<T>& distorted_center,
const vcl_vector<T>& k)
: vpgl_radial_distortion<T>(center, distorted_center)
{
set_coefficients(k);
}
void set_coefficients(const vcl_vector<T>& k)
{
assert(k.size() == n);
T* coptr = coefficients_;
for (unsigned int i=0; i<n; ++i, ++coptr)
*coptr = k[i];
}
void set_coefficients(const T* k)
{
if ( k == NULL ) return;
const T* kptr = k;
T* coptr = coefficients_;
for (unsigned int i=0; i<n; ++i, ++kptr, ++coptr)
*coptr = *kptr;
};
//: Distort a radial length
virtual T distort_radius( T radius ) const;
//: Compute the derivative of the distort_radius function
virtual T distort_radius_deriv( T radius ) const;
protected:
//: The coefficients of the nth-order polynomial
T coefficients_[n];
};
#endif // vpgl_poly_radial_distortion_h_