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);
190 if (std::fabs((V1 - V2).sumSquare()) > std::numeric_limits<double>::epsilon()) {
192 V3[0] = double(rand() % 1000) / 100;
193 V3[1] = double(rand() % 1000) / 100;
194 V3[2] = double(rand() % 1000) / 100;
201 vpPoint P3(V3[0], V3[1], V3[2]);
202 vpPoint P4(V4[0], V4[1], V4[2]);
205 vpPoint P3(V1[0], V1[1], V1[2]);
206 vpPoint P4(V2[0], V2[1], V2[2]);
231 unsigned int ind = 0;
233 if ((*
hiddenface)[(unsigned)(*itpoly)]->getName() == polyname) {
239 isTrackedLine =
false;
242 isTrackedLine =
true;
246 if (!isTrackedLine) {
247 isTrackedLineWithVisibility =
false;
261 if (!isTrackedLine) {
262 isTrackedLineWithVisibility =
false;
266 unsigned int ind = 0;
267 isTrackedLineWithVisibility =
false;
270 isTrackedLineWithVisibility =
true;
286 for (
unsigned int i = 0; i <
meline.size(); i++)
310 for (
unsigned int i = 0; i <
meline.size(); i++) {
330 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
338 if (linesLst.size() == 0) {
354 while (theta > M_PI) {
357 while (theta < -M_PI) {
361 if (theta < -M_PI / 2.0)
362 theta = -theta - 3 * M_PI / 2.0;
364 theta = M_PI / 2.0 - theta;
366 for (
unsigned int i = 0; i < linesLst.size(); i++) {
369 linesLst[i].first.project();
370 linesLst[i].second.project();
375 vpMbtMeLine *melinePt =
new vpMbtMeLine;
376 melinePt->setMask(*mask);
379 melinePt->setInitRange(0);
383 melinePt->jmin = (int)ip1.
get_j() - marge;
384 melinePt->jmax = (int)ip2.
get_j() + marge;
386 melinePt->jmin = (int)ip2.
get_j() - marge;
387 melinePt->jmax = (int)ip1.
get_j() + marge;
390 melinePt->imin = (int)ip1.
get_i() - marge;
391 melinePt->imax = (int)ip2.
get_i() + marge;
393 melinePt->imin = (int)ip2.
get_i() - marge;
394 melinePt->imax = (int)ip1.
get_i() + marge;
398 melinePt->initTracking(I, ip1, ip2, rho, theta, doNotTrack);
399 meline.push_back(melinePt);
400 nbFeature.push_back((
unsigned int) melinePt->getMeList().size());
427 for (
size_t i = 0; i <
meline.size(); i++) {
433 for (
size_t i = 0; i <
meline.size(); i++) {
466 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
474 if (linesLst.size() !=
meline.size() || linesLst.size() == 0) {
475 for (
size_t i = 0; i <
meline.size(); i++) {
491 for (
size_t j = 0; j <
meline.size(); j++) {
507 while (theta > M_PI) {
510 while (theta < -M_PI) {
514 if (theta < -M_PI / 2.0)
515 theta = -theta - 3 * M_PI / 2.0;
517 theta = M_PI / 2.0 - theta;
520 for (
unsigned int i = 0; i < linesLst.size(); i++) {
523 linesLst[i].first.project();
524 linesLst[i].second.project();
545 meline[i]->updateParameters(I, ip1, ip2, rho, theta);
550 for (
size_t j = 0; j <
meline.size(); j++) {
563 for (
size_t i = 0; i <
meline.size(); i++) {
587 for (
size_t i = 0; i <
meline.size(); i++) {
615 const bool displayFullModel)
617 if ((
isvisible && isTrackedLine) || displayFullModel) {
636 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
643 for (
unsigned int i = 0; i < linesLst.size(); i++) {
644 linesLst[i].first.project();
645 linesLst[i].second.project();
669 const bool displayFullModel)
671 if ((
isvisible && isTrackedLine) || displayFullModel) {
690 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
697 for (
unsigned int i = 0; i < linesLst.size(); i++) {
698 linesLst[i].first.project();
699 linesLst[i].second.project();
726 for (
size_t i = 0; i <
meline.size(); i++)
741 for (
size_t i = 0; i <
meline.size(); i++) {
744 std::list<vpMeSite> &me_site_list =
meline[i]->getMeList();
745 me_site_list.clear();
765 double rho = featureline.
getRho();
766 double theta = featureline.
getTheta();
768 double co = cos(theta);
769 double si = sin(theta);
771 double mx = 1.0 / cam.
get_px();
772 double my = 1.0 / cam.
get_py();
782 for (
size_t i = 0; i <
meline.size(); i++) {
783 for (std::list<vpMeSite>::const_iterator it =
meline[i]->getMeList().begin();
784 it !=
meline[i]->getMeList().end(); ++it) {
791 alpha_ = x * si - y * co;
794 double *Ltheta = H[1];
796 for (
unsigned int k = 0; k < 6; k++) {
797 L[j][k] = (Lrho[k] + alpha_ * Ltheta[k]);
799 error[j] = rho - (x * co + y * si);
807 for (
size_t i = 0; i <
meline.size(); i++) {
808 for (std::list<vpMeSite>::const_iterator it =
meline[i]->getMeList().begin();
809 it !=
meline[i]->getMeList().end(); ++it) {
810 for (
unsigned int k = 0; k < 6; k++) {
837 for (
size_t i = 0; i <
meline.size(); i++) {
838 for (std::list<vpMeSite>::const_iterator it =
meline[i]->getMeList().begin(); it !=
meline[i]->getMeList().end();
843 if (i_ < 0 || j_ < 0) {
847 if (((
unsigned int)i_ > (I.
getHeight() - threshold)) || (
unsigned int)i_ < threshold ||
848 ((
unsigned int)j_ > (I.
getWidth() - threshold)) || (
unsigned int)j_ < threshold) {
Implementation of a matrix and operations on matrices.
void setD(const double d)
void trackMovingEdge(const vpImage< unsigned char > &I)
virtual void setNbPoint(const unsigned int nb)
unsigned int nbFeatureTotal
The number of moving edges.
vpLine * line
The 3D line.
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.
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const bool doNotTrack, const vpImage< bool > *mask=NULL)
std::list< int > Lindex_polygon
Index of the faces which contain the line.
void setWorldCoordinates(const double &A1, const double &B1, const double &C1, const double &D1, const double &A2, const double &B2, const double &C2, const double &D2)
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Class to define 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 Y coordinate in the object frame.
error that can be emited by ViSP classes.
vpPoint * p
corners in the object frame
bool isvisible
Indicates if the line is visible or not.
Class that defines what is a point.
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 line in the object frame, the camera frame and the image plane. All the parameters must be set in meter.
void computePolygonClipped(const vpCameraParameters &cam=vpCameraParameters())
vpPoint * p2
The second extremity.
vpColVector error
The error vector.
void addPoint(const unsigned int n, const vpPoint &P)
Generic class defining intrinsic camera parameters.
double get_oZ() const
Get the point Z coordinate in the object frame.
unsigned int getClipping() const
void setA(const double a)
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP)
void setC(const double c)
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 X coordinate in the object frame.
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)
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void setB(const double b)
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 ...
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
std::vector< vpMbtMeLine * > meline
The moving edge container.
This class defines the container for a plane geometrical structure.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &_cP)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpImage< bool > *mask=NULL)
vpMatrix L
The interaction matrix.
std::vector< unsigned int > nbFeature
The number of moving edges.
void initInteractionMatrixError()
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)
bool useScanLine
Use scanline rendering.
void buildFrom(vpPoint &_p1, vpPoint &_p2)
void resize(const unsigned int i, const bool flagNullify=true)
void computeFov(const unsigned int &w, const unsigned int &h)