45 #include <visp3/core/vpDebug.h>
46 #include <visp3/vision/vpPose.h>
47 #include <visp3/core/vpExponentialMap.h>
48 #include <visp3/core/vpPixelMeterConversion.h>
49 #include <visp3/core/vpRobust.h>
50 #include <visp3/core/vpMatrixException.h>
51 #include <visp3/core/vpMath.h>
52 #include <visp3/core/vpException.h>
53 #include <visp3/core/vpTrackingException.h>
54 #include <visp3/mbt/vpMbEdgeTracker.h>
55 #include <visp3/mbt/vpMbtDistanceLine.h>
56 #include <visp3/mbt/vpMbtXmlParser.h>
57 #include <visp3/core/vpPolygon3D.h>
58 #include <visp3/core/vpVelocityTwistMatrix.h>
66 bool samePoint(
const vpPoint &P1,
const vpPoint &P2,
double threshold);
72 : compute_interaction(1), lambda(1), me(), lines(1), circles(1), cylinders(1), nline(0), ncircle(0), ncylinder(0),
73 nbvisiblepolygone(0), percentageGdPt(0.4), scales(1),
74 Ipyramid(0), scaleLevel(0)
95 for (
unsigned int i = 0; i <
scales.size(); i += 1){
97 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
105 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[i].begin(); it!=
cylinders[i].end(); ++it){
117 for (
unsigned int i = 0; i <
circles.size(); i += 1){
118 for(std::list<vpMbtDistanceCircle*>::const_iterator it=
circles[i].begin(); it!=
circles[i].end(); ++it){
140 for (
unsigned int i = 0; i <
scales.size(); i += 1){
142 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
143 (*it)->setMovingEdge(&(this->
me)) ;
147 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[i].begin(); it!=
cylinders[i].end(); ++it){
153 for(std::list<vpMbtDistanceCircle*>::const_iterator it=
circles[i].begin(); it!=
circles[i].end(); ++it){
172 double residu_1 =1e3;
188 unsigned int iter = 0;
191 unsigned int nbrow = 0;
192 unsigned int nberrors_lines = 0;
193 unsigned int nberrors_cylinders = 0;
194 unsigned int nberrors_circles = 0;
245 double e_prev = 0, e_cur, e_next;
255 while ( reloop ==
true && iter<10)
259 weighted_error.
resize(nerror) ;
271 if((*it)->isTracked())
280 int index = *itindex;
294 std::list<vpMeSite>::const_iterator itListLine;
296 unsigned int indexFeature = 0;
298 for(
unsigned int a = 0 ; a < l->
meline.size() ; a++)
300 if (iter == 0 && l->
meline[a] != NULL)
301 itListLine = l->
meline[a]->getMeList().begin();
303 for (
unsigned int i=0 ; i < l->
nbFeature[a] ; i++)
305 for (
unsigned int j=0; j < 6 ; j++)
307 L[n+i][j] = l->
L[indexFeature][j];
311 if (
m_error[n+i] <= limite) count = count+1.0;
324 if (indexFeature == 0)
329 e_next = l->
error[1];
342 e_cur = l->
error[indexFeature];
351 e_cur = l->
error[indexFeature];
352 e_next = l->
error[indexFeature+1];
353 if ( fabs(e_cur - e_prev) < limite )
357 if ( fabs(e_cur - e_next) < limite )
370 if((*it)->isTracked())
376 std::list<vpMeSite>::const_iterator itCyl1;
377 std::list<vpMeSite>::const_iterator itCyl2;
379 itCyl1 = cy->
meline1->getMeList().begin();
380 itCyl2 = cy->
meline2->getMeList().begin();
383 for(
unsigned int i=0 ; i < cy->
nbFeature ; i++){
384 for(
unsigned int j=0; j < 6 ; j++){
385 L[n+i][j] = cy->
L[i][j];
389 if (
m_error[n+i] <= limite) count = count+1.0;
397 if(i<cy->nbFeaturel1) {
411 e_cur = cy->
error[0];
414 e_next = cy->
error[1];
425 e_cur = cy->
error[i];
428 e_next = cy->
error[i+1];
441 e_cur = cy->
error[i];
450 e_cur = cy->
error[i];
459 e_cur = cy->
error[i];
460 e_next = cy->
error[i+1];
461 if ( fabs(e_cur - e_prev) < limite ){
464 if ( fabs(e_cur - e_next) < limite ){
476 if((*it)->isTracked())
482 std::list<vpMeSite>::const_iterator itCir;
483 if (iter == 0 && (ci->
meEllipse != NULL)) {
484 itCir = ci->
meEllipse->getMeList().begin();
487 for(
unsigned int i=0 ; i < ci->
nbFeature ; i++){
488 for(
unsigned int j=0; j < 6 ; j++){
489 L[n+i][j] = ci->
L[i][j];
493 if (
m_error[n+i] <= limite) count = count+1.0;
508 e_cur = ci->
error[0];
511 e_next = ci->
error[1];
524 e_cur = ci->
error[i];
533 e_cur = ci->
error[i];
534 e_next = ci->
error[i+1];
535 if ( fabs(e_cur - e_prev) < limite ){
538 if ( fabs(e_cur - e_next) < limite ){
549 count = count / (double)nbrow;
557 double wi ;
double eri ;
558 for(
unsigned int i = 0; i < nerror; i++){
559 wi =
m_w[i]*factor[i];
564 weighted_error[i] = wi*eri ;
568 for (
unsigned int i=0 ; i < nerror ; i++){
569 for (
unsigned int j=0 ; j < 6 ; j++){
570 L[i][j] =
m_w[i]*factor[i]*L[i][j] ;
578 if (isoJoIdentity_) {
582 unsigned int rank = (L*cVo).kernel(K);
591 isoJoIdentity_ =
false;
620 vpRobust robust_lines(nberrors_lines);
621 vpRobust robust_cylinders(nberrors_cylinders);
622 vpRobust robust_circles(nberrors_circles);
643 while ( ((
int)((residu_1 - r)*1e8) !=0 ) && (iter<30))
646 unsigned int nlines = 0;
647 unsigned int ncylinders = 0;
648 unsigned int ncircles = 0;
650 if((*it)->isTracked()){
654 for (
unsigned int j=0; j < 6 ; j++){
655 L[n+i][j] = l->
L[i][j];
657 error_lines[nlines+i] =
m_error[n+i];
666 if((*it)->isTracked()){
669 for(
unsigned int i=0 ; i < cy->
nbFeature ; i++){
670 for(
unsigned int j=0; j < 6 ; j++){
671 L[n+i][j] = cy->
L[i][j];
673 error_cylinders[ncylinders+i] =
m_error[n+i];
683 if((*it)->isTracked()){
686 for(
unsigned int i=0 ; i < ci->
nbFeature ; i++){
687 for(
unsigned int j=0; j < 6 ; j++){
688 L[n+i][j] = ci->
L[i][j];
690 error_circles[ncircles+i] =
m_error[n+i];
699 bool reStartFromLastIncrement =
false;
710 reStartFromLastIncrement =
true;
714 if(!reStartFromLastIncrement){
717 weighted_error.
resize(nerror);
720 w_lines.
resize(nberrors_lines);
722 w_cylinders.
resize(nberrors_cylinders);
724 w_circles.
resize(nberrors_circles);
730 if(nberrors_lines > 0)
732 if(nberrors_cylinders > 0)
734 if(nberrors_circles > 0)
742 if(nberrors_lines > 0)
744 if(nberrors_cylinders > 0)
746 if(nberrors_circles > 0)
750 unsigned int cpt = 0;
752 if(cpt<nberrors_lines){
753 m_w[cpt] = w_lines[cpt];
755 else if (cpt<nberrors_lines+nberrors_cylinders){
756 m_w[cpt] = w_cylinders[cpt-nberrors_lines];
759 m_w[cpt] = w_circles[cpt-nberrors_lines-nberrors_cylinders];
776 LVJ_true = (L*cVo*
oJo);
780 for(
unsigned int i=0; i<nerror; i++){
781 wi =
m_w[i]*factor[i];
787 weighted_error[i] = wi*eri ;
791 for (
unsigned int i=0 ; i < nerror ; i++){
792 for (
unsigned int j=0 ; j < 6 ; j++){
793 L[i][j] =
m_w[i]*factor[i]*L[i][j];
834 vpMatrix LTLmuI = LVJTLVJ + (LMA*mu);
882 if((*it)->isTracked()){
884 unsigned int indexLine = 0;
886 for(
unsigned int a = 0 ; a < l->
meline.size() ; a++)
888 std::list<vpMeSite>::iterator itListLine;
889 if (l->
nbFeature[a] > 0) itListLine = l->
meline[a]->getMeList().begin();
891 for (
unsigned int i=0 ; i < l->
nbFeature[a] ; i++){
892 wmean +=
m_w[n+indexLine] ;
894 if (
m_w[n+indexLine] < 0.5){
920 if((*it)->isTracked()){
923 std::list<vpMeSite>::iterator itListCyl1;
924 std::list<vpMeSite>::iterator itListCyl2;
927 itListCyl1 = cy->
meline1->getMeList().begin();
928 itListCyl2 = cy->
meline2->getMeList().begin();
956 for(
unsigned int i=cy->
nbFeaturel1 ; i < cy->nbFeature ; i++){
985 if((*it)->isTracked()){
988 std::list<vpMeSite>::iterator itListCir;
991 itListCir = ci->
meEllipse->getMeList().begin();
995 for(
unsigned int i=0 ; i < ci->
nbFeature ; i++){
1035 unsigned int nbFeatures = 0;
1040 for(
unsigned int a = 0 ; a < l->
meline.size() ; a++){
1041 if(l->
meline[a] != NULL){
1042 double lineNormGradient;
1043 unsigned int lineNbFeatures;
1044 l->
meline[a]->computeProjectionError(_I, lineNormGradient, lineNbFeatures);
1046 nbFeatures += lineNbFeatures;
1059 double cylinderNormGradient = 0;
1060 unsigned int cylinderNbFeatures = 0;
1061 cy->
meline1->computeProjectionError(_I, cylinderNormGradient, cylinderNbFeatures);
1063 nbFeatures += cylinderNbFeatures;
1068 double cylinderNormGradient = 0;
1069 unsigned int cylinderNbFeatures = 0;
1070 cy->
meline2->computeProjectionError(_I, cylinderNormGradient, cylinderNbFeatures);
1072 nbFeatures += cylinderNbFeatures;
1082 double circleNormGradient = 0;
1083 unsigned int circleNbFeatures = 0;
1084 c->
meEllipse->computeProjectionError(_I, circleNormGradient, circleNbFeatures);
1086 nbFeatures += circleNbFeatures;
1105 int nbExpectedPoint = 0;
1106 int nbGoodPoint = 0;
1114 for(
unsigned int a = 0 ; a < l->
meline.size() ; a++){
1115 if(l->
meline[a] != NULL){
1116 nbExpectedPoint += (int)l->
meline[a]->expecteddensity;
1117 for(std::list<vpMeSite>::const_iterator itme=l->
meline[a]->getMeList().begin(); itme!=l->
meline[a]->getMeList().end(); ++itme){
1132 nbExpectedPoint += (int)cy->
meline1->expecteddensity;
1133 for(std::list<vpMeSite>::const_iterator itme1=cy->
meline1->getMeList().begin(); itme1!=cy->
meline1->getMeList().end(); ++itme1){
1138 nbExpectedPoint += (int)cy->
meline2->expecteddensity;
1139 for(std::list<vpMeSite>::const_iterator itme2=cy->
meline2->getMeList().begin(); itme2!=cy->
meline2->getMeList().end(); ++itme2){
1152 nbExpectedPoint += ci->
meEllipse->getExpectedDensity();
1153 for(std::list<vpMeSite>::const_iterator itme=ci->
meEllipse->getMeList().begin(); itme!=ci->
meEllipse->getMeList().end(); ++itme){
1165 if (nbGoodPoint < nb_min || nbExpectedPoint < 2) {
1166 std::ostringstream oss;
1167 oss <<
"Not enough moving edges ("
1169 <<
") to track the object: expected "
1171 <<
". Try to reduce the threshold="
1173 <<
" using vpMbTracker::setGoodMovingEdgesRatioThreshold()";
1191 unsigned int lvl = (
unsigned int)
scales.size();
1209 vpTRACE(
"Error in moving edge tracking") ;
1264 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[lvl].begin(); it!=
lines[lvl].end(); ++it){
1271 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[lvl].begin(); it!=
cylinders[lvl].end(); ++it){
1278 for(std::list<vpMbtDistanceCircle*>::const_iterator it=
circles[lvl].begin(); it!=
circles[lvl].end(); ++it){
1288 bool newvisibleface = false ;
1346 #ifdef VISP_HAVE_OGRE
1363 unsigned int i = (
unsigned int)
scales.size();
1469 #ifdef VISP_HAVE_XML2
1478 std::cout <<
" *********** Parsing XML for Mb Edge Tracker ************ " << std::endl;
1479 xmlp.
parse(configFile);
1488 xmlp.
getMe(meParser);
1517 vpTRACE(
"You need the libXML2 to read the config file %s", configFile);
1535 const unsigned int thickness,
const bool displayFullModel)
1537 for (
unsigned int i = 0; i <
scales.size(); i += 1){
1540 (*it)->display(I,cMo_, camera, col, thickness, displayFullModel);
1544 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1548 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1555 #ifdef VISP_HAVE_OGRE
1574 const unsigned int thickness,
const bool displayFullModel)
1576 for (
unsigned int i = 0; i <
scales.size(); i += 1){
1579 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel) ;
1583 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel) ;
1587 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1593 #ifdef VISP_HAVE_OGRE
1614 bool isvisible = false ;
1617 int index = *itindex;
1618 if (index ==-1) isvisible =true ;
1638 for(
unsigned int a = 0 ; a < l->
meline.size() ; a++){
1651 bool isvisible = false ;
1654 if (index ==-1) isvisible =true ;
1689 bool isvisible = false ;
1692 if (index ==-1) isvisible =true ;
1730 if(l->
meline.size() == 0){
1771 if((*it)->isTracked()){
1782 if((*it)->isTracked()){
1793 if((*it)->isTracked()){
1817 if((*it)->isTracked()){
1826 if((*it)->isTracked()){
1835 if((*it)->isTracked()){
1845 for (
unsigned int i = 0; i <
scales.size(); i += 1){
1847 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
1848 for(
unsigned int a = 0 ; a < (*it)->meline.size() ; a++){
1849 if((*it)->meline[a] != NULL){
1850 delete (*it)->meline[a];
1851 (*it)->meline[a] = NULL;
1853 (*it)->meline.clear();
1854 (*it)->nbFeature.clear();
1855 (*it)->nbFeatureTotal = 0;
1859 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[i].begin(); it!=
cylinders[i].end(); ++it){
1860 if((*it)->meline1 != NULL){
1861 delete (*it)->meline1;
1862 (*it)->meline1 = NULL;
1864 if((*it)->meline2 != NULL){
1865 delete (*it)->meline2;
1866 (*it)->meline2 = NULL;
1869 (*it)->nbFeature = 0;
1870 (*it)->nbFeaturel1 = 0;
1871 (*it)->nbFeaturel2 = 0;
1874 for(std::list<vpMbtDistanceCircle*>::const_iterator it=
circles[i].begin(); it!=
circles[i].end(); ++it){
1875 if((*it)->meEllipse != NULL){
1876 delete (*it)->meEllipse;
1877 (*it)->meEllipse = NULL;
1879 (*it)->nbFeature = 0;
1900 if (dx <= std::numeric_limits<double>::epsilon() && dy <= std::numeric_limits<double>::epsilon() && dz <= std::numeric_limits<double>::epsilon())
1921 bool already_here = false ;
1924 for (
unsigned int i = 0; i <
scales.size(); i += 1){
1927 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
1931 already_here = true ;
1960 lines[i].push_back(l);
1977 for(
unsigned int i=0; i<
scales.size(); i++){
1979 for(std::list<vpMbtDistanceLine*>::iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
1981 if (name.compare(l->
getName()) == 0){
2003 bool already_here = false ;
2006 for (
unsigned int i = 0; i <
scales.size(); i += 1){
2009 for(std::list<vpMbtDistanceCircle*>::const_iterator it=
circles[i].begin(); it!=
circles[i].end(); ++it){
2057 bool already_here = false ;
2060 for (
unsigned int i = 0; i <
scales.size(); i += 1){
2063 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[i].begin(); it!=
cylinders[i].end(); ++it){
2099 for(
unsigned int i=0; i<
scales.size(); i++){
2101 for(std::list<vpMbtDistanceCylinder*>::iterator it=
cylinders[i].begin(); it!=
cylinders[i].end(); ++it){
2103 if (name.compare(cy->
getName()) == 0){
2122 for(
unsigned int i=0; i<
scales.size(); i++){
2124 for(std::list<vpMbtDistanceCircle*>::iterator it=
circles[i].begin(); it!=
circles[i].end(); ++it){
2126 if (name.compare(ci->
getName()) == 0){
2145 for (
unsigned int i=0 ; i < nbpt-1 ; i++)
2166 bool changed =
false;
2173 #ifdef VISP_HAVE_OGRE
2183 newvisibleline = true ;
2186 newvisibleline = false ;
2208 for (
unsigned int i=0 ; i < nbpt-1 ; i++)
2230 for (
unsigned int i=0 ; i < nbpt-1 ; i++)
2248 const int idFace,
const std::string &name)
2250 addCircle(p1, p2, p3, radius, (
int)idFace, name);
2265 const std::string &name)
2283 for (
unsigned int i = 0; i <
scales.size(); i += 1){
2285 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
2287 if (l!=NULL)
delete l ;
2291 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[i].begin(); it!=
cylinders[i].end(); ++it){
2293 if (cy!=NULL)
delete cy;
2297 for(std::list<vpMbtDistanceCircle*>::const_iterator it=
circles[i].begin(); it!=
circles[i].end(); ++it){
2299 if (ci!=NULL)
delete ci;
2312 #ifdef VISP_HAVE_OGRE
2367 for (
unsigned int i = 0; i <
scales.size(); i += 1){
2369 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
2371 if (l!=NULL)
delete l ;
2375 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[i].begin(); it!=
cylinders[i].end(); ++it){
2377 if (cy!=NULL)
delete cy;
2381 for(std::list<vpMbtDistanceCircle*>::const_iterator it=
circles[i].begin(); it!=
circles[i].end(); ++it){
2383 if (ci!=NULL)
delete ci;
2423 unsigned int nbGoodPoints = 0;
2425 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[level].begin(); it!=
lines[level].end(); ++it){
2429 for(
unsigned int a = 0 ; a < l->
meline.size() ; a++){
2431 for(std::list<vpMeSite>::const_iterator itme=l->
meline[a]->getMeList().begin(); itme!=l->
meline[a]->getMeList().end(); ++itme){
2439 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[level].begin(); it!=
cylinders[level].end(); ++it){
2443 for(std::list<vpMeSite>::const_iterator itme1=cy->
meline1->getMeList().begin(); itme1!=cy->
meline1->getMeList().end(); ++itme1){
2446 for(std::list<vpMeSite>::const_iterator itme2=cy->
meline2->getMeList().begin(); itme2!=cy->
meline2->getMeList().end(); ++itme2){
2453 for(std::list<vpMbtDistanceCircle*>::const_iterator it=
circles[level].begin(); it!=
circles[level].end(); ++it){
2457 for(std::list<vpMeSite>::const_iterator itme=ci->
meEllipse->getMeList().begin(); itme!=ci->
meEllipse->getMeList().end(); ++itme){
2463 return nbGoodPoints;
2489 unsigned int nbActivatedLevels = 0;
2490 for (
unsigned int i = 0; i < scale.size(); i += 1){
2492 nbActivatedLevels++;
2495 if((scale.size() < 1) || (nbActivatedLevels == 0)){
2496 vpERROR_TRACE(
" !! WARNING : must use at least one level for the tracking. Use the global one");
2498 this->
scales.push_back(
true);
2506 lines.resize(scale.size());
2508 for (
unsigned int i = 0; i <
lines.size(); i += 1){
2524 vpTRACE(
"Far clipping value cannot be inferior than near clipping value. Far clipping won't be considered.");
2525 else if ( dist < 0 )
2526 vpTRACE(
"Far clipping value cannot be inferior than 0. Far clipping won't be considered.");
2531 for (
unsigned int i = 0; i <
scales.size(); i += 1){
2533 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
2551 vpTRACE(
"Near clipping value cannot be superior than far clipping value. Near clipping won't be considered.");
2552 else if ( dist < 0 )
2553 vpTRACE(
"Near clipping value cannot be inferior than 0. Near clipping won't be considered.");
2558 for (
unsigned int i = 0; i <
scales.size(); i += 1){
2560 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
2583 for (
unsigned int i = 0; i <
scales.size(); i += 1){
2585 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
2610 _pyramid.resize(
scales.size());
2619 for(
unsigned int i=1; i<_pyramid.size(); i += 1){
2621 unsigned int cScale =
static_cast<unsigned int>(pow(2., (
int)i));
2623 #if (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x020408))
2624 IplImage* vpI0 = cvCreateImageHeader(cvSize((
int)_I.
getWidth(), (int)_I.
getHeight()), IPL_DEPTH_8U, 1);
2625 vpI0->imageData = (
char*)(_I.
bitmap);
2626 IplImage* vpI = cvCreateImage(cvSize((
int)(_I.
getWidth() / cScale), (
int)(_I.
getHeight() / cScale)), IPL_DEPTH_8U, 1);
2627 cvResize(vpI0, vpI, CV_INTER_NN);
2629 cvReleaseImage(&vpI);
2630 vpI0->imageData = NULL;
2631 cvReleaseImageHeader(&vpI0);
2633 for (
unsigned int k = 0, ii = 0; k < I->
getHeight(); k += 1, ii += cScale){
2634 for (
unsigned int l = 0, jj = 0; l < I->
getWidth(); l += 1, jj += cScale){
2635 (*I)[k][l] = _I[ii][jj];
2656 if(_pyramid.size() > 0){
2658 for (
unsigned int i = 1; i < _pyramid.size(); i += 1){
2659 if(_pyramid[i] != NULL){
2682 std::ostringstream oss;
2684 std::string errorMsg =
"level " + oss.str() +
" is not used, cannot get its distance lines.";
2688 linesList =
lines[level];
2706 std::ostringstream oss;
2708 std::string errorMsg =
"level " + oss.str() +
" is not used, cannot get its distance lines.";
2730 std::ostringstream oss;
2732 std::string errorMsg =
"level " + oss.str() +
" is not used, cannot get its distance lines.";
2748 const double ratio = pow(2., (
int)_scale);
2770 const double ratio = pow(2., (
int)_scale);
2799 if((*it)->isTracked()){
2807 if((*it)->isTracked()){
2815 if((*it)->isTracked()){
2835 for (
unsigned int i = 0; i <
scales.size(); i += 1){
2837 for(std::list<vpMbtDistanceLine*>::const_iterator it=
lines[i].begin(); it!=
lines[i].end(); ++it){
2846 (*it)->setTracked(name,useEdgeTracking);
2849 for(std::list<vpMbtDistanceCylinder*>::const_iterator it=
cylinders[i].begin(); it!=
cylinders[i].end(); ++it){
2850 if(
faces[(
unsigned)(*it)->index_polygon]->getName() == name){
2851 (*it)->setTracked(useEdgeTracking);
2855 for(std::list<vpMbtDistanceCircle*>::const_iterator it=
circles[i].begin(); it!=
circles[i].end(); ++it){
2856 if(
faces[(
unsigned)(*it)->index_polygon]->getName() == name){
2857 (*it)->setTracked(useEdgeTracking);
void setWindowName(const Ogre::String &n)
bool computeProjError
Flag used to specify if the gradient error criteria has to be computed or not.
unsigned int ncylinder
Index of the cylinder to add, and total number of cylinders extracted so far.
void setMovingEdge(vpMe *Me)
Implementation of a matrix and operations on matrices.
void displayMovingEdges(const vpImage< unsigned char > &I)
vpMatrix covarianceMatrix
Covariance matrix.
void initFromCalibrationMatrix(const vpMatrix &_K)
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void setMovingEdge(const vpMe &me)
static vpMatrix computeCovarianceMatrixVVS(const vpHomogeneousMatrix &cMo, const vpColVector &deltaS, const vpMatrix &Ls, const vpMatrix &W)
unsigned int nbFeature
The number of moving edges.
unsigned int nbFeatureTotal
The number of moving edges.
void setVisible(bool _isvisible)
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void trackMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void setCameraParameters(const vpCameraParameters &camera)
void upScale(const unsigned int _scale)
std::string getName() const
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void MEstimator(const vpRobustEstimatorType method, const vpColVector &residues, vpColVector &weights)
Compute the weights according a residue vector and a PsiFunction.
vpPoint * p3
An other point on the plane containing the circle.
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void addLine(vpPoint &p1, vpPoint &p2, int polygon=-1, std::string name="")
bool isAppearing(const unsigned int i)
unsigned int getWidth() const
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
void getCameraParameters(vpCameraParameters &_cam) const
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
bool Reinit
Indicates if the line has to be reinitialized.
void setMeanWeight2(const double wmean)
void computeVVS(const vpImage< unsigned char > &_I)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void init(const vpImage< unsigned char > &I)
void track(const vpImage< unsigned char > &I)
double lambda
The gain of the virtual visual servoing stage.
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.
Type * bitmap
points toward the bitmap
vpMatrix L
The interaction matrix.
void setFarClippingDistance(const double &dist)
void setCameraParameters(const vpCameraParameters &camera)
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'...
std::vector< std::list< vpMbtDistanceCircle * > > circles
Vector of the tracked circles.
Class to define colors available for display functionnalities.
Parse an Xml file to extract configuration parameters of a mbtConfig object.Data parser for the model...
void trackMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void setBackgroundSizeOgre(const unsigned int &h, const unsigned int &w)
vpHomogeneousMatrix cMo
The current pose.
vpPoint * p1
The first extremity.
void displayMovingEdges(const vpImage< unsigned char > &I)
double getNearClippingDistance() const
void setOgreShowConfigDialog(const bool showConfigDialog)
virtual ~vpMbEdgeTracker()
unsigned int ncircle
Index of the circle to add, and total number of circles extracted so far.
vpColVector error
The error vector.
bool modelInitialised
Flag used to ensure that the CAD model is loaded before the initialisation.
double get_oY() const
Get the point Y coordinate in the object frame.
void getMe(vpMe &_ecm) const
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, const vpPoint &_p3, const double r)
error that can be emited by ViSP classes.
vpMbtMeEllipse * meEllipse
The moving edge containers.
Manage a cylinder used in the model-based tracker.
void reInitLevel(const unsigned int _lvl)
vpPoint * p
corners in the object frame
Manage the line of a polygon used in the model-based tracker.
unsigned int nbFeature
The number of moving edges.
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
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...
void removeCircle(const std::string &name)
bool useOgre
Use Ogre3d for visibility tests.
unsigned int getCols() const
Return the number of columns of the 2D array.
int index_polygon
Index of the faces which contain the line.
vpPoint * p2
A point on the plane containing the circle.
void getLcylinder(std::list< vpMbtDistanceCylinder * > &cylindersList, const unsigned int level=0)
void setIndex(const unsigned int i)
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
unsigned int setVisibleOgre(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed)
void removeCylinder(const std::string &name)
vpMbtPolygon & getPolygon()
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
void loadConfigFile(const std::string &configFile)
vpMe me
The moving edges parameters.
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).
unsigned int getNbPoints(const unsigned int level=0) const
vpPoint * p1
The first extremity on the axe.
void initInteractionMatrixError()
void downScale(const unsigned int _scale)
bool hasNearClippingDistance() const
Class that defines what is a point.
vpMatrix L
The interaction matrix.
vpMeSiteState getState() const
vpCameraParameters cam
The camera parameters.
void computeClippedPolygons(const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam)
unsigned int setVisible(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angle, bool &changed)
static Type maximum(const Type &a, const Type &b)
virtual void setNearClippingDistance(const double &dist)
double getFarClippingDistance() const
void initOgre(const vpCameraParameters &cam=vpCameraParameters())
unsigned int nbFeaturel1
The number of moving edges on line 1.
double distFarClip
Distance for near clipping.
double projectionError
Error angle between the gradient direction of the model features projected at the resulting pose and ...
bool hasFarClippingDistance() const
vpAROgre * getOgreContext()
std::vector< vpMbtMeLine * > meline
The moving edge container.
int index_polygon
Index of the face which contains the cylinder.
void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
Manage a circle used in the model-based tracker.
vpMatrix oJo
The Degrees of Freedom to estimate.
std::vector< bool > scales
Vector of scale level to use for the multi-scale tracking.
bool Reinit
Indicates if the circle has to be reinitialized.
void getLline(std::list< vpMbtDistanceLine * > &linesList, const unsigned int level=0)
Error that can be emited by the vpTracker class and its derivates.
double getAngleDisappear() const
Implementation of a polygon of the model used by the model-based tracker.
void initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
void setName(const std::string &circle_name)
std::string getName() const
vpPoint * p2
The second extremity.
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void diag(const double &val=1.0)
bool useScanLine
Use Scanline for visibility tests.
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static double sqr(double x)
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
void setAngleDisappear(const double &adisappear)
double getMinPolygonAreaThreshold() const
vpColVector error
The error vector.
void trackMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
vpColVector m_error
Error s-s*.
Generic class defining intrinsic camera parameters.
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo)
double get_oZ() const
Get the point Z coordinate in the object frame.
void setIndex(const unsigned int i)
double percentageGdPt
Percentage of good points over total number of points below which tracking is supposed to have failed...
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > * > &_pyramid)
void cleanPyramid(std::vector< const vpImage< unsigned char > * > &_pyramid)
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder)
void setVisible(bool _isvisible)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
virtual void setFarClippingDistance(const double &dist)
static Type minimum(const Type &a, const Type &b)
Implementation of a velocity twist matrix and operations on such kind of matrices.
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
unsigned int getRows() const
Return the number of rows of the 2D array.
void setCameraParameters(const vpCameraParameters &_cam)
double angleAppears
Angle used to detect a face appearance.
void setState(const vpMeSiteState &flag)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
void displayMovingEdges(const vpImage< unsigned char > &I)
std::string getName() const
static double rad(double deg)
void addCylinder(const vpPoint &P1, const vpPoint &P2, const double r, int idFace=-1, const std::string &name="")
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
void parse(const char *filename)
void setMeanWeight1(const double wmean)
void setClipping(const unsigned int &flags)
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void setMovingEdge(vpMe *Me)
void computeProjectionError(const vpImage< unsigned char > &_I)
void setVisible(bool _isvisible)
bool samePoint(const vpPoint &P1, const vpPoint &P2)
virtual void initFaceFromLines(vpMbtPolygon &polygon)
double getMinLineLengthThreshold() const
void computeJTR(const vpMatrix &J, const vpColVector &R, vpColVector &JTR)
void setScales(const std::vector< bool > &_scales)
vpPoint * p2
The second extremity on the axe.
void getLcircle(std::list< vpMbtDistanceCircle * > &circlesList, const unsigned int level=0)
void setCameraParameters(const vpCameraParameters &camera)
double get_oX() const
Get the point X coordinate in the object frame.
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")
bool closeToImageBorder(const vpImage< unsigned char > &I, const unsigned int threshold)
void setIndex(const unsigned int i)
double minPolygonAreaThresholdGeneral
Minimum polygon area threshold for LOD mode (general setting)
static double deg(double rad)
void initInteractionMatrixError()
bool displayFeatures
If true, the features are displayed.
virtual void loadModel(const char *modelFile, const bool verbose=false)
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, const double r)
bool ogreShowConfigDialog
bool applyLodSettingInConfig
True if the CAO model is loaded before the call to loadConfigFile, (deduced by the number of polygons...
Implementation of column vector and the associated operations.
std::vector< std::list< vpMbtDistanceCylinder * > > cylinders
Vector of the tracked cylinders.
void setAngleAppear(const double &aappear)
void setMovingEdge(vpMe *Me)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo)
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")
vpHomogeneousMatrix inverse() const
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
static vpHomogeneousMatrix direct(const vpColVector &v)
void setMeanWeight(const double _wmean)
bool isVisible(const unsigned int i)
Contains an M-Estimator and various influence function.
unsigned int nbvisiblepolygone
Number of polygon (face) currently visible.
double angleDisappears
Angle used to detect a face disappearance.
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 unsigned int getNbPolygon() const
void visibleFace(const vpImage< unsigned char > &_I, const vpHomogeneousMatrix &_cMo, bool &newvisibleline)
void addPolygon(const int &index)
void setNearClippingDistance(const double &dist)
unsigned int getHeight() const
unsigned int getNbPoint() const
void setMeanWeight(const double w_mean)
vpColVector error
The error vector.
vpMatrix pseudoInverse(double svThreshold=1e-6) const
Compute the pseudo inverse of the matrix using the SVD.
virtual void setClipping(const unsigned int &flags)
bool Reinit
Indicates if the line has to be reinitialized.
double radius
The radius of the cylinder.
unsigned int clippingFlag
Flags specifying which clipping to used.
unsigned int nline
Index of the polygon to add, and total number of polygon extracted so far.
void addPolygon(vpMbtPolygon &p)
void setName(const std::string line_name)
void trackMovingEdge(const vpImage< unsigned char > &I)
void displayOgre(const vpHomogeneousMatrix &cMo)
double getAngleAppear() const
virtual void setClipping(const unsigned int &flags)
unsigned int nbFeaturel2
The number of moving edges on line 2.
void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
void setThreshold(const double noise_threshold)
double radius
The radius of the circle.
virtual void setFarClippingDistance(const double &dist)
void setName(const std::string &cyl_name)
static int sign(double x)
vpMbtMeLine * meline2
The moving edge containers (second line of the cylinder)
void removeLine(const std::string &name)
bool getFovClipping() const
void setIteration(const unsigned int iter)
Set iteration.
double distNearClip
Distance for near clipping.
bool useLodGeneral
True if LOD mode is enabled.
void computeScanLineRender(const vpCameraParameters &cam, const unsigned int &w, const unsigned int &h)
vpMatrix L
The interaction matrix.
void addCircle(const vpPoint &P1, const vpPoint &P2, const vpPoint &P3, const double r, int idFace=-1, const std::string &name="")
std::vector< unsigned int > nbFeature
The number of moving edges.
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo, const vpImage< unsigned char > &I)
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void initInteractionMatrixError()
void setMovingEdge(const vpMe &_ecm)
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
std::string getName() const
vpPoint * p1
The center of the circle.
bool useScanLine
Use scanline rendering.
void buildFrom(vpPoint &_p1, vpPoint &_p2)
void resize(const unsigned int i, const bool flagNullify=true)
vpColVector m_w
Weights used in the robust scheme.
virtual void setLod(const bool useLod, const std::string &name="")
virtual void setNearClippingDistance(const double &dist)
void computeFov(const unsigned int &w, const unsigned int &h)