40 #include <visp3/core/vpConfig.h> 48 #include <visp3/core/vpMeterPixelConversion.h> 49 #include <visp3/core/vpPlane.h> 50 #include <visp3/mbt/vpMbtDistanceLine.h> 51 #include <visp3/visual_features/vpFeatureBuilder.h> 60 : name(), index(0), cam(), me(NULL), isTrackedLine(true), isTrackedLineWithVisibility(true), wmean(1), featureline(),
61 poly(), useScanLine(false), meline(), line(NULL), p1(NULL), p2(NULL), L(), error(), nbFeature(), nbFeatureTotal(0),
62 Reinit(false), hiddenface(NULL), Lindex_polygon(), Lindex_polygon_tracked(), isvisible(false)
75 for (
unsigned int i = 0; i <
meline.size(); i++)
128 double norm = sqrt(A * A + B * B + C * C);
129 plane.
setA(A / norm);
130 plane.
setB(B / norm);
131 plane.
setC(C / norm);
132 plane.
setD(D / norm);
152 buildPlane(P1, P2, P3, plane1);
153 buildPlane(P1, P2, P4, plane2);
191 if (std::fabs((V1 - V2).sumSquare()) > std::numeric_limits<double>::epsilon()) {
193 V3[0] = double(rand_gen.
next() % 1000) / 100;
194 V3[1] = double(rand_gen.
next() % 1000) / 100;
195 V3[2] = double(rand_gen.
next() % 1000) / 100;
202 vpPoint P3(V3[0], V3[1], V3[2]);
203 vpPoint P4(V4[0], V4[1], V4[2]);
206 vpPoint P3(V1[0], V1[1], V1[2]);
207 vpPoint P4(V2[0], V2[1], V2[2]);
232 unsigned int ind = 0;
234 if ((*
hiddenface)[(unsigned)(*itpoly)]->getName() == polyname) {
240 isTrackedLine =
false;
243 isTrackedLine =
true;
247 if (!isTrackedLine) {
248 isTrackedLineWithVisibility =
false;
262 if (!isTrackedLine) {
263 isTrackedLineWithVisibility =
false;
267 unsigned int ind = 0;
268 isTrackedLineWithVisibility =
false;
271 isTrackedLineWithVisibility =
true;
287 for (
unsigned int i = 0; i <
meline.size(); i++)
311 for (
unsigned int i = 0; i <
meline.size(); i++) {
331 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
339 if (linesLst.size() == 0) {
355 while (theta > M_PI) {
358 while (theta < -M_PI) {
362 if (theta < -M_PI / 2.0)
363 theta = -theta - 3 * M_PI / 2.0;
365 theta = M_PI / 2.0 - theta;
367 for (
unsigned int i = 0; i < linesLst.size(); i++) {
370 linesLst[i].first.project();
371 linesLst[i].second.project();
376 vpMbtMeLine *melinePt =
new vpMbtMeLine;
377 melinePt->setMask(*mask);
380 melinePt->setInitRange(0);
384 melinePt->jmin = (int)ip1.
get_j() - marge;
385 melinePt->jmax = (int)ip2.
get_j() + marge;
387 melinePt->jmin = (int)ip2.
get_j() - marge;
388 melinePt->jmax = (int)ip1.
get_j() + marge;
391 melinePt->imin = (int)ip1.
get_i() - marge;
392 melinePt->imax = (int)ip2.
get_i() + marge;
394 melinePt->imin = (int)ip2.
get_i() - marge;
395 melinePt->imax = (int)ip1.
get_i() + marge;
399 melinePt->initTracking(I, ip1, ip2, rho, theta, doNotTrack);
400 meline.push_back(melinePt);
401 nbFeature.push_back((
unsigned int) melinePt->getMeList().size());
428 for (
size_t i = 0; i <
meline.size(); i++) {
434 for (
size_t i = 0; i <
meline.size(); i++) {
467 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
475 if (linesLst.size() !=
meline.size() || linesLst.size() == 0) {
476 for (
size_t i = 0; i <
meline.size(); i++) {
492 for (
size_t j = 0; j <
meline.size(); j++) {
508 while (theta > M_PI) {
511 while (theta < -M_PI) {
515 if (theta < -M_PI / 2.0)
516 theta = -theta - 3 * M_PI / 2.0;
518 theta = M_PI / 2.0 - theta;
521 for (
unsigned int i = 0; i < linesLst.size(); i++) {
524 linesLst[i].first.project();
525 linesLst[i].second.project();
546 meline[i]->updateParameters(I, ip1, ip2, rho, theta);
551 for (
size_t j = 0; j <
meline.size(); j++) {
564 for (
size_t i = 0; i <
meline.size(); i++) {
588 for (
size_t i = 0; i <
meline.size(); i++) {
616 bool displayFullModel)
618 std::vector<std::vector<double> > models =
621 for (
size_t i = 0; i < models.size(); i++) {
641 bool displayFullModel)
643 std::vector<std::vector<double> > models =
646 for (
size_t i = 0; i < models.size(); i++) {
669 for (
size_t i = 0; i <
meline.size(); i++) {
678 for (
size_t i = 0; i <
meline.size(); i++) {
691 std::vector<std::vector<double> > features;
693 for (
size_t i = 0; i <
meline.size(); i++) {
694 vpMbtMeLine *me_l =
meline[i];
696 for (std::list<vpMeSite>::const_iterator it = me_l->getMeList().begin(); it != me_l->getMeList().end(); ++it) {
698 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 699 std::vector<double> params = {0,
702 static_cast<double>(p_me_l.
getState())};
704 std::vector<double> params;
708 params.push_back(static_cast<double>(p_me_l.
getState()));
710 features.push_back(params);
732 bool displayFullModel)
734 std::vector<std::vector<double> > models;
736 if ((
isvisible && isTrackedLine) || displayFullModel) {
755 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
762 for (
unsigned int i = 0; i < linesLst.size(); i++) {
763 linesLst[i].first.project();
764 linesLst[i].second.project();
769 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 770 std::vector<double> params = {0,
776 std::vector<double> params;
778 params.push_back(ip1.
get_i());
779 params.push_back(ip1.
get_j());
780 params.push_back(ip2.
get_i());
781 params.push_back(ip2.
get_j());
783 models.push_back(params);
800 for (
size_t i = 0; i <
meline.size(); i++) {
803 std::list<vpMeSite> &me_site_list =
meline[i]->getMeList();
804 me_site_list.clear();
824 double rho = featureline.
getRho();
825 double theta = featureline.
getTheta();
827 double co = cos(theta);
828 double si = sin(theta);
830 double mx = 1.0 / cam.
get_px();
831 double my = 1.0 / cam.
get_py();
841 for (
size_t i = 0; i <
meline.size(); i++) {
842 for (std::list<vpMeSite>::const_iterator it =
meline[i]->getMeList().begin();
843 it !=
meline[i]->getMeList().end(); ++it) {
850 alpha_ = x * si - y * co;
853 double *Ltheta = H[1];
855 for (
unsigned int k = 0; k < 6; k++) {
856 L[j][k] = (Lrho[k] + alpha_ * Ltheta[k]);
858 error[j] = rho - (x * co + y * si);
866 for (
size_t i = 0; i <
meline.size(); i++) {
867 for (std::list<vpMeSite>::const_iterator it =
meline[i]->getMeList().begin();
868 it !=
meline[i]->getMeList().end(); ++it) {
869 for (
unsigned int k = 0; k < 6; k++) {
896 for (
size_t i = 0; i <
meline.size(); i++) {
897 for (std::list<vpMeSite>::const_iterator it =
meline[i]->getMeList().begin(); it !=
meline[i]->getMeList().end();
902 if (i_ < 0 || j_ < 0) {
906 if (((
unsigned int)i_ > (I.
getHeight() - threshold)) || (
unsigned int)i_ < threshold ||
907 ((
unsigned int)j_ > (I.
getWidth() - threshold)) || (
unsigned int)j_ < threshold) {
void addPoint(unsigned int n, const vpPoint &P)
Implementation of a matrix and operations on matrices.
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
void trackMovingEdge(const vpImage< unsigned char > &I)
vpMatrix interaction(unsigned int select=FEATURE_ALL)
unsigned int nbFeatureTotal
The number of moving edges.
void buildFrom(vpPoint &_p1, vpPoint &_p2, vpUniRand &rand_gen)
vpLine * line
The 3D line.
double get_jfloat() const
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
unsigned int getWidth() const
bool Reinit
Indicates if the line has to be reinitialized.
static vpColVector cross(const vpColVector &a, const vpColVector &b)
Implementation of an homogeneous matrix and operations on such kind of matrices.
std::list< int > Lindex_polygon
Index of the faces which contain the line.
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'...
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
virtual void setNbPoint(unsigned int nb)
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) const
Class to define RGB colors available for display functionnalities.
std::vector< bool > Lindex_polygon_tracked
vpPoint * p1
The first extremity.
void displayMovingEdges(const vpImage< unsigned char > &I)
double get_oY() const
Get the point oY coordinate in the object frame.
vpPoint * p
corners in the object frame
bool isvisible
Indicates if the line is visible or not.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
vpMeSiteState getState() const
std::vector< std::pair< vpPoint, unsigned int > > polyClipped
Region of interest clipped.
void setTracked(const std::string &name, const bool &track)
Class that defines a 3D line in the object frame and allows forward projection of the line in the cam...
std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false)
void setWorldCoordinates(const double &oA1, const double &oB1, const double &oC1, const double &oD1, const double &oA2, const double &oB2, const double &oC2, const double &oD2)
void computePolygonClipped(const vpCameraParameters &cam=vpCameraParameters())
vpPoint * p2
The second extremity.
vpColVector error
The error vector.
Generic class defining intrinsic camera parameters.
double get_oZ() const
Get the point oZ coordinate in the object frame.
unsigned int getClipping() const
static void convertLine(const vpCameraParameters &cam, const double &rho_m, const double &theta_m, double &rho_p, double &theta_p)
virtual ~vpMbtDistanceLine()
double get_oX() const
Get the point oX coordinate in the object frame.
void resize(unsigned int i, bool flagNullify=true)
bool closeToImageBorder(const vpImage< unsigned char > &I, const unsigned int threshold)
void computeScanLineQuery(const vpPoint &a, const vpPoint &b, std::vector< std::pair< vpPoint, vpPoint > > &lines, const bool &displayResults=false)
Implementation of column vector and the associated operations.
void setMovingEdge(vpMe *Me)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo)
double get_ifloat() const
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
std::vector< std::vector< double > > getFeaturesForDisplay()
void addPolygon(const int &index)
unsigned int getHeight() const
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Class for generating random numbers with uniform probability density.
std::vector< vpMbtMeLine * > meline
The moving edge container.
This class defines the container for a plane geometrical structure.
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) const
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpImage< bool > *mask=NULL)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
vpMatrix L
The interaction matrix.
std::vector< unsigned int > nbFeature
The number of moving edges.
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, bool doNotTrack, const vpImage< bool > *mask=NULL)
void initInteractionMatrixError()
bool useScanLine
Use scanline rendering.
void computeFov(const unsigned int &w, const unsigned int &h)