42 #include <visp3/core/vpConfig.h>
49 #include <visp3/mbt/vpMbtDistanceCylinder.h>
50 #include <visp3/core/vpPlane.h>
51 #include <visp3/core/vpMeterPixelConversion.h>
52 #include <visp3/core/vpPixelMeterConversion.h>
53 #include <visp3/visual_features/vpFeatureBuilder.h>
54 #include <visp3/visual_features/vpFeatureEllipse.h>
58 #include <visp3/vision/vpPose.h>
64 : name(), index(0), cam(), me(NULL), wmean1(1), wmean2(1),
65 featureline1(), featureline2(), isTrackedCylinder(true), meline1(NULL), meline2(NULL),
66 cercle1(NULL), cercle2(NULL), radius(0), p1(NULL), p2(NULL), L(),
67 error(), nbFeature(0), nbFeaturel1(0), nbFeaturel2(0), Reinit(false),
68 c(NULL), hiddenface(NULL), index_polygon(-1), isvisible(false)
79 if (
p1 != NULL)
delete p1 ;
80 if (
p2 != NULL)
delete p2 ;
81 if (
c != NULL)
delete c ;
224 double i11,i12,i21,i22,j11,j12,j21,j22;
246 while (theta1 > M_PI) { theta1 -= M_PI ; }
247 while (theta1 < -M_PI) { theta1 += M_PI ; }
249 if (theta1 < -M_PI/2.0) theta1 = -theta1 - 3*M_PI/2.0;
250 else theta1 = M_PI/2.0 - theta1;
252 while (theta2 > M_PI) { theta2 -= M_PI ; }
253 while (theta2 < -M_PI) { theta2 += M_PI ; }
255 if (theta2 < -M_PI/2.0) theta2 = -theta2 - 3*M_PI/2.0;
256 else theta2 = M_PI/2.0 - theta2;
260 meline1->initTracking(I,ip11,ip12,rho1,theta1);
269 meline2->initTracking(I,ip21,ip22,rho2,theta2);
343 catch(...){std::cout<<
"Probleme projection cercle 1\n";}
347 catch(...){std::cout<<
"Probleme projection cercle 2\n";}
359 double i11,i12,i21,i22,j11,j12,j21,j22;
383 while (theta1 > M_PI) { theta1 -= M_PI ; }
384 while (theta1 < -M_PI) { theta1 += M_PI ; }
386 if (theta1 < -M_PI/2.0) theta1 = -theta1 - 3*M_PI/2.0;
387 else theta1 = M_PI/2.0 - theta1;
389 while (theta2 > M_PI) { theta2 -= M_PI ; }
390 while (theta2 < -M_PI) { theta2 += M_PI ; }
392 if (theta2 < -M_PI/2.0) theta2 = -theta2 - 3*M_PI/2.0;
393 else theta2 = M_PI/2.0 - theta2;
398 meline1->updateParameters(I,ip11,ip12,rho1,theta1) ;
407 meline2->updateParameters(I,ip21,ip22,rho2,theta2) ;
461 const bool displayFullModel)
476 catch(...){std::cout<<
"Problem projection circle 1";}
480 catch(...){std::cout<<
"Problem projection circle 2";}
491 double i11,i12,i21,i22,j11,j12,j21,j22;
525 const bool displayFullModel)
540 catch(...){std::cout<<
"Problem projection circle 1";}
544 catch(...){std::cout<<
"Problem projection circle 2";}
555 double i11,i12,i21,i22,j11,j12,j21,j22;
635 catch(...){std::cout<<
"Problem projection circle 1\n";}
639 catch(...){std::cout<<
"Problem projection circle 2\n";}
649 double rho1 = featureline1.
getRho() ;
650 double theta1 = featureline1.
getTheta() ;
651 double rho2 = featureline2.
getRho() ;
652 double theta2 = featureline2.
getTheta() ;
654 double co1 = cos(theta1);
655 double si1 = sin(theta1);
656 double co2 = cos(theta2);
657 double si2 = sin(theta2);
659 double mx = 1.0/cam.
get_px() ;
660 double my = 1.0/cam.
get_py() ;
661 double xc = cam.
get_u0() ;
662 double yc = cam.
get_v0() ;
674 for(std::list<vpMeSite>::const_iterator it=
meline1->getMeList().begin(); it!=
meline1->getMeList().end(); ++it){
681 alpha1 = x*si1 - y*co1;
683 double *Lrho = H1[0] ;
684 double *Ltheta = H1[1] ;
686 for (
unsigned int k=0 ; k < 6 ; k++){
687 L[j][k] = (Lrho[k] + alpha1*Ltheta[k]);
689 error[j] = rho1 - ( x*co1 + y*si1) ;
696 for(std::list<vpMeSite>::const_iterator it=
meline2->getMeList().begin(); it!=
meline2->getMeList().end(); ++it){
703 alpha2 = x*si2 - y*co2;
705 double *Lrho = H2[0] ;
706 double *Ltheta = H2[1] ;
708 for (
unsigned int k=0 ; k < 6 ; k++){
709 L[j][k] = (Lrho[k] + alpha2*Ltheta[k]);
711 error[j] = rho2 - ( x*co2 + y*si2) ;
void setMovingEdge(vpMe *Me)
Implementation of a matrix and operations on matrices.
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 trackMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP)
perspective projection of the circle
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
bool isvisible
Indicates if the cylinder is visible or not.
Implementation of an homogeneous matrix and operations on such kind of matrices.
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)
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 void computeIntersectionPoint(const vpCircle &circle, const vpCameraParameters &cam, const double &rho, const double &theta, double &i, double &j)
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)
Implementation of column vector and the associated operations.
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)