42 #include <visp/vpMbEdgeKltTracker.h>
44 #ifdef VISP_HAVE_OPENCV
94 unsigned int i = (
unsigned int)
scales.size();
145 unsigned int i = (
unsigned int)
scales.size();
180 unsigned int nbrow = 0;
181 for(std::list<vpMbtDistanceLine*>::iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
187 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
280 #ifdef VISP_HAVE_XML2
284 vpTRACE(
"You need the libXML2 to read the config file %s", configFile);
309 const unsigned int lvl)
319 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
327 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
374 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
378 std::list<vpMeSite>::iterator itListLine;
381 for (
unsigned int i=0 ; i < l->
nbFeature ; i++){
408 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
411 std::list<vpMeSite>::iterator itListCyl1;
412 std::list<vpMeSite>::iterator itListCyl2;
443 for(
unsigned int i=cy->
nbFeaturel1 ; i < cy->nbFeature ; i++){
485 if(nbrow < 4 && nbInfos < 4){
493 double residu_1 = -1;
494 unsigned int iter = 0;
510 J_klt.
resize(2*nbInfos,6);
516 vpRobust robust_mbt(0), robust_klt(0);
521 double factorMBT = 1.0;
522 double factorKLT = 1.0;
530 double residuMBT = 0;
531 double residuKLT = 0;
533 while( ((
int)((residu - residu_1)*1e8) !=0 ) && (iter<
maxIter) ){
541 unsigned int shift = 0;
554 w.
resize(nbrow + 2*nbInfos);
563 robust_klt.
resize(2*nbInfos);
565 w_true.
resize(nbrow + 2*nbInfos);
571 for(
unsigned int i = 0; i < R_mbt.
getRows(); i++)
572 residuMBT += fabs(R_mbt[i]);
575 robust_mbt.setIteration(iter);
584 for(
unsigned int i = 0; i < R_klt.
getRows(); i++)
585 residuKLT += fabs(R_klt[i]);
596 unsigned int cpt = 0;
597 while(cpt< (nbrow+2*nbInfos)){
598 if(cpt<(
unsigned)nbrow){
599 w[cpt] = ((w_mbt[cpt] * factor[cpt]) * factorMBT) ;
602 w[cpt] = (w_klt[cpt-nbrow] * factorKLT);
615 for (
unsigned int i = 0; i < static_cast<unsigned int>(R->
getRows()); i++){
619 w_true[i] = w[i]*w[i];
622 for (
unsigned int j = 0; j < 6; j += 1){
628 residu = sqrt(num/den);
659 unsigned int nbInfos;
660 unsigned int nbFaceUsed;
693 unsigned int i = (
unsigned int)
scales.size();
729 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
746 std::list<vpMeSite>::const_iterator itListLine;
750 for (
unsigned int i=0 ; i < l->
nbFeature ; i++){
759 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
764 std::list<vpMeSite>::const_iterator itCyl1;
765 std::list<vpMeSite>::const_iterator itCyl2;
771 for(
unsigned int i=0 ; i < cy->
nbFeature ; i++){
774 if(i<cy->nbFeaturel1) {
799 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
802 for (
unsigned int i=0 ; i < l->
nbFeature ; i++){
803 for (
unsigned int j=0; j < 6 ; j++){
804 L[n+i][j] = l->
L[i][j];
805 error[n+i] = l->
error[i];
811 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
814 for(
unsigned int i=0 ; i < cy->
nbFeature ; i++){
815 for(
unsigned int j=0; j < 6 ; j++){
816 L[n+i][j] = cy->
L[i][j];
817 error[n+i] = cy->
error[i];
879 const vpColor& col ,
const unsigned int thickness,
const bool displayFullModel)
883 for (
unsigned int i = 0; i <
scales.size(); i += 1){
887 l->
display(I,cMo, cam, col, thickness, displayFullModel);
891 (*it)->display(I, cMo, cam, col, thickness);
904 #ifdef VISP_HAVE_OGRE
922 const vpColor& col ,
const unsigned int thickness,
const bool displayFullModel)
926 for (
unsigned int i = 0; i <
scales.size(); i += 1){
930 l->
display(I,cMo, cam, col, thickness, displayFullModel);
934 (*it)->display(I, cMo, cam, col, thickness);
947 #ifdef VISP_HAVE_OGRE
953 #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 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...
unsigned int scaleLevel
Current scale level used. This attribute must not be modified outside 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 computed in the init() and in the t...
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
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)
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)
bool useOgre
Use Ogre3d for visibility tests.
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 minimization. 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.
virtual void setMaxIter(const unsigned int max)
void diag(const vpColVector &A)
void preTracking(const vpImage< unsigned char > &I, unsigned int &nbInfos, unsigned int &nbFaceUsed)
unsigned int size() const
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)
bool isVisible(const unsigned int i)
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.
void displayOgre(const vpHomogeneousMatrix &_cMo)
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 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)