15 #define TDE4_LDP_VERSION "1.0.8" 25 TDE4_LDP_ADJUSTABLE_DOUBLE = 5
35 const char* getVersionString()
const 36 {
return TDE4_LDP_VERSION; }
49 virtual bool getParameterType(
const char *identifier, tde4_ldp_ptype &type) = 0;
55 std::cerr <<
"getParameterDefaultValue(" << identifier <<
",char*): unimplemented method." << std::endl;
61 std::cerr <<
"getParameterDefaultValue(" << identifier <<
",int&): unimplemented method." << std::endl;
67 std::cerr <<
"getParameterDefaultValue(" << identifier <<
",bool&): unimplemented method." << std::endl;
81 std::cerr <<
"setParameterValue(" << identifier <<
",const char* " << v <<
"): unimplemented method." << std::endl;
86 std::cerr <<
"setParameterValue(" << identifier <<
",int " << v <<
"): unimplemented method." << std::endl;
91 std::cerr <<
"setParameterValue(" << identifier <<
",bool " << v <<
"): unimplemented method." << std::endl;
99 virtual bool undistort(
double x0,
double y0,
double &x1,
double &y1) = 0;
100 virtual bool distort(
double x0,
double y0,
double &x1,
double &y1) = 0;
103 virtual bool distort(
double x0,
double y0,
double x1_start ,
double y1_start,
double &x1,
double &y1) {
return distort(x0,y0,x1,y1); }
115 double eps = 1e-4,x00,x10,x01,x11,y00,y10,y01,y11;
120 m00 = (x01 - x00) / (2.0 * eps);
121 m01 = (x11 - x10) / (2.0 * eps);
122 m10 = (y01 - y00) / (2.0 * eps);
123 m11 = (y11 - y10) / (2.0 * eps);
128 virtual bool getJacobianMatrix(
double x0,
double y0,
double &m00,
double &m01,
double &m10,
double &m11)
137 double eps = 1e-4,x00,x10,x01,x11,y00,y10,y01,y11;
138 ok &=
undistort(x0 - eps,y0 - eps,x00,y00);
139 ok &=
undistort(x0 + eps,y0 - eps,x10,y10);
140 ok &=
undistort(x0 - eps,y0 + eps,x01,y01);
141 ok &=
undistort(x0 + eps,y0 + eps,x11,y11);
142 t0 = (x11 - x01 - x10 + x00) / (4.0 * eps * eps);
143 t1 = (y11 - y01 - y10 + y00) / (4.0 * eps * eps);
147 virtual void getBoundingBoxUndistort(
double xa_in,
double ya_in,
double xb_in,
double yb_in,
double& xa_out,
double& ya_out,
double& xb_out,
double& yb_out,
int nx = 32,
int ny = 32)
153 double dx_in = xb_in - xa_in,dy_in = yb_in - ya_in;
155 for(
int ix = 0;ix < nx;++ix)
157 double xa = xa_in + dx_in * double(ix ) / nx;
158 double xb = xa_in + dx_in * double(ix + 1) / nx;
159 accumulate_undistort(xa,ya_in,xa_out,ya_out,xb_out,yb_out);
160 accumulate_undistort(xb,yb_in,xa_out,ya_out,xb_out,yb_out);
162 for(
int iy = 0;iy < ny;++iy)
164 double ya = ya_in + dy_in * double(iy + 1) / ny;
165 double yb = ya_in + dy_in * double(iy ) / ny;
166 accumulate_undistort(xa_in,ya,xa_out,ya_out,xb_out,yb_out);
167 accumulate_undistort(xb_in,yb,xa_out,ya_out,xb_out,yb_out);
171 virtual void getBoundingBoxDistort(
double xa_in,
double ya_in,
double xb_in,
double yb_in,
double& xa_out,
double& ya_out,
double& xb_out,
double& yb_out,
int nx = 32,
int ny = 32)
177 double dx_in = xb_in - xa_in,dy_in = yb_in - ya_in;
179 for(
int ix = 0;ix < nx;++ix)
181 double xa = xa_in + dx_in * double(ix ) / nx;
182 double xb = xa_in + dx_in * double(ix + 1) / nx;
183 accumulate_distort(xa,ya_in,xa_out,ya_out,xb_out,yb_out);
184 accumulate_distort(xb,yb_in,xa_out,ya_out,xb_out,yb_out);
186 for(
int iy = 0;iy < ny;++iy)
188 double ya = ya_in + dy_in * double(iy + 1) / ny;
189 double yb = ya_in + dy_in * double(iy ) / ny;
190 accumulate_distort(xa_in,ya,xa_out,ya_out,xb_out,yb_out);
191 accumulate_distort(xb_in,yb,xa_out,ya_out,xb_out,yb_out);
196 void accumulate_undistort(
double x0,
double y0,
double& xa_out,
double& ya_out,
double& xb_out,
double& yb_out)
200 xa_out = std::min(xa_out,x1);
201 ya_out = std::min(ya_out,y1);
202 xb_out = std::max(xb_out,x1);
203 yb_out = std::max(yb_out,y1);
205 void accumulate_distort(
double x0,
double y0,
double& xa_out,
double& ya_out,
double& xb_out,
double& yb_out)
208 distort(x0,y0,x1,y1);
209 xa_out = std::min(xa_out,x1);
210 ya_out = std::min(ya_out,y1);
211 xb_out = std::max(xb_out,x1);
212 yb_out = std::max(yb_out,y1);
virtual bool undistort(double x0, double y0, double &x1, double &y1)=0
warp/unwarp 2D points...
virtual bool getParameterDefaultValue(const char *identifier, double &v)=0
returns default value for given parameter (maximum length of "char *v": 1000 bytes)......
virtual bool initializeParameters()=0
prepare the current set of parameters...
virtual bool getParameterRange(const char *identifier, double &a, double &b)=0
returns range for adjustable double parameters...
virtual bool getModelName(char *model)=0
returns a name for the model as to show up in the GUI (maximum length of "name": 100 bytes)...
virtual bool getTwistVector(double x0, double y0, double &t0, double &t1)
calculate the mixed derivatives ("twist vector") of the undistort()-Method. Overwrite this...
Definition: tde4_ld_plugin.h:134
virtual void getBoundingBoxUndistort(double xa_in, double ya_in, double xb_in, double yb_in, double &xa_out, double &ya_out, double &xb_out, double &yb_out, int nx=32, int ny=32)
Iterate around the specified box, undistort the points and compute the bounding box.
Definition: tde4_ld_plugin.h:147
Lens Distortion Plugin Base Class.
Definition: tde4_ld_plugin.h:29
virtual bool providesParameterDerivatives()
parameter derivatives to be used for distortion grid controls' matrix calculation routine...
Definition: tde4_ld_plugin.h:106
virtual bool getParameterName(int i, char *identifier)=0
returns "identifier" name of parameter "i" (maximum length of "identifier": 100 bytes)...
virtual bool setParameterValue(const char *identifier, double v)=0
set parameter values... parameters predefined by 3DE4: "tde4_focal_length_cm", "tde4_filmback_width_c...
virtual bool distort(double x0, double y0, double x1_start, double y1_start, double &x1, double &y1)
potentially more efficient function which uses initial values...
Definition: tde4_ld_plugin.h:103
virtual bool calcParameterDerivatives(double x, double y, int num_parameters, double *dx_dy)
dx_dy is an array with 2 * num_parameters elements (x- and y- component for each of n derivatives) ...
Definition: tde4_ld_plugin.h:108
virtual void getBoundingBoxDistort(double xa_in, double ya_in, double xb_in, double yb_in, double &xa_out, double &ya_out, double &xb_out, double &yb_out, int nx=32, int ny=32)
Iterate around the specified box, distort the points and compute the bounding box.
Definition: tde4_ld_plugin.h:171
virtual bool getJacobianMatrix(double x0, double y0, double &m00, double &m01, double &m10, double &m11)
calculate the Jacobian matrix of the undistort()-Method. Overwrite this, if you know the Jacobian for...
Definition: tde4_ld_plugin.h:128
bool getJacobianMatrixDQ(double x0, double y0, double &m00, double &m01, double &m10, double &m11)
calculate the Jacobian matrix of the undistort()-Method by means of difference quotients. This is the default implementation. Also use it for testing your own implementation of getJacobianMatrix().
Definition: tde4_ld_plugin.h:112
virtual bool getParameterType(const char *identifier, tde4_ldp_ptype &type)=0
returns type of given parameter... The method should return false, if the parameter addressed by iden...
virtual bool getNumParameters(int &n)=0
returns the number of plugin parameters...