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++)
307 for (
unsigned int i = 0; i <
meline.size(); i++) {
327 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
335 if (linesLst.size() == 0) {
360 while (theta > M_PI) {
363 while (theta < -M_PI) {
367 if (theta < -M_PI / 2.0)
368 theta = -theta - 3 * M_PI / 2.0;
370 theta = M_PI / 2.0 - theta;
372 for (
unsigned int i = 0; i < linesLst.size(); i++) {
375 linesLst[i].first.project();
376 linesLst[i].second.project();
381 vpMbtMeLine *melinePt =
new vpMbtMeLine;
385 melinePt->setInitRange(0);
389 melinePt->jmin = (int)ip1.
get_j() - marge;
390 melinePt->jmax = (int)ip2.
get_j() + marge;
392 melinePt->jmin = (int)ip2.
get_j() - marge;
393 melinePt->jmax = (int)ip1.
get_j() + marge;
396 melinePt->imin = (int)ip1.
get_i() - marge;
397 melinePt->imax = (int)ip2.
get_i() + marge;
399 melinePt->imin = (int)ip2.
get_i() - marge;
400 melinePt->imax = (int)ip1.
get_i() + marge;
404 melinePt->initTracking(I, ip1, ip2, rho, theta);
405 meline.push_back(melinePt);
458 for (
unsigned int i = 0; i <
meline.size(); i++) {
464 for (
unsigned int i = 0; i <
meline.size(); i++) {
497 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
505 if (linesLst.size() !=
meline.size() || linesLst.size() == 0) {
506 for (
unsigned int i = 0; i <
meline.size(); i++) {
538 while (theta > M_PI) {
541 while (theta < -M_PI) {
545 if (theta < -M_PI / 2.0)
546 theta = -theta - 3 * M_PI / 2.0;
548 theta = M_PI / 2.0 - theta;
551 for (
unsigned int i = 0; i < linesLst.size(); i++) {
554 linesLst[i].first.project();
555 linesLst[i].second.project();
576 meline[i]->updateParameters(I, ip1, ip2, rho, theta);
581 for (
unsigned int j = 0; j <
meline.size(); j++) {
594 for (
unsigned int i = 0; i <
meline.size(); i++) {
617 for (
unsigned int i = 0; i <
meline.size(); i++) {
645 const bool displayFullModel)
647 if ((
isvisible && isTrackedLine) || displayFullModel) {
666 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
673 for (
unsigned int i = 0; i < linesLst.size(); i++) {
674 linesLst[i].first.project();
675 linesLst[i].second.project();
699 const bool displayFullModel)
701 if ((
isvisible && isTrackedLine) || displayFullModel) {
720 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
727 for (
unsigned int i = 0; i < linesLst.size(); i++) {
728 linesLst[i].first.project();
729 linesLst[i].second.project();
756 for (
unsigned int i = 0; i <
meline.size(); i++)
771 for (
unsigned int i = 0; i <
meline.size(); i++) {
774 std::list<vpMeSite> &me_site_list =
meline[i]->getMeList();
775 me_site_list.clear();
795 double rho = featureline.
getRho();
796 double theta = featureline.
getTheta();
798 double co = cos(theta);
799 double si = sin(theta);
801 double mx = 1.0 / cam.
get_px();
802 double my = 1.0 / cam.
get_py();
812 for (
unsigned int i = 0; i <
meline.size(); i++) {
813 for (std::list<vpMeSite>::const_iterator it =
meline[i]->getMeList().begin();
814 it !=
meline[i]->getMeList().end(); ++it) {
821 alpha_ = x * si - y * co;
824 double *Ltheta = H[1];
826 for (
unsigned int k = 0; k < 6; k++) {
827 L[j][k] = (Lrho[k] + alpha_ * Ltheta[k]);
829 error[j] = rho - (x * co + y * si);
834 std::cerr <<
"Catch an exception: " << e.
what() << std::endl;
835 std::cerr <<
"Set the corresponding interaction matrix part to zero." << std::endl;
838 for (
unsigned int i = 0; i <
meline.size(); i++) {
839 for (std::list<vpMeSite>::const_iterator it =
meline[i]->getMeList().begin();
840 it !=
meline[i]->getMeList().end(); ++it) {
841 for (
unsigned int k = 0; k < 6; k++) {
868 for (
unsigned int i = 0; i <
meline.size(); i++) {
869 for (std::list<vpMeSite>::const_iterator it =
meline[i]->getMeList().begin(); it !=
meline[i]->getMeList().end();
874 if (i_ < 0 || j_ < 0) {
878 if (((
unsigned int)i_ > (I.
getHeight() - threshold)) || (
unsigned int)i_ < threshold ||
879 ((
unsigned int)j_ > (I.
getWidth() - threshold)) || (
unsigned int)j_ < threshold) {
Implementation of a matrix and operations on matrices.
void setD(const double d)
double get_oY() const
Get the point Y coordinate in the object frame.
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)
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.
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)
Point coordinates conversion from normalized coordinates in meter to pixel coordinates ...
Class to define colors available for display functionnalities.
void trackMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
std::vector< bool > Lindex_polygon_tracked
vpPoint * p1
The first extremity.
void displayMovingEdges(const vpImage< unsigned char > &I)
error that can be emited by ViSP classes.
vpPoint * p
corners in the object frame
double get_oX() const
Get the point X coordinate 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 reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void computePolygonClipped(const vpCameraParameters &cam=vpCameraParameters())
vpPoint * p2
The second extremity.
unsigned int getClipping() const
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.
void setA(const double a)
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP)
const char * what() const
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)
Line coordinates conversion (rho,theta).
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)
unsigned int getHeight() const
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)
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)
unsigned int getWidth() const
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)
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)