39 #include <visp/vpMbEdgeKltTracker.h>
41 #ifdef VISP_HAVE_OPENCV
91 unsigned int i=
scales.size();
142 unsigned int i=
scales.size();
177 unsigned int nbrow = 0;
178 for(std::list<vpMbtDistanceLine*>::iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
184 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
274 #ifdef VISP_HAVE_XML2
278 vpTRACE(
"You need the libXML2 to read the config file %s", configFile);
303 const unsigned int lvl)
313 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
321 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
368 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
372 std::list<vpMeSite>::iterator itListLine;
375 for (
unsigned int i=0 ; i < l->
nbFeature ; i++){
402 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
405 std::list<vpMeSite>::iterator itListCyl1;
406 std::list<vpMeSite>::iterator itListCyl2;
437 for(
unsigned int i=cy->
nbFeaturel1 ; i < cy->nbFeature ; i++){
479 if(nbrow < 4 && nbInfos < 4){
487 double residu_1 = -1;
488 unsigned int iter = 0;
504 J_klt.
resize(2*nbInfos,6);
510 vpRobust robust_mbt(0), robust_klt(0);
515 double factorMBT = 1.0;
516 double factorKLT = 1.0;
524 double residuMBT = 0;
525 double residuKLT = 0;
527 while( ((
int)((residu - residu_1)*1e8) !=0 ) && (iter<
maxIter) ){
535 unsigned int shift = 0;
548 w.
resize(nbrow + 2*nbInfos);
557 robust_klt.
resize(2*nbInfos);
559 w_true.
resize(nbrow + 2*nbInfos);
565 for(
unsigned int i = 0; i < R_mbt.
getRows(); i++)
566 residuMBT += fabs(R_mbt[i]);
569 robust_mbt.setIteration(iter);
578 for(
unsigned int i = 0; i < R_klt.
getRows(); i++)
579 residuKLT += fabs(R_klt[i]);
590 unsigned int cpt = 0;
591 while(cpt< (nbrow+2*nbInfos)){
592 if(cpt<(
unsigned)nbrow){
593 w[cpt] = ((w_mbt[cpt] * factor[cpt]) * factorMBT) ;
596 w[cpt] = (w_klt[cpt-nbrow] * factorKLT);
609 for (
unsigned int i = 0; i < static_cast<unsigned int>(R->
getRows()); i++){
613 w_true[i] = w[i]*w[i];
616 for (
unsigned int j = 0; j < 6; j += 1){
622 residu = sqrt(num/den);
653 unsigned int nbInfos;
654 unsigned int nbFaceUsed;
663 std::cout <<
"[ERROR] Unable to init with KLT" << std::endl;
699 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
716 std::list<vpMeSite>::const_iterator itListLine;
720 for (
unsigned int i=0 ; i < l->
nbFeature ; i++){
729 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
734 std::list<vpMeSite>::const_iterator itCyl1;
735 std::list<vpMeSite>::const_iterator itCyl2;
741 for(
unsigned int i=0 ; i < cy->
nbFeature ; i++){
744 if(i<cy->nbFeaturel1) {
769 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
772 for (
unsigned int i=0 ; i < l->
nbFeature ; i++){
773 for (
unsigned int j=0; j < 6 ; j++){
774 L[n+i][j] = l->
L[i][j];
775 error[n+i] = l->
error[i];
781 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
784 for(
unsigned int i=0 ; i < cy->
nbFeature ; i++){
785 for(
unsigned int j=0; j < 6 ; j++){
786 L[n+i][j] = cy->
L[i][j];
787 error[n+i] = cy->
error[i];
849 const vpColor& col ,
const unsigned int thickness,
const bool displayFullModel)
853 for (
unsigned int i = 0; i <
scales.size(); i += 1){
856 (*it)->display(I, cMo, cam, col, thickness);
875 const vpColor& col ,
const unsigned int thickness,
const bool displayFullModel)
879 for (
unsigned int i = 0; i <
scales.size(); i += 1){
882 (*it)->display(I, cMo, cam, col, thickness);
889 #endif //VISP_HAVE_OPENCV
void setWindowName(const Ogre::String &n)
void trackSecondLoop(const vpImage< unsigned char > &I, vpMatrix &L, vpColVector &_error, vpHomogeneousMatrix &cMo, const unsigned int lvl=0)
double lambda
The gain of the virtual visual servoing stage.
void postTrackingMbt(vpColVector &w, const unsigned int level=0)
Definition of the vpMatrix class.
void displayMovingEdges(const vpImage< unsigned char > &I)
vpMatrix covarianceMatrix
Covariance matrix.
void setMaxIter(const unsigned int max)
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
void upScale(const unsigned int _scale)
void MEstimator(const vpRobustEstimatorType method, const vpColVector &residues, vpColVector &weights)
Compute the weights according a residue vector and a PsiFunction.
bool isAppearing(const unsigned int i)
bool Reinit
Indicates if the line has to be reinitialized.
void setMeanWeight2(const double wmean)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void init(const vpImage< unsigned char > &I)
unsigned int scaleLevel
Current scale level used. This attribute must not be modified outsied of the downScale() and upScale(...
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'...
Class to define colors available for display functionnalities.
vpHomogeneousMatrix cMo
The current pose.
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w)
void displayMovingEdges(const vpImage< unsigned char > &I)
double thresholdKLT
The threshold used in the robust estimation of KLT.
error that can be emited by ViSP classes.
void computeJTR(const vpMatrix &J, const vpColVector &R, vpMatrix &JTR)
Manage a cylinder used in the model-based tracker.
Manage the line of a polygon used in the model-based tracker.
unsigned int nbFeature
The number of moving edges.
std::vector< const vpImage< unsigned char > * > Ipyramid
Pyramid of image associated to the current image. This pyramid is compted in the init() and in the tr...
Definition of the vpSubMatrix vpSubMatrix class provides a mask on a vpMatrix all properties of vpMat...
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
void loadConfigFile(const std::string &configFile)
void updateMovingEdge(const vpImage< unsigned char > &I)
std::vector< std::list< vpMbtDistanceLine * > > lines
Vector of list of all the lines tracked (each line is linked to a list of moving edges). Each element of the vector is for a scale (element 0 = level 0 = no subsampling).
void initInteractionMatrixError()
static vpMatrix computeCovarianceMatrix(const vpMatrix &A, const vpColVector &x, const vpColVector &b)
virtual void reinit(const vpImage< unsigned char > &I)
virtual ~vpMbEdgeKltTracker()
unsigned int nbFeature
The number of moving edges.
void downScale(const unsigned int _scale)
Class that defines what is a point.
virtual void loadConfigFile(const std::string &configFile)
vpMatrix L
The interaction matrix.
vpMeSiteState getState() const
vpCameraParameters cam
The camera parameters.
virtual void init(const vpImage< unsigned char > &I)
vpHomogeneousMatrix ctTc0
The estimated displacement of the pose between the current instant and the initial position...
unsigned int nbFeaturel1
The number of moving edges on line 1.
This class aims to compute the homography wrt.two images.
vpAROgre * getOgreContext()
void setMeanWeight(const double wmean)
std::vector< bool > scales
Vector of scale level to use for the multi-scale tracking.
Error that can be emited by the vpTracker class and its derivates.
void initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
static double sqr(double x)
virtual void initCylinder(const vpPoint &_p1, const vpPoint _p2, const double _radius, const unsigned int _indexCylinder=0)
vpColVector error
The error vector.
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual void track(const vpImage< unsigned char > &I)
Definition of the vpSubColVector vpSubColVector class provides a mask on a vpColVector all properties...
virtual 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)
Generic class defining intrinsic camera parameters.
virtual void loadModel(const std::string &modelFile)
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > * > &_pyramid)
void cleanPyramid(std::vector< const vpImage< unsigned char > * > &_pyramid)
vpMbHiddenFaces< vpMbtKltPolygon > faces
Set of faces describing the object.
virtual void initFaceFromCorners(const std::vector< vpPoint > &corners, const unsigned int indexFace=-1)
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder)
bool compute_interaction
If true, compute the interaction matrix at each iteration of the minimisation. Otherwise, compute it only on the first iteration.
bool firstTrack
First track() called.
virtual void initFaceFromCorners(const std::vector< vpPoint > &_corners, const unsigned int _indexFace=-1)
std::list< vpMeSite > & getMeList()
void loadConfigFile(const char *configFile)
void setState(const vpMeSiteState &flag)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
void setMeanWeight1(const double wmean)
virtual void setCameraParameters(const vpCameraParameters &cam)
static vpMatrix stackMatrices(const vpMatrix &A, const vpMatrix &B)
Stack two Matrices C = [ A B ]^T.
void diag(const vpColVector &A)
void preTracking(const vpImage< unsigned char > &I, unsigned int &nbInfos, unsigned int &nbFaceUsed)
unsigned int maxIter
The maximum iteration of the virtual visual servoing stage.
bool closeToImageBorder(const vpImage< unsigned char > &I, const unsigned int threshold)
bool displayFeatures
If true, the features are displayed.
void setCameraParameters(const vpCameraParameters &cam)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
std::vector< std::list< vpMbtDistanceCylinder * > > cylinders
Vector of the tracked cylinders.
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo)
unsigned int initMbtTracking(const unsigned int level=0)
vpHomogeneousMatrix inverse() const
unsigned int trackFirstLoop(const vpImage< unsigned char > &I, vpColVector &factor, const unsigned int lvl=0)
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
static vpHomogeneousMatrix direct(const vpColVector &v)
Contains an M-Estimator and various influence function.
virtual void initFaceFromCorners(const std::vector< vpPoint > &corners, const unsigned int indexFace=-1)
unsigned int nbvisiblepolygone
Number of polygon (face) currently visible.
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w_mbt, vpColVector &w_klt, const unsigned int lvl=0)
vpColVector error
The error vector.
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Compute the pseudo inverse of the matrix using the SVD.
bool Reinit
Indicates if the line has to be reinitialized.
virtual void init(const vpImage< unsigned char > &I)
virtual void setCameraParameters(const vpCameraParameters &cam)
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
void trackMovingEdge(const vpImage< unsigned char > &I)
unsigned int nbFeaturel2
The number of moving edges on line 2.
void setThreshold(const double noise_threshold)
unsigned int getRows() const
Return the number of rows of the matrix.
virtual void initCylinder(const vpPoint &, const vpPoint, const double, const unsigned int)
void resize(unsigned int n_data)
Resize containers for sort methods.
vpMbtMeLine * meline2
The moving edge containers (second line of the cylinder)
void setIteration(const unsigned int iter)
Set iteration.
vpMatrix L
The interaction matrix.
void computeVVS(const unsigned int &nbInfos, vpColVector &w)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo, const vpImage< unsigned char > &I)
void initInteractionMatrixError()
vpMbtMeLine * meline
The moving edge container.
virtual void loadModel(const std::string &modelFile)
double thresholdMBT
The threshold used in the robust estimation of MBT.
virtual 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)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
void resize(const unsigned int i, const bool flagNullify=true)
void computeVVS(const vpImage< unsigned char > &I, const unsigned int &nbInfos, vpColVector &w_mbt, vpColVector &w_klt, const unsigned int lvl=0)