45 #include <visp/vpConfig.h>
52 #include <visp/vpMbtDistanceCylinder.h>
53 #include <visp/vpPlane.h>
54 #include <visp/vpMeterPixelConversion.h>
55 #include <visp/vpPixelMeterConversion.h>
56 #include <visp/vpFeatureBuilder.h>
57 #include <visp/vpFeatureEllipse.h>
61 #include <visp/vpPose.h>
67 : name(), index(0), cam(), me(NULL), alpha(0), wmean1(1), wmean2(1),
68 featureline1(), featureline2(), meline1(NULL), meline2(NULL),
69 cercle1(NULL), cercle2(NULL), radius(0), p1(NULL), p2(NULL), L(),
70 error(), nbFeature(0), nbFeaturel1(0), nbFeaturel2(0), Reinit(false),
82 if (
p1 != NULL)
delete p1 ;
83 if (
p2 != NULL)
delete p2 ;
84 if (
c != NULL)
delete c ;
183 vpMbtDistanceCylinder::getCylinderLineExtremity(
double &i,
double &j,
double rho,
double theta,
187 double px = cam.
get_px() ;
188 double py = cam.
get_py() ;
189 double u0 = cam.
get_u0() ;
190 double v0 = cam.
get_v0() ;
192 double mu11 = circle->
p[3];
193 double mu02 = circle->
p[4];
194 double mu20 = circle->
p[2];
195 double Xg = u0 + circle->
p[0]*px;
196 double Yg = v0 + circle->
p[1]*py;
201 double stheta = sin(theta);
202 double ctheta = cos(theta);
203 double sctheta = stheta*ctheta;
204 double m11yg = mu11*Yg;
206 double m02xg = mu02*Xg;
207 double m11stheta = mu11*stheta;
208 j = ((mu11*Xg*sctheta-mu20*Yg*sctheta+mu20*rho*ctheta
209 -m11yg+m11yg*ctheta2+m02xg-m02xg*ctheta2+
210 m11stheta*rho)/(mu20*ctheta2+2.0*m11stheta*ctheta
211 +mu02-mu02*ctheta2));
213 double rhom02 = rho*mu02;
214 double sctheta2 = stheta*ctheta2;
215 double ctheta3 = ctheta2*ctheta;
216 i = (-(-rho*mu11*stheta*ctheta-rhom02+rhom02*ctheta2
217 +mu11*Xg*sctheta2-mu20*Yg*sctheta2-ctheta*mu11*Yg
218 +ctheta3*mu11*Yg+ctheta*mu02*Xg-ctheta3*mu02*Xg)/
219 (mu20*ctheta2+2.0*mu11*stheta*ctheta+mu02-
220 mu02*ctheta2)/stheta);
247 catch(...){std::cout<<
"Problem when projecting circle 1\n";}
251 catch(...){std::cout<<
"Problem when projecting circle 2\n";}
272 double i11,i12,i21,i22,j11,j12,j21,j22;
273 getCylinderLineExtremity(i11, j11, rho1, theta1,
cercle1);
274 getCylinderLineExtremity(i12, j12, rho1, theta1,
cercle2);
275 getCylinderLineExtremity(i21, j21, rho2, theta2,
cercle1);
276 getCylinderLineExtremity(i22, j22, rho2, theta2,
cercle2);
294 while (theta1 > M_PI) { theta1 -= M_PI ; }
295 while (theta1 < -M_PI) { theta1 += M_PI ; }
297 if (theta1 < -M_PI/2.0) theta1 = -theta1 - 3*M_PI/2.0;
298 else theta1 = M_PI/2.0 - theta1;
300 while (theta2 > M_PI) { theta2 -= M_PI ; }
301 while (theta2 < -M_PI) { theta2 += M_PI ; }
303 if (theta2 < -M_PI/2.0) theta2 = -theta2 - 3*M_PI/2.0;
304 else theta2 = M_PI/2.0 - theta2;
312 vpTRACE(
"the line can't be initialized");
320 vpTRACE(
"the line can't be initialized");
341 std::cout <<
"Track meline1 failed" << std::endl;
350 std::cout <<
"Track meline2 failed" << std::endl;
382 catch(...){std::cout<<
"Probleme projection cercle 1\n";}
386 catch(...){std::cout<<
"Probleme projection cercle 2\n";}
398 double i11,i12,i21,i22,j11,j12,j21,j22;
400 getCylinderLineExtremity(i11, j11, rho1, theta1,
cercle1);
401 getCylinderLineExtremity(i12, j12, rho1, theta1,
cercle2);
403 getCylinderLineExtremity(i21, j21, rho2, theta2,
cercle1);
404 getCylinderLineExtremity(i22, j22, rho2, theta2,
cercle2);
422 while (theta1 > M_PI) { theta1 -= M_PI ; }
423 while (theta1 < -M_PI) { theta1 += M_PI ; }
425 if (theta1 < -M_PI/2.0) theta1 = -theta1 - 3*M_PI/2.0;
426 else theta1 = M_PI/2.0 - theta1;
428 while (theta2 > M_PI) { theta2 -= M_PI ; }
429 while (theta2 < -M_PI) { theta2 += M_PI ; }
431 if (theta2 < -M_PI/2.0) theta2 = -theta2 - 3*M_PI/2.0;
432 else theta2 = M_PI/2.0 - theta2;
510 catch(...){std::cout<<
"Problem projection circle 1";}
514 catch(...){std::cout<<
"Problem projection circle 2";}
525 double i11,i12,i21,i22,j11,j12,j21,j22;
527 getCylinderLineExtremity(i11, j11, rho1, theta1,
cercle1);
528 getCylinderLineExtremity(i12, j12, rho1, theta1,
cercle2);
530 getCylinderLineExtremity(i21, j21, rho2, theta2,
cercle1);
531 getCylinderLineExtremity(i22, j22, rho2, theta2,
cercle2);
570 catch(...){std::cout<<
"Problem projection circle 1";}
574 catch(...){std::cout<<
"Problem projection circle 2";}
585 double i11,i12,i21,i22,j11,j12,j21,j22;
587 getCylinderLineExtremity(i11, j11, rho1, theta1,
cercle1);
588 getCylinderLineExtremity(i12, j12, rho1, theta1,
cercle2);
590 getCylinderLineExtremity(i21, j21, rho2, theta2,
cercle1);
591 getCylinderLineExtremity(i22, j22, rho2, theta2,
cercle2);
656 catch(...){std::cout<<
"Problem projection circle 1\n";}
660 catch(...){std::cout<<
"Problem projection circle 2\n";}
670 double rho1 = featureline1.
getRho() ;
671 double theta1 = featureline1.
getTheta() ;
672 double rho2 = featureline2.
getRho() ;
673 double theta2 = featureline2.
getTheta() ;
675 double co1 = cos(theta1);
676 double si1 = sin(theta1);
677 double co2 = cos(theta2);
678 double si2 = sin(theta2);
680 double mx = 1.0/cam.
get_px() ;
681 double my = 1.0/cam.
get_py() ;
682 double xc = cam.
get_u0() ;
683 double yc = cam.
get_v0() ;
702 alpha1 = x*si1 - y*co1;
704 double *Lrho = H1[0] ;
705 double *Ltheta = H1[1] ;
707 for (
unsigned int k=0 ; k < 6 ; k++){
708 L[j][k] = (Lrho[k] + alpha1*Ltheta[k]);
710 error[j] = rho1 - ( x*co1 + y*si1) ;
724 alpha2 = x*si2 - y*co2;
726 double *Lrho = H2[0] ;
727 double *Ltheta = H2[1] ;
729 for (
unsigned int k=0 ; k < 6 ; k++){
730 L[j][k] = (Lrho[k] + alpha2*Ltheta[k]);
732 error[j] = rho2 - ( x*co2 + y*si2) ;
void setMovingEdge(vpMe *Me)
Definition of the vpMatrix class.
void displayMovingEdges(const vpImage< unsigned char > &I)
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
vpCylinder * c
The cylinder.
void projection(const vpColVector &_cP, vpColVector &_p)
Projection onto the image plane of a point. Input: the 3D coordinates in the camera frame _cP...
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
void trackMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP)
perspective projection of the circle
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'...
Class to define colors available for display functionnalities.
void track(const vpImage< unsigned char > &I)
double get_oY() const
Get the point Y coordinate in the object frame.
Contains predetermined masks for sites and holds moving edges tracking parameters.
unsigned int nbFeature
The number of moving edges.
Implementation of a line used by the model-based tracker.
void initTracking(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, double rho, double theta)
vpPoint * p1
The first extremity on the axe.
void initInteractionMatrixError()
static void flush(const vpImage< unsigned char > &I)
void display(const vpImage< unsigned char > &, vpColor)
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP)
Class that defines what is a point.
vpMatrix L
The interaction matrix.
static const vpColor orange
unsigned int nbFeaturel1
The number of moving edges on line 1.
void projection()
perspective projection of the circle
void updateParameters(const vpImage< unsigned char > &I, double rho, double theta)
vpCircle * cercle2
The lower circle limiting the cylinder.
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
static double sqr(double x)
void setInitRange(const unsigned int &r)
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
Generic class defining intrinsic camera parameters.
double get_oZ() const
Get the point Z coordinate in the object frame.
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder)
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
std::list< vpMeSite > & getMeList()
static void convertLine(const vpCameraParameters &cam, const double &rho_m, const double &theta_m, double &rho_p, double &theta_p)
line coordinates conversion (rho,theta)
vpPoint * p2
The second extremity on the axe.
double get_oX() const
Get the point X coordinate in the object frame.
Class that defines what is a cylinder.
void initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, const double r)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpColVector error
The error vector.
vpCircle * cercle1
The upper circle limiting the cylinder.
bool Reinit
Indicates if the line has to be reinitialized.
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
double radius
The radius of the cylinder.
void setWorldCoordinates(const vpColVector &oP)
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor col, const unsigned int thickness=1)
unsigned int nbFeaturel2
The number of moving edges on line 2.
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &_cP)
Class that defines what is a circle.
vpMbtMeLine * meline2
The moving edge containers (second line of the cylinder)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo, const vpImage< unsigned char > &I)
void set_ij(const double ii, const double jj)
void setWorldCoordinates(const vpColVector &oP)
void resize(const unsigned int i, const bool flagNullify=true)