44 #include <visp/vpBasicFeature.h>
45 #include <visp/vpFeatureSegment.h>
46 #include <visp/vpImagePoint.h>
47 #include <visp/vpMeterPixelConversion.h>
48 #include <visp/vpMath.h>
49 #include <visp/vpDisplay.h>
53 #include <visp/vpException.h>
54 #include <visp/vpMatrixException.h>
57 #include <visp/vpDebug.h>
92 : xc_(0), yc_(0), l_(0), alpha_(0), Z1_(0), Z2_(0), cos_a_(0), sin_a_(0), normalized_(normalized)
206 if (
flags[i] ==
false)
210 vpTRACE(
"Warning !!! The interaction matrix is computed but xc was not set yet");
213 vpTRACE(
"Warning !!! The interaction matrix is computed but Yc was not set yet");
216 vpTRACE(
"Warning !!! The interaction matrix is computed but l was not set yet");
219 vpTRACE(
"Warning !!! The interaction matrix is computed but alpha was not set yet");
222 vpTRACE(
"Warning !!! The interaction matrix is computed but Z1 was not set yet");
225 vpTRACE(
"Warning !!! The interaction matrix is computed but Z2 was not set yet");
228 vpTRACE(
"Problem during the reading of the variable flags");
235 double lambda1 = (Z1_-Z2_)/(Z1_*Z2_);
236 double lambda2 = (Z1_+Z2_)/(2*Z1_*Z2_);
244 double lambda = -lambda1 * ln;
245 double Zn_inv = lambda2 * ln;
246 double lc = cos_a_ / ln;
247 double ls = sin_a_ / ln;
248 double xnalpha = xn*cos_a_+yn*sin_a_;
249 double lnc = cos_a_ * ln;
250 double lns = sin_a_ * ln;
254 Lxn[0][0] = -Zn_inv + lambda * xn * cos_a_;
255 Lxn[0][1] = lambda * xn * sin_a_ ;
256 Lxn[0][2] = lambda1 * (xn*xnalpha - cos_a_ /4.);
257 Lxn[0][3] = sin_a_*cos_a_/4/ln - xn*xnalpha*sin_a_/ln;
258 Lxn[0][4] = -ln*(1.+lc*lc/4.) + xn*xnalpha*cos_a_/ln ;
265 Lyn[0][0] = lambda*yn*cos_a_ ;
266 Lyn[0][1] = -Zn_inv + lambda*yn*sin_a_ ;
267 Lyn[0][2] = lambda1 * (yn*xnalpha - sin_a_/4.);
268 Lyn[0][3] = ln*(1+ls*ls/4.)-yn*xnalpha*sin_a_/ln ;
269 Lyn[0][4] = -sin_a_*cos_a_/4/ln + yn*xnalpha*cos_a_/ln;
276 Lln[0][0] = lambda * lnc ;
277 Lln[0][1] = lambda * lns ;
278 Lln[0][2] = -(Zn_inv + lambda*xnalpha);
279 Lln[0][3] = -yn-xnalpha*sin_a_ ;
280 Lln[0][4] = xn + xnalpha*cos_a_ ;
287 Lalpha[0][0] = -lambda1*sin_a_*l_ ;
288 Lalpha[0][1] = lambda1*cos_a_*l_ ;
289 Lalpha[0][2] = lambda1*(xc_*sin_a_-yc_*cos_a_);
290 Lalpha[0][3] = (-xc_*sin_a_*sin_a_+yc_*cos_a_*sin_a_)/l_;
291 Lalpha[0][4] = (xc_*cos_a_*sin_a_ - yc_*cos_a_*cos_a_)/l_ ;
300 Lxc[0][0] = -lambda2 ;
302 Lxc[0][2] = lambda2*xc_ - lambda1*l_*cos_a_/4.;
303 Lxc[0][3] = xc_*yc_ + l_*l_*cos_a_*sin_a_/4. ;
304 Lxc[0][4] = -(1+xc_*xc_+l_*l_*cos_a_*cos_a_/4.) ;
312 Lyc[0][1] = -lambda2 ;
313 Lyc[0][2] = lambda2*yc_ - lambda1*l_*sin_a_/4.;
314 Lyc[0][3] = 1+yc_*yc_+l_*l_*sin_a_*sin_a_/4. ;
315 Lyc[0][4] = -xc_*yc_-l_*l_*cos_a_*sin_a_/4. ;
322 Ll[0][0] = lambda1*cos_a_ ;
323 Ll[0][1] = lambda1*sin_a_ ;
324 Ll[0][2] = lambda2*l_-lambda1*(xc_*cos_a_+yc_*sin_a_);
325 Ll[0][3] = l_*(xc_*cos_a_*sin_a_ + yc_*(1+sin_a_*sin_a_)) ;
326 Ll[0][4] = -l_*(xc_*(1+cos_a_*cos_a_)+yc_*cos_a_*sin_a_) ;
332 Lalpha[0][0] = -lambda1*sin_a_/l_ ;
333 Lalpha[0][1] = lambda1*cos_a_/l_ ;
334 Lalpha[0][2] = lambda1*(xc_*sin_a_-yc_*cos_a_)/l_;
335 Lalpha[0][3] = -xc_*sin_a_*sin_a_+yc_*cos_a_*sin_a_;
336 Lalpha[0][4] = xc_*cos_a_*sin_a_ - yc_*cos_a_*cos_a_ ;
376 exc[0] = xc_-s_star[0];
382 eyc[0] = yc_ - s_star[1];
388 eL[0] = l_ - s_star[2];
394 eAlpha[0] = alpha_ - s_star[3];
395 while (eAlpha[0] < -M_PI) eAlpha[0] += 2*M_PI ;
396 while (eAlpha[0] > M_PI) eAlpha[0] -= 2*M_PI ;
431 std::cout <<
"vpFeatureSegment: (";
434 std::cout <<
"xn = ";
436 std::cout <<
"xc = ";
437 std::cout <<
s[0] <<
"; ";
441 std::cout <<
"yn = ";
443 std::cout <<
"yc = ";
444 std::cout <<
s[1] <<
"; ";
448 std::cout <<
"ln = ";
451 std::cout <<
s[2] <<
"; ";
456 std::cout <<
")" << std::endl;
492 unsigned int thickness )
const
506 double x1 = x - (l/2.)*cos_a_;
507 double x2 = x + (l/2.)*cos_a_;
509 double y1 = y - (l/2.)*sin_a_;
510 double y2 = y + (l/2.)*sin_a_;
534 unsigned int thickness )
const
548 double x1 = x - (l/2.)*cos_a_;
549 double x2 = x + (l/2.)*cos_a_;
551 double y1 = y - (l/2.)*sin_a_;
552 double y2 = y + (l/2.)*sin_a_;
581 const double x2,
const double y2,
const double Z2)
583 double l = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
584 double x_c = (x1+x2)/2.;
585 double y_c = (y1+y2)/2.;
586 double alpha = atan2(y1-y2,x1-x2);
virtual void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
Definition of the vpMatrix class.
bool * flags
Ensure that all the parameters needed to compute the iteraction matrix are set.
static unsigned int selectL()
vpColVector error(const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL)
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
void setAlpha(const double val)
static unsigned int selectYc()
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Point coordinates conversion from normalized coordinates in meter to pixel coordinates ...
Class to define colors available for display functionnalities.
static unsigned int selectAlpha()
unsigned int dim_s
Dimension of the visual feature.
void setL(const double val)
void setZ1(const double val)
class that defines what is a visual feature
static const vpColor cyan
void setZ2(const double val)
Class that defines a 2D segment visual features. This class allow to consider two sets of visual feat...
Generic class defining intrinsic camera parameters.
vpFeatureSegment(bool normalized=false)
void stackMatrices(const vpMatrix &A)
void setYc(const double val)
void buildFrom(const double x1, const double y1, const double Z1, const double x2, const double y2, const double Z2)
vpBasicFeatureDeallocatorType deallocate
static double deg(double rad)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
static const vpColor yellow
vpFeatureSegment * duplicate() const
Feature duplication.
void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const
unsigned int nbParameters
Number of parameters needed to compute the interaction matrix.
static unsigned int selectXc()
vpColVector s
State of the visual feature.
void resize(const unsigned int i, const bool flagNullify=true)
void setXc(const double val)
void print(const unsigned int select=FEATURE_ALL) const