39 #include <visp3/core/vpConfig.h>
46 #include <visp3/mbt/vpMbtDistanceLine.h>
47 #include <visp3/core/vpPlane.h>
48 #include <visp3/core/vpMeterPixelConversion.h>
49 #include <visp3/visual_features/vpFeatureBuilder.h>
59 : name(), index(0), cam(), me(NULL), isTrackedLine(true), isTrackedLineWithVisibility(true),
60 wmean(1), featureline(), poly(), useScanLine(false), meline(), line(NULL), p1(NULL), p2(NULL), L(),
61 error(), nbFeature(), nbFeatureTotal(0), Reinit(false), hiddenface(NULL), Lindex_polygon(),
62 Lindex_polygon_tracked(), isvisible(false)
74 for(
unsigned int i = 0 ; i <
meline.size() ; i++)
126 double norm = sqrt(A*A+B*B+C*C) ;
150 buildPlane(P1,P2,P3,plane1) ;
151 buildPlane(P1,P2,P4,plane2) ;
188 if(std::fabs((V1-V2).sumSquare()) > std::numeric_limits<double>::epsilon())
191 V3[0]=double(rand()%1000)/100;
192 V3[1]=double(rand()%1000)/100;
193 V3[2]=double(rand()%1000)/100;
236 unsigned int ind = 0;
238 if((*
hiddenface)[(unsigned)(*itpoly)]->getName() == polyname){
244 isTrackedLine =
false;
248 isTrackedLine =
true;
253 isTrackedLineWithVisibility =
false;
268 isTrackedLineWithVisibility =
false;
272 unsigned int ind = 0;
273 isTrackedLineWithVisibility =
false;
276 isTrackedLineWithVisibility =
true;
293 for(
unsigned int i = 0 ; i <
meline.size() ; i++)
316 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
336 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
345 if(linesLst.size() == 0){
365 while (theta > M_PI) { theta -= M_PI ; }
366 while (theta < -M_PI) { theta += M_PI ; }
368 if (theta < -M_PI/2.0) theta = -theta - 3*M_PI/2.0;
369 else 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 ;
382 melinePt->setMe(me) ;
385 melinePt->setInitRange(0);
388 if (ip1.
get_j()<ip2.
get_j()) { melinePt->jmin = (int)ip1.
get_j()-marge ; melinePt->jmax = (int)ip2.
get_j()+marge ; }
else{ melinePt->jmin = (int)ip2.
get_j()-marge ; melinePt->jmax = (int)ip1.
get_j()+marge ; }
389 if (ip1.
get_i()<ip2.
get_i()) { melinePt->imin = (int)ip1.
get_i()-marge ; melinePt->imax = (int)ip2.
get_i()+marge ; }
else{ melinePt->imin = (int)ip2.
get_i()-marge ; melinePt->imax = (int)ip1.
get_i()+marge ; }
393 melinePt->initTracking(I,ip1,ip2,rho,theta);
394 meline.push_back(melinePt);
452 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
460 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
494 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
503 if(linesLst.size() !=
meline.size() || linesLst.size() == 0){
504 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
531 while (theta > M_PI) { theta -= M_PI ; }
532 while (theta < -M_PI) { theta += M_PI ; }
534 if (theta < -M_PI/2.0) theta = -theta - 3*M_PI/2.0;
535 else theta = M_PI/2.0 - theta;
540 for(
unsigned int i = 0 ; i < linesLst.size() ; i++){
543 linesLst[i].first.project();
544 linesLst[i].second.project();
553 meline[i]->updateParameters(I,ip1,ip2,rho,theta) ;
560 for(
unsigned int j = 0 ; j <
meline.size() ; j++){
573 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
596 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
644 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
652 for(
unsigned int i = 0 ; i < linesLst.size() ; i++){
653 linesLst[i].first.project();
654 linesLst[i].second.project();
679 const unsigned int thickness,
const bool displayFullModel)
700 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
708 for(
unsigned int i = 0 ; i < linesLst.size() ; i++){
709 linesLst[i].first.project();
710 linesLst[i].second.project();
735 for(
unsigned int i = 0 ; i <
meline.size() ; i++)
754 for(
unsigned int i = 0 ; i <
meline.size() ; i++)
774 double rho = featureline.
getRho() ;
775 double theta = featureline.
getTheta() ;
777 double co = cos(theta);
778 double si = sin(theta);
780 double mx = 1.0/cam.
get_px() ;
781 double my = 1.0/cam.
get_py() ;
782 double xc = cam.
get_u0() ;
783 double yc = cam.
get_v0() ;
793 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
794 for(std::list<vpMeSite>::const_iterator it=
meline[i]->getMeList().begin(); it!=
meline[i]->getMeList().end(); ++it){
801 alpha_ = x*si - y*co;
803 double *Lrho = H[0] ;
804 double *Ltheta = H[1] ;
806 for (
unsigned int k=0 ; k < 6 ; k++)
808 L[j][k] = (Lrho[k] + alpha_*Ltheta[k]);
810 error[j] = rho - ( x*co + y*si) ;
832 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
833 for(std::list<vpMeSite>::const_iterator it=
meline[i]->getMeList().begin(); it!=
meline[i]->getMeList().end(); ++it){
837 if(i_ < 0 || j_ < 0){
841 if( ((
unsigned int)i_ > (I.
getHeight()- threshold) ) || (
unsigned int)i_ < threshold ||
842 ((
unsigned int)j_ > (I.
getWidth ()- threshold) ) || (
unsigned int)j_ < threshold ) {
Implementation of a matrix and operations on matrices.
void setD(const double d)
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.
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)
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)
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
Vector of bool associated with Lindex_polygon to know if Lindex_polygon[i] is 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.
vpPoint * p
corners in the object frame
bool isvisible
Indicates if the line is visible or not.
Class that defines what is a point.
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)
std::vector< vpMbtMeLine * > meline
The moving edge container.
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.
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)
std::vector< std::pair< vpPoint, unsigned int > > polyClipped
Region of interest clipped.
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).
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 ...
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
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)
std::vector< unsigned int > nbFeature
The number of moving edges.
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void initInteractionMatrixError()
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)