41 #include <visp3/core/vpConfig.h>
50 #include <visp3/core/vpMeterPixelConversion.h>
51 #include <visp3/core/vpPixelMeterConversion.h>
52 #include <visp3/core/vpPlane.h>
53 #include <visp3/mbt/vpMbtDistanceCylinder.h>
54 #include <visp3/visual_features/vpFeatureBuilder.h>
55 #include <visp3/visual_features/vpFeatureEllipse.h>
57 #include <visp3/vision/vpPose.h>
64 : name(), index(0), cam(), me(nullptr), wmean1(1), wmean2(1), featureline1(), featureline2(), isTrackedCylinder(true),
65 meline1(nullptr), meline2(nullptr), cercle1(nullptr), cercle2(nullptr), radius(0), p1(nullptr), p2(nullptr), L(), error(),
66 nbFeature(0), nbFeaturel1(0), nbFeaturel2(0), Reinit(false), c(nullptr), hiddenface(nullptr), index_polygon(-1),
229 double i11, i12, i21, i22, j11, j12, j21, j22;
279 while (theta1 > M_PI) {
282 while (theta1 < -M_PI) {
286 if (theta1 < -M_PI / 2.0)
287 theta1 = -theta1 - 3 * M_PI / 2.0;
289 theta1 = M_PI / 2.0 - theta1;
291 while (theta2 > M_PI) {
294 while (theta2 < -M_PI) {
298 if (theta2 < -M_PI / 2.0)
299 theta2 = -theta2 - 3 * M_PI / 2.0;
301 theta2 = M_PI / 2.0 - theta2;
304 meline1->initTracking(I, ip11, ip12, rho1, theta1, doNotTrack);
311 meline2->initTracking(I, ip21, ip22, rho2, theta2, doNotTrack);
376 std::cout <<
"Probleme projection cercle 1\n";
382 std::cout <<
"Probleme projection cercle 2\n";
395 double i11, i12, i21, i22, j11, j12, j21, j22;
447 while (theta1 > M_PI) {
450 while (theta1 < -M_PI) {
454 if (theta1 < -M_PI / 2.0)
455 theta1 = -theta1 - 3 * M_PI / 2.0;
457 theta1 = M_PI / 2.0 - theta1;
459 while (theta2 > M_PI) {
462 while (theta2 < -M_PI) {
466 if (theta2 < -M_PI / 2.0)
467 theta2 = -theta2 - 3 * M_PI / 2.0;
469 theta2 = M_PI / 2.0 - theta2;
473 meline1->updateParameters(I, ip11, ip12, rho1, theta1);
480 meline2->updateParameters(I, ip21, ip22, rho2, theta2);
533 bool displayFullModel)
535 std::vector<std::vector<double> > models =
538 for (
size_t i = 0; i < models.size(); i++) {
558 bool displayFullModel)
560 std::vector<std::vector<double> > models =
563 for (
size_t i = 0; i < models.size(); i++) {
577 std::vector<std::vector<double> > features;
580 for (std::list<vpMeSite>::const_iterator it =
meline1->getMeList().begin(); it !=
meline1->getMeList().end();
583 #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
584 std::vector<double> params = { 0,
587 static_cast<double>(p_me.
getState()) };
589 std::vector<double> params;
593 params.push_back(
static_cast<double>(p_me.
getState()));
596 features.push_back(params);
601 for (std::list<vpMeSite>::const_iterator it =
meline2->getMeList().begin(); it !=
meline2->getMeList().end();
604 #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
605 std::vector<double> params = { 0,
608 static_cast<double>(p_me.
getState()) };
610 std::vector<double> params;
614 params.push_back(
static_cast<double>(p_me.
getState()));
617 features.push_back(params);
637 bool displayFullModel)
639 std::vector<std::vector<double> > models;
641 if ((
isvisible && isTrackedCylinder) || displayFullModel) {
655 std::cout <<
"Problem projection circle 1";
661 std::cout <<
"Problem projection circle 2";
673 double i11, i12, i21, i22, j11, j12, j21, j22;
688 #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
689 std::vector<double> params1 = { 0,
695 std::vector<double> params2 = { 0,
701 std::vector<double> params1, params2;
702 params1.push_back(0);
703 params1.push_back(ip11.
get_i());
704 params1.push_back(ip11.
get_j());
705 params1.push_back(ip12.
get_i());
706 params1.push_back(ip12.
get_j());
708 params2.push_back(0);
709 params2.push_back(ip11.
get_i());
710 params2.push_back(ip11.
get_j());
711 params2.push_back(ip12.
get_i());
712 params2.push_back(ip12.
get_j());
715 models.push_back(params1);
716 models.push_back(params2);
792 std::cout <<
"Problem projection circle 1\n";
798 std::cout <<
"Problem projection circle 2\n";
810 double rho1 = featureline1.
getRho();
811 double theta1 = featureline1.
getTheta();
812 double rho2 = featureline2.
getRho();
813 double theta2 = featureline2.
getTheta();
815 double co1 = cos(theta1);
816 double si1 = sin(theta1);
817 double co2 = cos(theta2);
818 double si2 = sin(theta2);
820 double mx = 1.0 / cam.
get_px();
821 double my = 1.0 / cam.
get_py();
832 for (std::list<vpMeSite>::const_iterator it =
meline1->getMeList().begin(); it !=
meline1->getMeList().end();
834 double x = (double)it->
m_j;
835 double y = (
double)it->m_i;
840 double alpha1 = x * si1 - y * co1;
842 double *Lrho = H1[0];
843 double *Ltheta = H1[1];
845 for (
unsigned int k = 0; k < 6; k++) {
846 L[j][k] = (Lrho[k] + alpha1 * Ltheta[k]);
848 error[j] = rho1 - (x * co1 + y * si1);
856 for (std::list<vpMeSite>::const_iterator it =
meline2->getMeList().begin(); it !=
meline2->getMeList().end();
858 double x = (double)it->m_j;
859 double y = (
double)it->m_i;
864 double alpha2 = x * si2 - y * co2;
866 double *Lrho = H2[0];
867 double *Ltheta = H2[1];
869 for (
unsigned int k = 0; k < 6; k++) {
870 L[j][k] = (Lrho[k] + alpha2 * Ltheta[k]);
872 error[j] = rho2 - (x * co2 + y * si2);
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
Generic class defining intrinsic camera parameters.
Class that defines a 3D circle in the object frame and allows forward projection of a 3D circle in th...
void changeFrame(const vpHomogeneousMatrix &noMo, vpColVector &noP) const VP_OVERRIDE
void projection() VP_OVERRIDE
void setWorldCoordinates(const vpColVector &oP) VP_OVERRIDE
static void computeIntersectionPoint(const vpCircle &circle, const vpCameraParameters &cam, const double &rho, const double &theta, double &i, double &j)
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
Class to define RGB colors available for display functionalities.
static const vpColor orange
Class that defines a 3D cylinder in the object frame and allows forward projection of a 3D cylinder i...
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) const VP_OVERRIDE
void projection() VP_OVERRIDE
void setWorldCoordinates(const vpColVector &oP) VP_OVERRIDE
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void flush(const vpImage< unsigned char > &I)
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpImagePoint &t)
vpMatrix interaction(unsigned int select=FEATURE_ALL) VP_OVERRIDE
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void set_ij(double ii, double jj)
unsigned int getWidth() const
unsigned int getHeight() const
Implementation of a matrix and operations on matrices.
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, double r)
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo, const vpImage< unsigned char > &I)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpImage< bool > *mask=nullptr)
vpMbtMeLine * meline2
The moving edge containers (second line of the cylinder)
vpCylinder * c
The cylinder.
vpMatrix L
The interaction matrix.
unsigned int nbFeaturel2
The number of moving edges on line 2.
bool Reinit
Indicates if the line has to be reinitialized.
vpPoint * p2
The second extremity on the axe.
vpCircle * cercle1
The upper circle limiting the cylinder.
void initInteractionMatrixError()
void setMovingEdge(vpMe *Me)
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, bool doNotTrack, const vpImage< bool > *mask=nullptr)
double radius
The radius of the cylinder.
unsigned int nbFeaturel1
The number of moving edges on line 1.
vpColVector error
The error vector.
void displayMovingEdges(const vpImage< unsigned char > &I)
std::vector< std::vector< double > > getFeaturesForDisplay()
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
unsigned int nbFeature
The number of moving edges.
vpCircle * cercle2
The lower circle limiting the cylinder.
bool isvisible
Indicates if the cylinder is visible or not.
std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false)
virtual ~vpMbtDistanceCylinder()
void trackMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
vpPoint * p1
The first extremity on the axe.
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder)
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'....
vpMeSiteState getState() const
int m_j
Integer coordinates along j of a site.
double get_ifloat() const
double get_jfloat() const
static void convertLine(const vpCameraParameters &cam, const double &rho_m, const double &theta_m, double &rho_p, double &theta_p)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
double get_oX() const
Get the point oX coordinate in the object frame.
void projection(const vpColVector &_cP, vpColVector &_p) const VP_OVERRIDE
double get_oZ() const
Get the point oZ coordinate in the object frame.
double get_oY() const
Get the point oY coordinate in the object frame.
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) const VP_OVERRIDE