39#include <visp3/core/vpConfig.h>
48#include <visp3/core/vpMeterPixelConversion.h>
49#include <visp3/core/vpPixelMeterConversion.h>
50#include <visp3/core/vpPlane.h>
51#include <visp3/mbt/vpMbtDistanceCylinder.h>
52#include <visp3/visual_features/vpFeatureBuilder.h>
53#include <visp3/visual_features/vpFeatureEllipse.h>
55#include <visp3/vision/vpPose.h>
66 : name(), index(0), cam(), me(nullptr), wmean1(1), wmean2(1), featureline1(), featureline2(), isTrackedCylinder(true),
151 c->setWorldCoordinates(ABC[0], ABC[1], ABC[2], (_p1.
get_oX() + _p2.
get_oX()) / 2.0,
185 bool doNotTrack,
const vpImage<bool> *mask,
const int &initRange)
189 p1->changeFrame(cMo);
190 p2->changeFrame(cMo);
225 unsigned int initRange_;
227 initRange_ = defaultRange;
230 initRange_ =
static_cast<unsigned int>(initRange);
232 int oldInitRange = me->getInitRange();
233 me->setInitRange(initRange_);
240 double i11, i12, i21, i22, j11, j12, j21, j22;
290 while (theta1 > M_PI) {
293 while (theta1 < -M_PI) {
297 if (theta1 < -M_PI / 2.0)
298 theta1 = -theta1 - 3 * M_PI / 2.0;
300 theta1 = M_PI / 2.0 - theta1;
302 while (theta2 > M_PI) {
305 while (theta2 < -M_PI) {
309 if (theta2 < -M_PI / 2.0)
310 theta2 = -theta2 - 3 * M_PI / 2.0;
312 theta2 = M_PI / 2.0 - theta2;
315 meline1->initTracking(I, ip11, ip12, rho1, theta1, doNotTrack);
319 me->setInitRange(oldInitRange);
323 meline2->initTracking(I, ip21, ip22, rho2, theta2, doNotTrack);
327 me->setInitRange(oldInitRange);
330 me->setInitRange(oldInitRange);
344 int oldInitRange = me->getInitRange();
345 me->setInitRange(defaultRange);
369 me->setInitRange(oldInitRange);
380 int oldInitRange = me->getInitRange();
381 me->setInitRange(defaultRange);
384 p1->changeFrame(cMo);
385 p2->changeFrame(cMo);
396 std::cout <<
"Probleme projection cercle 1\n";
402 std::cout <<
"Probleme projection cercle 2\n";
415 double i11, i12, i21, i22, j11, j12, j21, j22;
467 while (theta1 > M_PI) {
470 while (theta1 < -M_PI) {
474 if (theta1 < -M_PI / 2.0)
475 theta1 = -theta1 - 3 * M_PI / 2.0;
477 theta1 = M_PI / 2.0 - theta1;
479 while (theta2 > M_PI) {
482 while (theta2 < -M_PI) {
486 if (theta2 < -M_PI / 2.0)
487 theta2 = -theta2 - 3 * M_PI / 2.0;
489 theta2 = M_PI / 2.0 - theta2;
493 meline1->updateParameters(I, ip11, ip12, rho1, theta1);
500 meline2->updateParameters(I, ip21, ip22, rho2, theta2);
511 me->setInitRange(oldInitRange);
554 bool displayFullModel)
556 std::vector<std::vector<double> > models =
559 for (
size_t i = 0; i < models.size(); i++) {
579 bool displayFullModel)
581 std::vector<std::vector<double> > models =
584 for (
size_t i = 0; i < models.size(); i++) {
598 std::vector<std::vector<double> > features;
601 for (std::list<vpMeSite>::const_iterator it =
meline1->getMeList().begin(); it !=
meline1->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);
622 for (std::list<vpMeSite>::const_iterator it =
meline2->getMeList().begin(); it !=
meline2->getMeList().end();
625#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
626 std::vector<double> params = { 0,
629 static_cast<double>(p_me.
getState()) };
631 std::vector<double> params;
635 params.push_back(
static_cast<double>(p_me.
getState()));
638 features.push_back(params);
659 bool displayFullModel)
663 std::vector<std::vector<double> > models;
665 if ((
isvisible && isTrackedCylinder) || displayFullModel) {
667 p1->changeFrame(cMo);
668 p2->changeFrame(cMo);
679 std::cout <<
"Problem projection circle 1";
685 std::cout <<
"Problem projection circle 2";
697 double i11, i12, i21, i22, j11, j12, j21, j22;
712#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
713 std::vector<double> params1 = { 0,
719 std::vector<double> params2 = { 0,
725 std::vector<double> params1, params2;
726 params1.push_back(0);
727 params1.push_back(ip11.
get_i());
728 params1.push_back(ip11.
get_j());
729 params1.push_back(ip12.
get_i());
730 params1.push_back(ip12.
get_j());
732 params2.push_back(0);
733 params2.push_back(ip11.
get_i());
734 params2.push_back(ip11.
get_j());
735 params2.push_back(ip12.
get_i());
736 params2.push_back(ip12.
get_j());
739 models.push_back(params1);
740 models.push_back(params2);
816 std::cout <<
"Problem projection circle 1\n";
822 std::cout <<
"Problem projection circle 2\n";
834 double rho1 = featureline1.getRho();
835 double theta1 = featureline1.getTheta();
836 double rho2 = featureline2.getRho();
837 double theta2 = featureline2.getTheta();
839 double co1 = cos(theta1);
840 double si1 = sin(theta1);
841 double co2 = cos(theta2);
842 double si2 = sin(theta2);
844 double mx = 1.0 / cam.get_px();
845 double my = 1.0 / cam.get_py();
846 double xc = cam.get_u0();
847 double yc = cam.get_v0();
850 H1 = featureline1.interaction();
852 H2 = featureline2.interaction();
856 for (std::list<vpMeSite>::const_iterator it =
meline1->getMeList().begin(); it !=
meline1->getMeList().end();
858 double x =
static_cast<double>(it->m_j);
859 double y =
static_cast<double>(it->m_i);
864 double alpha1 = x * si1 - y * co1;
866 double *Lrho = H1[0];
867 double *Ltheta = H1[1];
869 for (
unsigned int k = 0; k < 6; k++) {
870 L[j][k] = (Lrho[k] + alpha1 * Ltheta[k]);
872 error[j] = rho1 - (x * co1 + y * si1);
880 for (std::list<vpMeSite>::const_iterator it =
meline2->getMeList().begin(); it !=
meline2->getMeList().end();
882 double x =
static_cast<double>(it->m_j);
883 double y =
static_cast<double>(it->m_i);
888 double alpha2 = x * si2 - y * co2;
890 double *Lrho = H2[0];
891 double *Ltheta = H2[1];
893 for (
unsigned int k = 0; k < 6; k++) {
894 L[j][k] = (Lrho[k] + alpha2 * Ltheta[k]);
896 error[j] = rho2 - (x * co2 + y * si2);
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...
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.
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...
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 vpDot &d)
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)
Definition of the vpImage class member functions.
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).
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, bool doNotTrack, const vpImage< bool > *mask=nullptr, const int &initRange=0)
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()
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void setMovingEdge(vpMe *Me)
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.
int index_polygon
Index of the face which contains the cylinder.
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
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.
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.
const unsigned int defaultRange