1 #ifndef tde4_ldp_all_par_types_sdv 2 #define tde4_ldp_all_par_types_sdv 4 #include <ldpk/ldpk_ldp_builtin.h> 5 #include <ldpk/ldpk_generic_anamorphic_distortion.h> 6 #include <ldpk/ldpk_rotation_extender.h> 7 #include <ldpk/ldpk_squeeze_extender.h> 8 #include <ldpk/ldpk_linear_extender.h> 18 template <
class VEC2,
class MAT2>
22 typedef VEC2 vec2_type;
23 typedef MAT2 mat2_type;
26 static const char* _para[9];
28 bool _debugging_enabled;
29 std::string _debugging_filename;
30 std::ofstream _debugging_fout;
45 bool decypher(
const char* name,
int& i)
52 if(0 == strcmp(name,_para[i]))
57 bool initializeParameters()
60 bt::check_builtin_parameters();
64 _rot_sqx_sqy_pa.
set(_rotation,_squeeze_x,_squeeze_y,_pa);
65 if(_squeeze_x.get_sq() == 0)
66 { std::cerr <<
"tde4_ldp_anamorphic_deg_4_rotate_squeeze_xy::initializeParameters, error: Squeeze-X is 0." << std::endl; }
67 if(_squeeze_y.get_sq() == 0)
68 { std::cerr <<
"tde4_ldp_anamorphic_deg_4_rotate_squeeze_xy::initializeParameters, error: Squeeze-Y is 0." << std::endl; }
69 _pa_rot.
set(_pa,_rotation);
70 _anamorphic.prepare();
71 if(_debugging_enabled && _debugging_fout.is_open())
73 _debugging_fout <<
"initializeParameters()" << std::endl;
77 bool getNumParameters(
int& n)
82 bool getParameterName(
int i,
char* identifier)
84 strcpy(identifier,_para[i]);
87 bool setParameterValue(
const char *identifier,
double v)
91 if(_debugging_enabled && _debugging_fout.is_open())
92 { _debugging_fout <<
"setParameterValue(\"" << identifier <<
"\"," << v <<
")" << std::endl; }
94 if(bt::set_builtin_parameter_value(identifier,v))
96 if(!decypher(identifier,i))
108 { bt::no_longer_uptodate_lut(); }
115 bool setParameterValue(
const char *identifier,
const char* t)
117 typedef base_type bt;
119 if(_debugging_enabled && _debugging_fout.is_open())
120 { _debugging_fout <<
"setParameterValue(\"" << identifier <<
"\",\"" << t <<
"\")" << std::endl; }
122 if(!decypher(identifier,i))
131 if(_squeeze_x.get_sq() != v)
132 { bt::no_longer_uptodate_lut(); }
133 _squeeze_x.set_sq(v);
140 if(_squeeze_y.get_sq() != v)
141 { bt::no_longer_uptodate_lut(); }
142 _squeeze_y.set_sq(v);
148 if(_debugging_filename != t)
150 _debugging_fout.close();
151 _debugging_filename = t;
164 bool setParameterValue(
const char *identifier,
bool v)
166 typedef base_type bt;
168 if(_debugging_enabled && _debugging_fout.is_open())
169 { _debugging_fout <<
"setParameterValue(\"" << identifier <<
"\"," << v <<
")" << std::endl; }
171 if(!decypher(identifier,i))
178 _debugging_enabled = v;
184 bool setParameterValue(
const char *identifier,
int v)
186 typedef base_type bt;
188 if(_debugging_enabled && _debugging_fout.is_open())
189 { _debugging_fout <<
"setParameterValue(\"" << identifier <<
"\"," << v <<
")" << std::endl; }
191 if(!decypher(identifier,i))
204 virtual bool undistort(
double x0,
double y0,
double &x1,
double &y1)
206 typedef base_type bt;
207 vec2_type q = bt::map_dn_to_unit(
208 _rot_sqx_sqy_pa.
eval(
211 bt::map_unit_to_dn(vec2_type(x0,y0))))));
216 virtual bool distort(
double x0,
double y0,
double &x1,
double &y1)
218 typedef base_type bt;
225 if(!bt::is_uptodate_lut())
228 if(!bt::is_uptodate_lut())
235 vec2_type qs = bt::get_lut().get_initial_value(vec2_type(x0,y0));
237 vec2_type q = bt::map_dn_to_unit(
241 bt::map_unit_to_dn(vec2_type(x0,y0))),
243 bt::map_unit_to_dn(qs)))));
248 virtual bool distort(
double x0,
double y0,
double x1_start,
double y1_start,
double &x1,
double &y1)
250 typedef base_type bt;
251 vec2_type q = bt::map_dn_to_unit(
255 bt::map_unit_to_dn(vec2_type(x0,y0))),
257 bt::map_unit_to_dn(vec2_type(x1_start,y1_start))))));
270 #ifdef LDPK_COMPILE_AS_PLUGIN_SDV 271 strcpy(name,
"3DE4 All Parameter Types [Plugin]");
273 strcpy(name,
"3DE4 All Parameter Types");
279 typedef base_type bt;
281 if(bt::get_builtin_parameter_type(identifier,ptype))
return true;
282 if(!decypher(identifier,i))
return false;
287 ptype = TDE4_LDP_ADJUSTABLE_DOUBLE;
break;
290 ptype = TDE4_LDP_DOUBLE;
break;
293 ptype = TDE4_LDP_STRING;
break;
295 ptype = TDE4_LDP_FILE;
break;
297 ptype = TDE4_LDP_TOGGLE;
break;
299 ptype = TDE4_LDP_INT;
break;
305 typedef base_type bt;
307 if(!decypher(identifier,i))
return false;
323 typedef base_type bt;
325 if(!decypher(identifier,i))
return false;
344 typedef base_type bt;
346 if(!decypher(identifier,i))
return false;
359 typedef base_type bt;
361 if(!decypher(identifier,i))
return false;
374 typedef base_type bt;
376 if(!decypher(identifier,i))
return false;
384 typedef base_type bt;
385 mat2_type m = _rot_sqx_sqy_pa.
get_mat()
388 bt::map_unit_to_dn(vec2_type(x0,y0))))
390 mat2_type u2d(bt::w_fb_cm() / bt::r_fb_cm(),0.0,0.0,bt::h_fb_cm() / bt::r_fb_cm());
391 mat2_type d2u(bt::r_fb_cm() / bt::w_fb_cm(),0.0,0.0,bt::r_fb_cm() / bt::h_fb_cm());
393 m00 = m[0][0];m01 = m[0][1];m10 = m[1][0];m11 = m[1][1];
398 template <
class VEC2,
class MAT2>
400 "Par - Adjustable Double [Cx02]",
401 "Par - Adjustable Double [Cy02]",
402 "Par - Double [Cx22]",
403 "Par - Double [Cy22]",
404 "Par - String [Squeeze-X]",
405 "Par - String [Squeeze-Y]",
406 "Par - File [Debug Output]",
407 "Par - Toggle [Debugging On/Off]",
bool getJacobianMatrix(double x0, double y0, double &m00, double &m01, double &m10, double &m11)
Tested against difference quotients.
Definition: tde4_ldp_all_par_types.h:382
virtual mat2_type jacobi(const vec2_type &p_dn) const
Jacobi-Matrix. The result is a matrix g_{ij} = d/dp_j f(p)_i, where f represents the undistort-functi...
Definition: ldpk_generic_distortion_base.h:109
vec2_type eval(const vec2_type &p) const
eval() is per definition removal of lens distortion (undistort).
Definition: ldpk_linear_extender.h:65
Example plugin class containing one parameter of each type. The main purpose of this model is to test...
Definition: tde4_ldp_all_par_types.h:19
bool getParameterDefaultValue(const char *identifier, double &v)
returns default value for given parameter (maximum length of "char *v": 1000 bytes)......
Definition: tde4_ldp_all_par_types.h:303
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_all_par_types.h:277
vec2_type eval(const vec2_type &p) const
Same as method instead of operator.
Definition: ldpk_generic_distortion_base.h:104
void set_coeff(int i, double q)
Set coefficient as demanded by base class.
Definition: ldpk_generic_anamorphic_distortion.h:77
bool getParameterRange(const char *identifier, double &a, double &b)
returns range for adjustable double parameters...
Definition: tde4_ldp_all_par_types.h:372
const mat2_type & get_mat_inv() const
The inverse matrix for this extender.
Definition: ldpk_linear_extender.h:77
void set(const mat2_type &m)
Passing the matrix.
Definition: ldpk_linear_extender.h:24
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
const mat2_type & get_mat() const
The matrix for this extender.
Definition: ldpk_linear_extender.h:74
virtual vec2_type map_inverse(const vec2_type &q) const
Inverse mapping by solving the fixed point equation without providing initial values. Virtual, because the derived class might use some smart data structure for calculating an initial value.
Definition: ldpk_generic_distortion_base.h:122
vec2_type eval_inv(const vec2_type &q) const
eval_inv() is applying lens distortion (distort)
Definition: ldpk_linear_extender.h:68
double get_coeff(int i) const
Get coefficient as demanded by base class.
Definition: ldpk_generic_anamorphic_distortion.h:71
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_all_par_types.h:268