1 #ifndef tde4_ldp_anamorphic_deg_4_rotate_squeeze_xy_xy_sdv
2 #define tde4_ldp_anamorphic_deg_4_rotate_squeeze_xy_xy_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>
11 #define M_PI 3.1415926535
17 template <
class VEC2,
class MAT2>
21 typedef VEC2 vec2_type;
22 typedef MAT2 mat2_type;
37 static const char* _para[13];
39 bool decypher(
const char* name,
int& i)
46 if(0 == strcmp(name,_para[i]))
53 bool initializeParameters()
56 bt::check_builtin_parameters();
60 _rot_sqx_sqy_pa.
set(_rotation,_squeeze_x,_squeeze_y,_pa);
61 if(_squeeze_x.get_sq() == 0)
62 { std::cerr <<
"tde4_ldp_anamorphic_deg_4_rotate_squeeze_xy::initializeParameters, error: Squeeze-X is 0." << std::endl; }
63 if(_squeeze_y.get_sq() == 0)
64 { std::cerr <<
"tde4_ldp_anamorphic_deg_4_rotate_squeeze_xy::initializeParameters, error: Squeeze-Y is 0." << std::endl; }
65 _pa_rot.
set(_pa,_rotation);
66 _anamorphic.prepare();
69 bool getNumParameters(
int& n)
74 bool getParameterName(
int i,
char* identifier)
76 strcpy(identifier,_para[i]);
79 bool setParameterValue(
const char *identifier,
double v)
84 if(bt::set_builtin_parameter_value(identifier,v))
88 if(!decypher(identifier,i))
95 { bt::no_longer_uptodate_lut(); }
100 if(_rotation.
get_phi() != v / 180.0 * M_PI)
101 { bt::no_longer_uptodate_lut(); }
102 _rotation.
set_phi(v / 180.0 * M_PI);
106 if(_squeeze_x.get_sq() != v)
107 { bt::no_longer_uptodate_lut(); }
108 _squeeze_x.set_sq(v);
112 if(_squeeze_y.get_sq() != v)
113 { bt::no_longer_uptodate_lut(); }
114 _squeeze_y.set_sq(v);
120 virtual bool undistort(
double x0,
double y0,
double &x1,
double &y1)
123 vec2_type q = bt::map_dn_to_unit(
124 _rot_sqx_sqy_pa.
eval(
127 bt::map_unit_to_dn(vec2_type(x0,y0))))));
150 virtual bool distort(
double x0,
double y0,
double &x1,
double &y1)
159 if(!bt::is_uptodate_lut())
162 if(!bt::is_uptodate_lut())
170 vec2_type qs = bt::get_lut().get_initial_value(vec2_type(x0,y0));
173 vec2_type q = bt::map_dn_to_unit(
177 bt::map_unit_to_dn(vec2_type(x0,y0))),
179 bt::map_unit_to_dn(qs)))));
228 virtual bool distort(
double x0,
double y0,
double x1_start,
double y1_start,
double &x1,
double &y1)
231 vec2_type q = bt::map_dn_to_unit(
235 bt::map_unit_to_dn(vec2_type(x0,y0))),
237 bt::map_unit_to_dn(vec2_type(x1_start,y1_start))))));
273 #ifdef LDPK_COMPILE_AS_PLUGIN_SDV
274 strcpy(name,
"3DE4 Anamorphic - Standard, Degree 4 [Plugin]");
276 strcpy(name,
"3DE4 Anamorphic - Standard, Degree 4");
284 if(bt::get_builtin_parameter_type(identifier,ptype))
return true;
285 if(!decypher(identifier,i))
return false;
286 ptype = TDE4_LDP_ADJUSTABLE_DOUBLE;
293 if(!decypher(identifier,i))
return false;
298 else if((i == 11) || (i == 12))
308 if(!decypher(identifier,i))
return false;
320 else if((i == 11) || (i == 12))
328 std::cerr <<
"getParameterRange: i out of range" << std::endl;
336 mat2_type m = _rot_sqx_sqy_pa.
get_mat()
339 bt::map_unit_to_dn(vec2_type(x0,y0))))
341 mat2_type u2d(bt::w_fb_cm() / bt::r_fb_cm(),0.0,0.0,bt::h_fb_cm() / bt::r_fb_cm());
342 mat2_type d2u(bt::r_fb_cm() / bt::w_fb_cm(),0.0,0.0,bt::r_fb_cm() / bt::h_fb_cm());
344 m00 = m[0][0];m01 = m[0][1];m10 = m[1][0];m11 = m[1][1];
349 template <
class VEC2,
class MAT2>
351 "Cx02 - Degree 2",
"Cy02 - Degree 2",
352 "Cx22 - Degree 2",
"Cy22 - Degree 2",
354 "Cx04 - Degree 4",
"Cy04 - Degree 4",
355 "Cx24 - Degree 4",
"Cy24 - Degree 4",
356 "Cx44 - Degree 4",
"Cy44 - Degree 4",
358 "Lens Rotation",
"Squeeze-X",
"Squeeze-Y"
bool getParameterDefaultValue(const char *identifier, double &v)
returns default value for given parameter (maximum length of "char *v": 1000 bytes)......
Definition: tde4_ldp_anamorphic_deg_4_rotate_squeeze_xy.h:289
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:51
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_anamorphic_deg_4_rotate_squeeze_xy.h:280
vec2_type eval(const vec2_type &p) const
Same as method instead of operator.
Definition: ldpk_generic_distortion_base.h:104
bool getJacobianMatrix(double x0, double y0, double &m00, double &m01, double &m10, double &m11)
Tested against difference quotients.
Definition: tde4_ldp_anamorphic_deg_4_rotate_squeeze_xy.h:333
void set_coeff(int i, double q)
Set coefficient as demanded by base class.
Definition: ldpk_generic_anamorphic_distortion.h:77
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_anamorphic_deg_4_rotate_squeeze_xy.h:271
double get_phi() const
Getter.
Definition: ldpk_rotation_extender.h:36
const mat2_type & get_mat_inv() const
The inverse matrix for this extender.
Definition: ldpk_linear_extender.h:63
void set(const mat2_type &m)
Passing the matrix.
Definition: ldpk_linear_extender.h:24
bool getParameterRange(const char *identifier, double &a, double &b)
returns range for adjustable double parameters...
Definition: tde4_ldp_anamorphic_deg_4_rotate_squeeze_xy.h:304
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:60
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:54
double get_coeff(int i) const
Get coefficient as demanded by base class.
Definition: ldpk_generic_anamorphic_distortion.h:71
void set_phi(double phi)
The rotation extender has one parameter called phi (in radians).
Definition: ldpk_rotation_extender.h:29
Definition: tde4_ldp_anamorphic_deg_4_rotate_squeeze_xy.h:18