15 #define TDE4_LDP_VERSION "1.0.8"
18 enum tde4_ldp_ptype { TDE4_LDP_STRING=0, TDE4_LDP_DOUBLE=1, TDE4_LDP_INT=2, TDE4_LDP_FILE=3, TDE4_LDP_TOGGLE=4, TDE4_LDP_ADJUSTABLE_DOUBLE=5 };
27 const char* getVersionString()
const
28 {
return TDE4_LDP_VERSION; }
41 virtual bool getParameterType(
const char *identifier, tde4_ldp_ptype &type) = 0;
47 std::cerr <<
"getParameterDefaultValue(" << identifier <<
",char*): unimplemented method." << std::endl;
53 std::cerr <<
"getParameterDefaultValue(" << identifier <<
",int&): unimplemented method." << std::endl;
59 std::cerr <<
"getParameterDefaultValue(" << identifier <<
",bool&): unimplemented method." << std::endl;
73 std::cerr <<
"setParameterValue(" << identifier <<
",const char* " << v <<
"): unimplemented method." << std::endl;
78 std::cerr <<
"setParameterValue(" << identifier <<
",int " << v <<
"): unimplemented method." << std::endl;
83 std::cerr <<
"setParameterValue(" << identifier <<
",bool " << v <<
"): unimplemented method." << std::endl;
91 virtual bool undistort(
double x0,
double y0,
double &x1,
double &y1) = 0;
92 virtual bool distort(
double x0,
double y0,
double &x1,
double &y1) = 0;
95 virtual bool distort(
double x0,
double y0,
double x1_start ,
double y1_start,
double &x1,
double &y1) {
return distort(x0,y0,x1,y1); }
107 double eps = 1e-4,x00,x10,x01,x11,y00,y10,y01,y11;
112 m00 = (x01 - x00) / (2.0 * eps);
113 m01 = (x11 - x10) / (2.0 * eps);
114 m10 = (y01 - y00) / (2.0 * eps);
115 m11 = (y11 - y10) / (2.0 * eps);
120 virtual bool getJacobianMatrix(
double x0,
double y0,
double &m00,
double &m01,
double &m10,
double &m11)
129 double eps = 1e-4,x00,x10,x01,x11,y00,y10,y01,y11;
130 ok &=
undistort(x0 - eps,y0 - eps,x00,y00);
131 ok &=
undistort(x0 + eps,y0 - eps,x10,y10);
132 ok &=
undistort(x0 - eps,y0 + eps,x01,y01);
133 ok &=
undistort(x0 + eps,y0 + eps,x11,y11);
134 t0 = (x11 - x01 - x10 + x00) / (4.0 * eps * eps);
135 t1 = (y11 - y01 - y10 + y00) / (4.0 * eps * eps);
139 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)
145 double dx_in = xb_in - xa_in,dy_in = yb_in - ya_in;
147 for(
int ix = 0;ix < nx;++ix)
149 double xa = xa_in + dx_in * double(ix ) / nx;
150 double xb = xa_in + dx_in * double(ix + 1) / nx;
151 accumulate_undistort(xa,ya_in,xa_out,ya_out,xb_out,yb_out);
152 accumulate_undistort(xb,yb_in,xa_out,ya_out,xb_out,yb_out);
154 for(
int iy = 0;iy < ny;++iy)
156 double ya = ya_in + dy_in * double(iy + 1) / ny;
157 double yb = ya_in + dy_in * double(iy ) / ny;
158 accumulate_undistort(xa_in,ya,xa_out,ya_out,xb_out,yb_out);
159 accumulate_undistort(xb_in,yb,xa_out,ya_out,xb_out,yb_out);
163 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)
169 double dx_in = xb_in - xa_in,dy_in = yb_in - ya_in;
171 for(
int ix = 0;ix < nx;++ix)
173 double xa = xa_in + dx_in * double(ix ) / nx;
174 double xb = xa_in + dx_in * double(ix + 1) / nx;
175 accumulate_distort(xa,ya_in,xa_out,ya_out,xb_out,yb_out);
176 accumulate_distort(xb,yb_in,xa_out,ya_out,xb_out,yb_out);
178 for(
int iy = 0;iy < ny;++iy)
180 double ya = ya_in + dy_in * double(iy + 1) / ny;
181 double yb = ya_in + dy_in * double(iy ) / ny;
182 accumulate_distort(xa_in,ya,xa_out,ya_out,xb_out,yb_out);
183 accumulate_distort(xb_in,yb,xa_out,ya_out,xb_out,yb_out);
188 void accumulate_undistort(
double x0,
double y0,
double& xa_out,
double& ya_out,
double& xb_out,
double& yb_out)
192 xa_out = std::min(xa_out,x1);
193 ya_out = std::min(ya_out,y1);
194 xb_out = std::max(xb_out,x1);
195 yb_out = std::max(yb_out,y1);
197 void accumulate_distort(
double x0,
double y0,
double& xa_out,
double& ya_out,
double& xb_out,
double& yb_out)
200 distort(x0,y0,x1,y1);
201 xa_out = std::min(xa_out,x1);
202 ya_out = std::min(ya_out,y1);
203 xb_out = std::max(xb_out,x1);
204 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:126
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:139
Lens Distortion Plugin Base Class.
Definition: tde4_ld_plugin.h:21
virtual bool providesParameterDerivatives()
parameter derivatives to be used for distortion grid controls' matrix calculation routine...
Definition: tde4_ld_plugin.h:98
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:95
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:100
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:163
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:120
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:104
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...