3 #include <ldpk/ldpk_ldp_builtin.h> 13 template <
class VEC2,
class MAT2>
17 typedef VEC2 vec2_type;
18 typedef MAT2 mat2_type;
23 static const char* _para[4];
25 double _r_clip_factor;
28 bool decypher(
const char* name,
int& i)
35 if(0 == strcmp(name,_para[i]))
40 bool initializeParameters()
43 bt::check_builtin_parameters();
45 _fl_dn = bt::fl_cm() / bt::r_fb_cm();
48 bool getNumParameters(
int& n)
53 bool getParameterName(
int i,
char* identifier)
55 strcpy(identifier,_para[i]);
58 bool setParameterValue(
const char *identifier,
double v)
63 if(bt::set_builtin_parameter_value(identifier,v))
65 if(!decypher(identifier,i))
68 { bt::no_longer_uptodate_lut(); }
72 virtual bool remap_fe2plain(
double r_ed_dn,
double& r_plain_dn) = 0;
73 virtual bool remap_plain2fe(
double r_plain_dn,
double& r_ed_dn) = 0;
75 bool undistort(
double x0,
double y0,
double &x1,
double &y1)
79 vec2_type p_ed_dist_dn = bt::map_unit_to_dn(vec2_type(x0,y0));
82 double r_ed_dist_dn = norm2(p_ed_dist_dn);
87 double r_ed_undist_dn = _fl_dn * _distortion(r_ed_dist_dn / _fl_dn);
89 double r_plain_undist_dn;
90 if(!remap_fe2plain(r_ed_undist_dn,r_plain_undist_dn))
93 vec2_type p_plain_undist_dn;
94 if(dotsq(p_ed_dist_dn) == 0.0)
95 { p_plain_undist_dn = vec2_type(0,0); }
97 { p_plain_undist_dn = r_plain_undist_dn * unit(p_ed_dist_dn); }
99 vec2_type p_plain_undist_unit = bt::map_dn_to_unit(p_plain_undist_dn);
100 x1 = p_plain_undist_unit[0];
101 y1 = p_plain_undist_unit[1];
104 bool distort(
double x0,
double y0,
double &x1,
double &y1)
106 typedef base_type bt;
108 vec2_type p_plain_undis_dn = bt::map_unit_to_dn(vec2_type(x0,y0));
110 double r_ed_undis_dn,r_plain_undis_dn = norm2(p_plain_undis_dn);
112 if(!remap_plain2fe(r_plain_undis_dn,r_ed_undis_dn))
115 double r_ed_dis_dn = _fl_dn * _distortion.
map_inverse(r_ed_undis_dn / _fl_dn,r_ed_undis_dn / _fl_dn);
117 vec2_type p_ed_dis_dn;
118 if(dotsq(p_plain_undis_dn) == 0.0)
119 { p_ed_dis_dn = vec2_type(0,0); }
121 { p_ed_dis_dn = r_ed_dis_dn * unit(p_plain_undis_dn); }
123 vec2_type p_ed_dis_unit = bt::map_dn_to_unit(p_ed_dis_dn);
124 x1 = p_ed_dis_unit[0];
125 y1 = p_ed_dis_unit[1];
134 double r_clip_factor()
const 135 {
return _r_clip_factor; }
136 void r_clip_factor(
double f)
137 { _r_clip_factor = f; }
141 typedef base_type bt;
143 if(bt::get_builtin_parameter_type(identifier,ptype))
return true;
144 if(!decypher(identifier,i))
return false;
145 ptype = TDE4_LDP_ADJUSTABLE_DOUBLE;
150 typedef base_type bt;
152 if(!decypher(identifier,i))
return false;
158 typedef base_type bt;
160 if(!decypher(identifier,i))
return false;
167 template <
class VEC2,
class MAT2>
double map_inverse(double q) const
Inverse mapping by solving the fixed point equation without providing initial values.
Definition: ldpk_generic_radial_distortion_1d.h:96
void set_coeff(int i, double q)
Set coefficient c[i], 0 <= i < N.
Definition: ldpk_generic_radial_distortion_1d.h:59
virtual bool getModelName(char *name)=0
returns a name for the model as to show up in the GUI (maximum length of "name": 100 bytes)...
bool getParameterType(const char *identifier, tde4_ldp_ptype &ptype)
returns type of given parameter... The method should return false, if the parameter addressed by iden...
Definition: tde4_ldp_radial_fisheye_base_deg_8.experimental.h:139
Plugin class for radial distortion. Does not compensate for decentering.
Definition: tde4_ldp_radial_fisheye_base_deg_8.experimental.h:14
bool getParameterRange(const char *identifier, double &a, double &b)
returns range for adjustable double parameters...
Definition: tde4_ldp_radial_fisheye_base_deg_8.experimental.h:156
A polynomial radially symmetric model of degree N (even)
bool getParameterDefaultValue(const char *identifier, double &v)
returns default value for given parameter (maximum length of "char *v": 1000 bytes)......
Definition: tde4_ldp_radial_fisheye_base_deg_8.experimental.h:148
This class handles the built-in parameter and the lookup table. You may find it useful for your own d...
Definition: ldpk_ldp_builtin.h:31
Double-valued vector and matrix class.
double get_coeff(int i) const
Get coefficient c[i], 0 <= i < N (i.e. coefficient power r^(2i))
Definition: ldpk_generic_radial_distortion_1d.h:53