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),
71 c(NULL), hiddenface(NULL), index_polygon(-1), isvisible(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);
280 double i11,i12,i21,i22,j11,j12,j21,j22;
281 getCylinderLineExtremity(i11, j11, rho1, theta1,
cercle1);
282 getCylinderLineExtremity(i12, j12, rho1, theta1,
cercle2);
283 getCylinderLineExtremity(i21, j21, rho2, theta2,
cercle1);
284 getCylinderLineExtremity(i22, j22, rho2, theta2,
cercle2);
302 while (theta1 > M_PI) { theta1 -= M_PI ; }
303 while (theta1 < -M_PI) { theta1 += M_PI ; }
305 if (theta1 < -M_PI/2.0) theta1 = -theta1 - 3*M_PI/2.0;
306 else theta1 = M_PI/2.0 - theta1;
308 while (theta2 > M_PI) { theta2 -= M_PI ; }
309 while (theta2 < -M_PI) { theta2 += M_PI ; }
311 if (theta2 < -M_PI/2.0) theta2 = -theta2 - 3*M_PI/2.0;
312 else theta2 = M_PI/2.0 - theta2;
316 meline1->initTracking(I,ip11,ip12,rho1,theta1);
325 meline2->initTracking(I,ip21,ip22,rho2,theta2);
399 catch(...){std::cout<<
"Probleme projection cercle 1\n";}
403 catch(...){std::cout<<
"Probleme projection cercle 2\n";}
415 double i11,i12,i21,i22,j11,j12,j21,j22;
417 getCylinderLineExtremity(i11, j11, rho1, theta1,
cercle1);
418 getCylinderLineExtremity(i12, j12, rho1, theta1,
cercle2);
420 getCylinderLineExtremity(i21, j21, rho2, theta2,
cercle1);
421 getCylinderLineExtremity(i22, j22, rho2, theta2,
cercle2);
439 while (theta1 > M_PI) { theta1 -= M_PI ; }
440 while (theta1 < -M_PI) { theta1 += M_PI ; }
442 if (theta1 < -M_PI/2.0) theta1 = -theta1 - 3*M_PI/2.0;
443 else theta1 = M_PI/2.0 - theta1;
445 while (theta2 > M_PI) { theta2 -= M_PI ; }
446 while (theta2 < -M_PI) { theta2 += M_PI ; }
448 if (theta2 < -M_PI/2.0) theta2 = -theta2 - 3*M_PI/2.0;
449 else theta2 = M_PI/2.0 - theta2;
454 meline1->updateParameters(I,ip11,ip12,rho1,theta1) ;
463 meline2->updateParameters(I,ip21,ip22,rho2,theta2) ;
517 const bool displayFullModel)
532 catch(...){std::cout<<
"Problem projection circle 1";}
536 catch(...){std::cout<<
"Problem projection circle 2";}
547 double i11,i12,i21,i22,j11,j12,j21,j22;
549 getCylinderLineExtremity(i11, j11, rho1, theta1,
cercle1);
550 getCylinderLineExtremity(i12, j12, rho1, theta1,
cercle2);
552 getCylinderLineExtremity(i21, j21, rho2, theta2,
cercle1);
553 getCylinderLineExtremity(i22, j22, rho2, theta2,
cercle2);
581 const bool displayFullModel)
596 catch(...){std::cout<<
"Problem projection circle 1";}
600 catch(...){std::cout<<
"Problem projection circle 2";}
611 double i11,i12,i21,i22,j11,j12,j21,j22;
613 getCylinderLineExtremity(i11, j11, rho1, theta1,
cercle1);
614 getCylinderLineExtremity(i12, j12, rho1, theta1,
cercle2);
616 getCylinderLineExtremity(i21, j21, rho2, theta2,
cercle1);
617 getCylinderLineExtremity(i22, j22, rho2, theta2,
cercle2);
691 catch(...){std::cout<<
"Problem projection circle 1\n";}
695 catch(...){std::cout<<
"Problem projection circle 2\n";}
705 double rho1 = featureline1.
getRho() ;
706 double theta1 = featureline1.
getTheta() ;
707 double rho2 = featureline2.
getRho() ;
708 double theta2 = featureline2.
getTheta() ;
710 double co1 = cos(theta1);
711 double si1 = sin(theta1);
712 double co2 = cos(theta2);
713 double si2 = sin(theta2);
715 double mx = 1.0/cam.
get_px() ;
716 double my = 1.0/cam.
get_py() ;
717 double xc = cam.
get_u0() ;
718 double yc = cam.
get_v0() ;
730 for(std::list<vpMeSite>::const_iterator it=
meline1->getMeList().begin(); it!=
meline1->getMeList().end(); ++it){
737 alpha1 = x*si1 - y*co1;
739 double *Lrho = H1[0] ;
740 double *Ltheta = H1[1] ;
742 for (
unsigned int k=0 ; k < 6 ; k++){
743 L[j][k] = (Lrho[k] + alpha1*Ltheta[k]);
745 error[j] = rho1 - ( x*co1 + y*si1) ;
752 for(std::list<vpMeSite>::const_iterator it=
meline2->getMeList().begin(); it!=
meline2->getMeList().end(); ++it){
759 alpha2 = x*si2 - y*co2;
761 double *Lrho = H2[0] ;
762 double *Ltheta = H2[1] ;
764 for (
unsigned int k=0 ; k < 6 ; k++){
765 L[j][k] = (Lrho[k] + alpha2*Ltheta[k]);
767 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
bool isvisible
Indicates if the cylinder is visible or not.
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.
double get_oY() const
Get the point Y coordinate in the object frame.
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor col, const unsigned int thickness=1, const bool displayFullModel=false)
Contains predetermined masks for sites and holds moving edges tracking parameters.
unsigned int nbFeature
The number of moving edges.
vpPoint * p1
The first extremity on the axe.
void initInteractionMatrixError()
static void flush(const vpImage< unsigned char > &I)
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.
vpCircle * cercle2
The lower circle limiting the cylinder.
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
static double sqr(double x)
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.
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder)
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
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 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)
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)