Go to the documentation of this file.00001
00002 #ifndef vpgl_radial_distortion_h_
00003 #define vpgl_radial_distortion_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "vpgl_lens_distortion.h"
00016 #include <vgl/vgl_point_2d.h>
00017 #include <vgl/vgl_vector_2d.h>
00018 #include <vgl/vgl_homg_point_2d.h>
00019
00020
00021 template <class T>
00022 class vpgl_radial_distortion : public vpgl_lens_distortion<T>
00023 {
00024 public:
00025
00026 vpgl_radial_distortion(const vgl_point_2d<T>& center, bool has_deriv=false)
00027 : center_(center), distorted_center_(center), has_derivative_(has_deriv) {}
00028
00029
00030 vpgl_radial_distortion(const vgl_point_2d<T>& center,
00031 const vgl_point_2d<T>& new_center, bool has_deriv=false)
00032 : center_(center), distorted_center_(new_center), has_derivative_(has_deriv) {}
00033
00034
00035
00036 virtual vgl_homg_point_2d<T> distort( const vgl_homg_point_2d<T>& point ) const;
00037
00038
00039
00040
00041
00042 virtual vgl_homg_point_2d<T> undistort( const vgl_homg_point_2d<T>& point,
00043 const vgl_homg_point_2d<T>* init=0) const;
00044
00045
00046
00047
00048
00049
00050 virtual T distort_radius( T radius ) const = 0;
00051
00052
00053
00054
00055 virtual T undistort_radius( T radius, const T* init=0) const;
00056
00057
00058
00059
00060
00061 virtual T distort_radius_deriv( T radius ) const
00062 {
00063 T eps = T(0.001);
00064 return (distort_radius(radius) - distort_radius(radius-eps)) / eps;
00065 }
00066
00067
00068
00069
00070 virtual void set_translation(const vgl_vector_2d<T>& offset, bool after = true)
00071 {
00072 if (after)
00073 distorted_center_ += offset;
00074 else
00075 center_ += offset;
00076 }
00077
00078
00079 vgl_point_2d<T> center() const { return center_; }
00080
00081 vgl_point_2d<T> distorted_center() const { return distorted_center_; }
00082
00083
00084 void set_center(const vgl_point_2d<T>& c) { center_ = c; }
00085
00086 void set_distorted_center(const vgl_point_2d<T>& dc) { distorted_center_ = dc; }
00087
00088 protected:
00089
00090 vgl_point_2d<T> center_;
00091
00092
00093 vgl_point_2d<T> distorted_center_;
00094
00095 bool has_derivative_;
00096 };
00097
00098 #endif // vpgl_radial_distortion_h_