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) ;
191 if(std::fabs((V1-V2).sumSquare()) > std::numeric_limits<double>::epsilon())
194 V3[0]=double(rand()%1000)/100;
195 V3[1]=double(rand()%1000)/100;
196 V3[2]=double(rand()%1000)/100;
239 unsigned int ind = 0;
241 if((*
hiddenface)[(unsigned)(*itpoly)]->getName() == polyname){
247 isTrackedLine =
false;
251 isTrackedLine =
true;
256 isTrackedLineWithVisibility =
false;
271 isTrackedLineWithVisibility =
false;
275 unsigned int ind = 0;
276 isTrackedLineWithVisibility =
false;
279 isTrackedLineWithVisibility =
true;
296 for(
unsigned int i = 0 ; i <
meline.size() ; i++)
319 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
339 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
348 if(linesLst.size() == 0){
368 while (theta > M_PI) { theta -= M_PI ; }
369 while (theta < -M_PI) { theta += M_PI ; }
371 if (theta < -M_PI/2.0) theta = -theta - 3*M_PI/2.0;
372 else theta = M_PI/2.0 - theta;
375 for(
unsigned int i = 0 ; i < linesLst.size() ; i++){
378 linesLst[i].first.project();
379 linesLst[i].second.project();
384 vpMbtMeLine *melinePt =
new vpMbtMeLine ;
385 melinePt->setMe(me) ;
388 melinePt->setInitRange(0);
391 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 ; }
392 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 ; }
396 melinePt->initTracking(I,ip1,ip2,rho,theta);
397 meline.push_back(melinePt);
454 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
462 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
496 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++){
533 while (theta > M_PI) { theta -= M_PI ; }
534 while (theta < -M_PI) { theta += M_PI ; }
536 if (theta < -M_PI/2.0) theta = -theta - 3*M_PI/2.0;
537 else theta = M_PI/2.0 - theta;
542 for(
unsigned int i = 0 ; i < linesLst.size() ; i++){
545 linesLst[i].first.project();
546 linesLst[i].second.project();
555 meline[i]->updateParameters(I,ip1,ip2,rho,theta) ;
562 for(
unsigned int j = 0 ; j <
meline.size() ; j++){
575 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
598 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
627 if( (
isvisible && isTrackedLine) || displayFullModel){
646 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
654 for(
unsigned int i = 0 ; i < linesLst.size() ; i++){
655 linesLst[i].first.project();
656 linesLst[i].second.project();
681 const unsigned int thickness,
const bool displayFullModel)
683 if( (
isvisible && isTrackedLine) || displayFullModel){
702 std::vector<std::pair<vpPoint, vpPoint> > linesLst;
710 for(
unsigned int i = 0 ; i < linesLst.size() ; i++){
711 linesLst[i].first.project();
712 linesLst[i].second.project();
737 for(
unsigned int i = 0 ; i <
meline.size() ; i++)
756 for(
unsigned int i = 0 ; i <
meline.size() ; i++)
776 double rho = featureline.
getRho() ;
777 double theta = featureline.
getTheta() ;
779 double co = cos(theta);
780 double si = sin(theta);
782 double mx = 1.0/cam.
get_px() ;
783 double my = 1.0/cam.
get_py() ;
784 double xc = cam.
get_u0() ;
785 double yc = cam.
get_v0() ;
795 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
796 for(std::list<vpMeSite>::const_iterator it=
meline[i]->getMeList().begin(); it!=
meline[i]->getMeList().end(); ++it){
803 alpha_ = x*si - y*co;
805 double *Lrho = H[0] ;
806 double *Ltheta = H[1] ;
808 for (
unsigned int k=0 ; k < 6 ; k++)
810 L[j][k] = (Lrho[k] + alpha_*Ltheta[k]);
812 error[j] = rho - ( x*co + y*si) ;
834 for(
unsigned int i = 0 ; i <
meline.size() ; i++){
835 for(std::list<vpMeSite>::const_iterator it=
meline[i]->getMeList().begin(); it!=
meline[i]->getMeList().end(); ++it){
839 if(i_ < 0 || j_ < 0){
843 if( ((
unsigned int)i_ > (I.
getHeight()- threshold) ) || (
unsigned int)i_ < threshold ||
844 ((
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 ...
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
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)