3 #include <ldpk/ldpk_ldp_builtin.h> 11 template <
class VEC2,
class MAT2>
21 static const char* _para[4];
22 double _r_clip_factor;
25 bool decypher(
const char* name,
int& i)
32 if(0 == strcmp(name,_para[i]))
40 bt::check_builtin_parameters();
42 _fl_dn = bt::fl_cm() / bt::r_fb_cm();
52 strcpy(identifier,_para[i]);
60 if(bt::set_builtin_parameter_value(identifier,v))
62 if(!decypher(identifier,i))
65 { bt::no_longer_uptodate_lut(); }
70 bool undistort(
double x0,
double y0,
double &x1,
double &y1)
74 vec2 p_ed_dist_dn = bt::map_unit_to_dn(vec2(x0,y0));
76 double r_ed_dist_dn = norm2(p_ed_dist_dn);
82 double the_undist = _distortion(r_ed_dist_dn / _fl_dn);
84 double phi_new = ::atan2(p_ed_dist_dn[1],p_ed_dist_dn[0]);
85 double the_new = the_undist;
86 if((the_new < -M_PI) || (the_new > M_PI))
89 double x = ::sin(-the_new) * ::cos(phi_new);
90 double y = ::sin(-the_new) * ::sin(phi_new);
91 double z = ::cos(the_new);
92 double r = ::sqrt(x * x + z * z);
94 double phi = ::atan2(x,-z);
95 double the = ::atan2(r,y);
97 { phi += 2.0 * M_PI; }
99 x1 = phi / (2.0 * M_PI);
103 bool distort(
double x0,
double y0,
double &x1,
double &y1)
105 typedef base_type bt;
107 double phi = x0 * (2.0 * M_PI);
108 double the = y0 * M_PI;
110 double z = -::sin(the) * ::cos(phi);
111 double y = ::cos(the);
112 double x = +::sin(the) * ::sin(phi);
114 double r = ::sqrt(x * x + y * y);
115 double the_new = -::atan2(r,z);
116 double phi_new = ::atan2(y,x);
118 double r_ed_dist_dn = _fl_dn * _distortion.
map_inverse(the_new);
119 vec2 p_ed_dn = r_ed_dist_dn * vec2(::cos(phi_new),::sin(phi_new));
121 vec2 q_ed_unit = bt::map_dn_to_unit(p_ed_dn);
133 double r_clip_factor()
const 134 {
return _r_clip_factor; }
135 void r_clip_factor(
double f)
136 { _r_clip_factor = f; }
139 #ifdef LDPK_COMPILE_AS_PLUGIN_SDV 140 strcpy(name,
"3DE4 Radial - Fisheye, Equidistant, Longlat-Z, Degree 8 [Plugin]");
142 strcpy(name,
"3DE4 Radial - Fisheye, Equidistant, Longlat-Z, Degree 8");
148 typedef base_type bt;
150 if(bt::get_builtin_parameter_type(identifier,ptype))
return true;
151 if(!decypher(identifier,i))
return false;
152 ptype = TDE4_LDP_ADJUSTABLE_DOUBLE;
157 typedef base_type bt;
159 if(!decypher(identifier,i))
return false;
165 typedef base_type bt;
167 if(!decypher(identifier,i))
return false;
180 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
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_equidistant_longlat_z_deg_8.experimental.h:146
bool getParameterRange(const char *identifier, double &a, double &b)
returns range for adjustable double parameters...
Definition: tde4_ldp_radial_fisheye_equidistant_longlat_z_deg_8.experimental.h:163
bool undistort(double x0, double y0, double &x1, double &y1)
warp/unwarp 2D points...
Definition: tde4_ldp_radial_fisheye_equidistant_longlat_z_deg_8.experimental.h:70
bool getNumParameters(int &n)
returns the number of plugin parameters...
Definition: tde4_ldp_radial_fisheye_equidistant_longlat_z_deg_8.experimental.h:45
bool getModelName(char *name)
returns a name for the model as to show up in the GUI (maximum length of "name": 100 bytes)...
Definition: tde4_ldp_radial_fisheye_equidistant_longlat_z_deg_8.experimental.h:137
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_equidistant_longlat_z_deg_8.experimental.h:155
bool getParameterName(int i, char *identifier)
returns "identifier" name of parameter "i" (maximum length of "identifier": 100 bytes)...
Definition: tde4_ldp_radial_fisheye_equidistant_longlat_z_deg_8.experimental.h:50
bool setParameterValue(const char *identifier, double v)
set parameter values... parameters predefined by 3DE4: "tde4_focal_length_cm", "tde4_filmback_width_c...
Definition: tde4_ldp_radial_fisheye_equidistant_longlat_z_deg_8.experimental.h:55
A polynomial radially symmetric model of degree N (even)
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
Plugin class for radial distortion. Does not compensate for decentering.
Definition: tde4_ldp_radial_fisheye_equidistant_longlat_z_deg_8.experimental.h:12
bool initializeParameters()
prepare the current set of parameters...
Definition: tde4_ldp_radial_fisheye_equidistant_longlat_z_deg_8.experimental.h:37
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