46 #include <visp3/core/vpDebug.h> 47 #include <visp3/core/vpException.h> 48 #include <visp3/core/vpExponentialMap.h> 49 #include <visp3/core/vpMath.h> 50 #include <visp3/core/vpMatrixException.h> 51 #include <visp3/core/vpPixelMeterConversion.h> 52 #include <visp3/core/vpPolygon3D.h> 53 #include <visp3/core/vpTrackingException.h> 54 #include <visp3/core/vpVelocityTwistMatrix.h> 55 #include <visp3/mbt/vpMbEdgeTracker.h> 56 #include <visp3/mbt/vpMbtDistanceLine.h> 57 #include <visp3/mbt/vpMbtXmlParser.h> 58 #include <visp3/vision/vpPose.h> 70 : me(), lines(1), circles(1), cylinders(1), nline(0), ncircle(0), ncylinder(0), nbvisiblepolygone(0),
71 percentageGdPt(0.4), scales(1), Ipyramid(0), scaleLevel(0), nbFeaturesForProjErrorComputation(0), m_factor(),
72 m_robustLines(), m_robustCylinders(), m_robustCircles(), m_wLines(), m_wCylinders(), m_wCircles(), m_errorLines(),
73 m_errorCylinders(), m_errorCircles(), m_L_edge(), m_error_edge(), m_w_edge(), m_weightedError_edge(),
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();
118 for (
unsigned int i = 0; i <
circles.size(); i += 1) {
119 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) {
147 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
153 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
172 double residu_1 = 1e3;
175 unsigned int iter = 0;
188 while (reloop ==
true && iter < 10) {
193 count = count / (double)nbrow;
225 while (std::fabs((residu_1 - r) * 1e8) > std::numeric_limits<double>::epsilon() && (iter <
m_maxIter)) {
228 bool reStartFromLastIncrement =
false;
232 if (!reStartFromLastIncrement) {
240 if (!isoJoIdentity_) {
246 double wi = 0.0, eri = 0.0;
247 double num = 0.0, den = 0.0;
249 for (
unsigned int i = 0; i < nbrow; i++) {
258 for (
unsigned int j = 0; j < 6; j++) {
263 for (
unsigned int i = 0; i < nbrow; i++) {
294 const unsigned int lvl)
306 double e_prev = 0, e_cur, e_next;
308 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[lvl].begin(); it !=
lines[lvl].end(); ++it) {
309 if ((*it)->isTracked()) {
317 int index = *itindex;
329 std::list<vpMeSite>::const_iterator itListLine;
331 unsigned int indexFeature = 0;
333 for (
unsigned int a = 0; a < l->
meline.size(); a++) {
334 if (iter == 0 && l->
meline[a] != NULL)
335 itListLine = l->
meline[a]->getMeList().begin();
337 for (
unsigned int i = 0; i < l->
nbFeature[a]; i++) {
338 for (
unsigned int j = 0; j < 6; j++) {
339 m_L_edge[n + i][j] = l->
L[indexFeature][j];
357 if (indexFeature == 0) {
360 e_next = l->
error[1];
371 e_cur = l->
error[indexFeature];
378 e_cur = l->
error[indexFeature];
379 e_next = l->
error[indexFeature + 1];
380 if (fabs(e_cur - e_prev) < limite) {
383 if (fabs(e_cur - e_next) < limite) {
395 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[lvl].begin(); it !=
cylinders[lvl].end();
397 if ((*it)->isTracked()) {
402 std::list<vpMeSite>::const_iterator itCyl1;
403 std::list<vpMeSite>::const_iterator itCyl2;
405 itCyl1 = cy->
meline1->getMeList().begin();
406 itCyl2 = cy->
meline2->getMeList().begin();
409 for (
unsigned int i = 0; i < cy->
nbFeature; i++) {
410 for (
unsigned int j = 0; j < 6; j++) {
423 if (i < cy->nbFeaturel1) {
436 e_cur = cy->
error[0];
438 e_next = cy->
error[1];
447 e_cur = cy->
error[i];
449 e_next = cy->
error[i + 1];
460 e_cur = cy->
error[i];
467 e_cur = cy->
error[i];
474 e_cur = cy->
error[i];
475 e_next = cy->
error[i + 1];
476 if (fabs(e_cur - e_prev) < limite) {
479 if (fabs(e_cur - e_next) < limite) {
490 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[lvl].begin(); it !=
circles[lvl].end(); ++it) {
491 if ((*it)->isTracked()) {
496 std::list<vpMeSite>::const_iterator itCir;
497 if (iter == 0 && (ci->
meEllipse != NULL)) {
498 itCir = ci->
meEllipse->getMeList().begin();
501 for (
unsigned int i = 0; i < ci->
nbFeature; i++) {
502 for (
unsigned int j = 0; j < 6; j++) {
522 e_cur = ci->
error[0];
524 e_next = ci->
error[1];
535 e_cur = ci->
error[i];
542 e_cur = ci->
error[i];
543 e_next = ci->
error[i + 1];
544 if (fabs(e_cur - e_prev) < limite) {
547 if (fabs(e_cur - e_next) < limite) {
566 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[lvl].begin(); it !=
lines[lvl].end(); ++it) {
567 if ((*it)->isTracked()) {
574 int index = *itindex;
585 unsigned int indexFeature = 0;
586 for (
unsigned int a = 0; a < l->
meline.size(); a++) {
587 std::list<vpMeSite>::const_iterator itListLine;
588 if (l->
meline[a] != NULL) {
589 itListLine = l->
meline[a]->getMeList().begin();
591 for (
unsigned int i = 0; i < l->
nbFeature[a]; i++) {
605 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[lvl].begin(); it !=
cylinders[lvl].end();
607 if ((*it)->isTracked()) {
611 std::list<vpMeSite>::const_iterator itCyl1;
612 std::list<vpMeSite>::const_iterator itCyl2;
614 itCyl1 = cy->
meline1->getMeList().begin();
615 itCyl2 = cy->
meline2->getMeList().begin();
618 for (
unsigned int i = 0; i < cy->
nbFeature; i++) {
621 if (i < cy->nbFeaturel1) {
636 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[lvl].begin(); it !=
circles[lvl].end(); ++it) {
637 if ((*it)->isTracked()) {
641 std::list<vpMeSite>::const_iterator itCir;
643 itCir = ci->
meEllipse->getMeList().begin();
646 for (
unsigned int i = 0; i < ci->
nbFeature; i++) {
665 for (
unsigned int i = 0; i < nerror; i++) {
671 for (
unsigned int j = 0; j < 6; j++) {
676 for (
unsigned int i = 0; i < nerror; i++) {
690 if (isoJoIdentity_) {
694 unsigned int rank = (
m_L_edge * cVo).kernel(K);
703 isoJoIdentity_ =
false;
711 if (isoJoIdentity_) {
721 v = -0.7 * LVJTLVJ.
pseudoInverse(LVJTLVJ.
getRows() * std::numeric_limits<double>::epsilon()) * LVJTR;
731 unsigned int nbrow = 0;
732 unsigned int nberrors_lines = 0;
733 unsigned int nberrors_cylinders = 0;
734 unsigned int nberrors_circles = 0;
736 nbrow =
initMbtTracking(nberrors_lines, nberrors_cylinders, nberrors_circles);
740 "No data found to compute the interaction matrix...");
774 "computeVVSInteractionMatrixAndR" 775 "esidu() should not be called!");
785 unsigned int nlines = 0;
786 unsigned int ncylinders = 0;
787 unsigned int ncircles = 0;
791 if ((*it)->isTracked()) {
795 for (
unsigned int j = 0; j < 6; j++) {
806 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
808 if ((*it)->isTracked()) {
811 for (
unsigned int i = 0; i < cy->
nbFeature; i++) {
812 for (
unsigned int j = 0; j < 6; j++) {
824 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
826 if ((*it)->isTracked()) {
829 for (
unsigned int i = 0; i < ci->
nbFeature; i++) {
830 for (
unsigned int j = 0; j < 6; j++) {
848 if (nberrors_lines > 0)
850 if (nberrors_cylinders > 0)
852 if (nberrors_circles > 0)
871 unsigned int nbFeatures = 0;
876 for (
unsigned int a = 0; a < l->
meline.size(); a++) {
877 if (l->
meline[a] != NULL) {
878 double lineNormGradient;
879 unsigned int lineNbFeatures;
880 l->
meline[a]->computeProjectionError(_I, lineNormGradient, lineNbFeatures);
882 nbFeatures += lineNbFeatures;
888 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
893 double cylinderNormGradient = 0;
894 unsigned int cylinderNbFeatures = 0;
895 cy->
meline1->computeProjectionError(_I, cylinderNormGradient, cylinderNbFeatures);
897 nbFeatures += cylinderNbFeatures;
901 double cylinderNormGradient = 0;
902 unsigned int cylinderNbFeatures = 0;
903 cy->
meline2->computeProjectionError(_I, cylinderNormGradient, cylinderNbFeatures);
905 nbFeatures += cylinderNbFeatures;
910 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
914 double circleNormGradient = 0;
915 unsigned int circleNbFeatures = 0;
916 c->
meEllipse->computeProjectionError(_I, circleNormGradient, circleNbFeatures);
918 nbFeatures += circleNbFeatures;
922 if (nbFeatures > 0) {
939 int nbExpectedPoint = 0;
947 for (
unsigned int a = 0; a < l->
meline.size(); a++) {
948 if (l->
meline[a] != NULL) {
949 nbExpectedPoint += (int)l->
meline[a]->expecteddensity;
950 for (std::list<vpMeSite>::const_iterator itme = l->
meline[a]->getMeList().begin();
951 itme != l->
meline[a]->getMeList().end(); ++itme) {
963 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
967 nbExpectedPoint += (int)cy->
meline1->expecteddensity;
968 for (std::list<vpMeSite>::const_iterator itme1 = cy->
meline1->getMeList().begin();
969 itme1 != cy->
meline1->getMeList().end(); ++itme1) {
976 nbExpectedPoint += (int)cy->
meline2->expecteddensity;
977 for (std::list<vpMeSite>::const_iterator itme2 = cy->
meline2->getMeList().begin();
978 itme2 != cy->
meline2->getMeList().end(); ++itme2) {
988 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
992 nbExpectedPoint += ci->
meEllipse->getExpectedDensity();
993 for (std::list<vpMeSite>::const_iterator itme = ci->
meEllipse->getMeList().begin();
994 itme != ci->
meEllipse->getMeList().end(); ++itme) {
1008 if (nbGoodPoint < nb_min || nbExpectedPoint < 2) {
1009 std::ostringstream oss;
1010 oss <<
"Not enough moving edges (" << nbGoodPoint <<
") to track the object: expected " << nb_min
1012 <<
" using vpMbTracker::setGoodMovingEdgesRatioThreshold()";
1029 unsigned int lvl = (
unsigned int)
scales.size();
1043 vpTRACE(
"Error in moving edge tracking");
1085 bool newvisibleface =
false;
1133 #ifdef VISP_HAVE_OGRE 1152 unsigned int i = (
unsigned int)
scales.size();
1260 #ifdef VISP_HAVE_XML2 1269 std::cout <<
" *********** Parsing XML for Mb Edge Tracker ************ " << std::endl;
1270 xmlp.
parse(configFile);
1278 xmlp.
getMe(meParser);
1307 vpTRACE(
"You need the libXML2 to read the config file %s", configFile);
1324 const bool displayFullModel)
1326 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
1330 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1333 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1335 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1338 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1340 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1347 #ifdef VISP_HAVE_OGRE 1366 const bool displayFullModel)
1368 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
1372 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1375 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1377 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1380 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1382 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
1388 #ifdef VISP_HAVE_OGRE 1397 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[lvl].begin(); it !=
lines[lvl].end(); ++it) {
1404 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[lvl].begin(); it !=
cylinders[lvl].end();
1412 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[lvl].begin(); it !=
circles[lvl].end(); ++it) {
1436 bool isvisible =
false;
1440 int index = *itindex;
1460 for (
unsigned int a = 0; a < l->
meline.size(); a++) {
1461 if (l->
meline[a] != NULL)
1463 if (a < l->nbFeature.size())
1473 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1477 bool isvisible =
false;
1510 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1513 bool isvisible =
false;
1550 if (l->
meline.size() == 0) {
1557 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1568 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1590 if ((*it)->isTracked()) {
1600 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1602 if ((*it)->isTracked()) {
1612 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1614 if ((*it)->isTracked()) {
1631 if ((*it)->isTracked()) {
1633 unsigned int indexLine = 0;
1635 for (
unsigned int a = 0; a < l->
meline.size(); a++) {
1637 std::list<vpMeSite>::iterator itListLine;
1638 itListLine = l->
meline[a]->getMeList().begin();
1640 for (
unsigned int i = 0; i < l->
nbFeature[a]; i++) {
1643 if (
m_w_edge[n + indexLine] < 0.5) {
1670 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1672 if ((*it)->isTracked()) {
1675 std::list<vpMeSite>::iterator itListCyl1;
1676 std::list<vpMeSite>::iterator itListCyl2;
1679 itListCyl1 = cy->
meline1->getMeList().begin();
1680 itListCyl2 = cy->
meline2->getMeList().begin();
1682 for (
unsigned int i = 0; i < cy->
nbFeaturel1; i++) {
1707 for (
unsigned int i = cy->
nbFeaturel1; i < cy->nbFeature; i++) {
1736 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1738 if ((*it)->isTracked()) {
1741 std::list<vpMeSite>::iterator itListCir;
1744 itListCir = ci->
meEllipse->getMeList().begin();
1748 for (
unsigned int i = 0; i < ci->
nbFeature; i++) {
1790 if ((*it)->isTracked()) {
1798 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1800 if ((*it)->isTracked()) {
1808 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1810 if ((*it)->isTracked()) {
1820 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
1822 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
1823 for (
unsigned int a = 0; a < (*it)->meline.size(); a++) {
1824 if ((*it)->meline[a] != NULL) {
1825 delete (*it)->meline[a];
1826 (*it)->meline[a] = NULL;
1828 (*it)->meline.clear();
1829 (*it)->nbFeature.clear();
1830 (*it)->nbFeatureTotal = 0;
1834 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
1836 if ((*it)->meline1 != NULL) {
1837 delete (*it)->meline1;
1838 (*it)->meline1 = NULL;
1840 if ((*it)->meline2 != NULL) {
1841 delete (*it)->meline2;
1842 (*it)->meline2 = NULL;
1845 (*it)->nbFeature = 0;
1846 (*it)->nbFeaturel1 = 0;
1847 (*it)->nbFeaturel2 = 0;
1850 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
1851 if ((*it)->meEllipse != NULL) {
1852 delete (*it)->meEllipse;
1853 (*it)->meEllipse = NULL;
1855 (*it)->nbFeature = 0;
1876 if (dx <= std::numeric_limits<double>::epsilon() && dy <= std::numeric_limits<double>::epsilon() &&
1877 dz <= std::numeric_limits<double>::epsilon())
1898 bool already_here =
false;
1901 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
1904 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
1908 already_here =
true;
1914 if (!already_here) {
1937 lines[i].push_back(l);
1953 for (
unsigned int i = 0; i <
scales.size(); i++) {
1955 for (std::list<vpMbtDistanceLine *>::iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
1957 if (name.compare(l->
getName()) == 0) {
1977 const std::string &name)
1979 bool already_here =
false;
1982 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
1985 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
1994 if (!already_here) {
2034 const std::string &name)
2036 bool already_here =
false;
2039 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2042 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
2052 if (!already_here) {
2079 for (
unsigned int i = 0; i <
scales.size(); i++) {
2081 for (std::list<vpMbtDistanceCylinder *>::iterator it =
cylinders[i].begin(); it !=
cylinders[i].end(); ++it) {
2083 if (name.compare(cy->
getName()) == 0) {
2101 for (
unsigned int i = 0; i <
scales.size(); i++) {
2103 for (std::list<vpMbtDistanceCircle *>::iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
2105 if (name.compare(ci->
getName()) == 0) {
2123 for (
unsigned int i = 0; i < nbpt - 1; i++)
2141 bool &newvisibleline)
2144 bool changed =
false;
2151 #ifdef VISP_HAVE_OGRE 2160 newvisibleline =
true;
2162 newvisibleline =
false;
2186 for (
unsigned int i = 0; i < nbpt - 1; i++)
2210 for (
unsigned int i = 0; i < nbpt - 1; i++)
2216 unsigned int &nberrors_circles)
2218 unsigned int nbrow = 0;
2220 nberrors_cylinders = 0;
2221 nberrors_circles = 0;
2235 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
2246 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
2272 const int idFace,
const std::string &name)
2274 addCircle(p1, p2, p3, radius, (
int)idFace, name);
2288 const std::string &name)
2305 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2307 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2314 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
2322 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
2338 #ifdef VISP_HAVE_OGRE 2391 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2393 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2400 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
2408 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
2451 unsigned int nbGoodPoints = 0;
2453 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[level].begin(); it !=
lines[level].end(); ++it) {
2456 for (
unsigned int a = 0; a < l->
meline.size(); a++) {
2458 for (std::list<vpMeSite>::const_iterator itme = l->
meline[a]->getMeList().begin();
2459 itme != l->
meline[a]->getMeList().end(); ++itme) {
2468 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[level].begin(); it !=
cylinders[level].end();
2472 for (std::list<vpMeSite>::const_iterator itme1 = cy->
meline1->getMeList().begin();
2473 itme1 != cy->
meline1->getMeList().end(); ++itme1) {
2477 for (std::list<vpMeSite>::const_iterator itme2 = cy->
meline2->getMeList().begin();
2478 itme2 != cy->
meline2->getMeList().end(); ++itme2) {
2486 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[level].begin(); it !=
circles[level].end(); ++it) {
2489 for (std::list<vpMeSite>::const_iterator itme = ci->
meEllipse->getMeList().begin();
2490 itme != ci->
meEllipse->getMeList().end(); ++itme) {
2497 return nbGoodPoints;
2523 unsigned int nbActivatedLevels = 0;
2524 for (
unsigned int i = 0; i < scale.size(); i++) {
2526 nbActivatedLevels++;
2530 if (scale.empty() || (nbActivatedLevels == 0)) {
2531 vpERROR_TRACE(
" !! WARNING : must use at least one level for the " 2532 "tracking. Use the global one");
2534 this->
scales.push_back(
true);
2547 lines.resize(scale.size());
2551 for (
unsigned int i = 0; i <
lines.size(); i++) {
2567 std::cerr <<
"Far clipping value cannot be inferior than near clipping " 2568 "value. Far clipping won't be considered." 2571 std::cerr <<
"Far clipping value cannot be inferior than 0. Far clipping " 2572 "won't be considered." 2578 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2580 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2597 std::cerr <<
"Near clipping value cannot be superior than far clipping " 2598 "value. Near clipping won't be considered." 2601 std::cerr <<
"Near clipping value cannot be inferior than 0. Near " 2602 "clipping won't be considered." 2608 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2610 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2632 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2634 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2660 _pyramid.resize(
scales.size());
2668 for (
unsigned int i = 1; i < _pyramid.size(); i += 1) {
2670 unsigned int cScale =
static_cast<unsigned int>(pow(2., (
int)i));
2672 #if (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x020408)) 2673 IplImage *vpI0 = cvCreateImageHeader(cvSize((
int)_I.
getWidth(), (int)_I.
getHeight()), IPL_DEPTH_8U, 1);
2674 vpI0->imageData = (
char *)(_I.
bitmap);
2676 cvCreateImage(cvSize((
int)(_I.
getWidth() / cScale), (
int)(_I.
getHeight() / cScale)), IPL_DEPTH_8U, 1);
2677 cvResize(vpI0, vpI, CV_INTER_NN);
2679 cvReleaseImage(&vpI);
2680 vpI0->imageData = NULL;
2681 cvReleaseImageHeader(&vpI0);
2683 for (
unsigned int k = 0, ii = 0; k < I->
getHeight(); k += 1, ii += cScale) {
2684 for (
unsigned int l = 0, jj = 0; l < I->
getWidth(); l += 1, jj += cScale) {
2685 (*I)[k][l] = _I[ii][jj];
2704 if (_pyramid.size() > 0) {
2706 for (
unsigned int i = 1; i < _pyramid.size(); i += 1) {
2707 if (_pyramid[i] != NULL) {
2729 std::ostringstream oss;
2731 std::string errorMsg =
"level " + oss.str() +
" is not used, cannot get its distance lines.";
2735 linesList =
lines[level];
2751 std::ostringstream oss;
2753 std::string errorMsg =
"level " + oss.str() +
" is not used, cannot get its distance lines.";
2773 std::ostringstream oss;
2775 std::string errorMsg =
"level " + oss.str() +
" is not used, cannot get its distance lines.";
2790 const double ratio = pow(2., (
int)_scale);
2811 const double ratio = pow(2., (
int)_scale);
2839 if ((*it)->isTracked()) {
2846 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
2848 if ((*it)->isTracked()) {
2855 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
2857 if ((*it)->isTracked()) {
2877 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2879 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2890 (*it)->setTracked(name, useEdgeTracking);
2893 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
2895 if (
faces[(
unsigned)(*it)->index_polygon]->getName() == name) {
2896 (*it)->setTracked(useEdgeTracking);
2900 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
2901 if (
faces[(
unsigned)(*it)->index_polygon]->getName() == name) {
2902 (*it)->setTracked(useEdgeTracking);
bool m_computeInteraction
void setWindowName(const Ogre::String &n)
std::string getName() const
void setMovingEdge(vpMe *Me)
Implementation of a matrix and operations on matrices.
void displayMovingEdges(const vpImage< unsigned char > &I)
vpMatrix pseudoInverse(double svThreshold=1e-6) const
vpMatrix covarianceMatrix
Covariance matrix.
void initFromCalibrationMatrix(const vpMatrix &_K)
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void setMovingEdge(const vpMe &me)
bool getFovClipping() const
double get_oY() const
Get the point Y coordinate in the object frame.
vpMeSiteState getState() const
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)
vpColVector m_error_edge
(s - s*)
void upScale(const unsigned int _scale)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
vpColVector m_weightedError_edge
Weighted error.
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)
double getAngleAppear() const
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
std::string getName() 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)
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)
std::string getName() const
std::vector< std::list< vpMbtDistanceCylinder * > > cylinders
Vector of the tracked cylinders.
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'...
void getMe(vpMe &_ecm) const
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true, const bool recopy_=true)
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)
vpColVector m_factor
Edge VVS variables.
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)
void setOgreShowConfigDialog(const bool showConfigDialog)
virtual ~vpMbEdgeTracker()
std::vector< const vpImage< unsigned char > * > Ipyramid
vpColVector error
The error vector.
virtual unsigned int getNbPoints(const unsigned int level=0) const
vpColVector m_w_edge
Robust weights.
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
unsigned int getRows() const
vpHomogeneousMatrix inverse() const
Manage the line of a polygon used in the model-based tracker.
unsigned int nbFeature
The number of moving edges.
void getCameraParameters(vpCameraParameters &_cam) const
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
void removeCircle(const std::string &name)
bool useOgre
Use Ogre3d for visibility tests.
int index_polygon
Index of the faces which contain the line.
vpPoint * p2
A point on the plane containing the circle.
bool hasNearClippingDistance() const
void setIndex(const unsigned int i)
virtual void setCameraParameters(const vpCameraParameters &camera)
void displayFeaturesOnImage(const vpImage< unsigned char > &I, const unsigned int lvl)
void computeVVSFirstPhasePoseEstimation(const unsigned int iter, bool &isoJoIdentity_)
void computeVVS(const vpImage< unsigned char > &_I, const unsigned int lvl)
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)
vpPoint * p1
The first extremity on the axe.
void initInteractionMatrixError()
double get_oX() const
Get the point X coordinate in the object frame.
void downScale(const unsigned int _scale)
Class that defines what is a point.
vpMatrix L
The interaction matrix.
vpCameraParameters cam
The camera parameters.
virtual void computeVVSWeights()
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)
double getAngleDisappear() const
virtual void setNearClippingDistance(const double &dist)
void initOgre(const vpCameraParameters &cam=vpCameraParameters())
unsigned int nbFeaturel1
The number of moving edges on line 1.
double distFarClip
Distance for near clipping.
vpAROgre * getOgreContext()
int index_polygon
Index of the face which contains the cylinder.
virtual 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.
Error that can be emited by the vpTracker class and its derivates.
Implementation of a polygon of the model used by the model-based tracker.
double getNearClippingDistance() const
void initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
void setName(const std::string &circle_name)
vpPoint * p2
The second extremity.
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
bool useScanLine
Use Scanline for visibility tests.
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
double getFarClippingDistance() const
static double sqr(double x)
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
void setAngleDisappear(const double &adisappear)
vpColVector error
The error vector.
void trackMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
unsigned int nbFeaturesForProjErrorComputation
Number of features used in the computation of the projection error.
Generic class defining intrinsic camera parameters.
void cleanPyramid(std::vector< const vpImage< unsigned char > *> &_pyramid)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo)
unsigned int initMbtTracking(unsigned int &nberrors_lines, unsigned int &nberrors_cylinders, unsigned int &nberrors_circles)
void setIndex(const unsigned int i)
std::string getName() const
unsigned int getNbPoint() const
virtual void computeVVSInteractionMatrixAndResidu()
double get_oZ() const
Get the point Z coordinate in the object frame.
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
double m_initialMu
Initial Mu for Levenberg Marquardt optimization loop.
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder)
void setVisible(bool _isvisible)
double m_lambda
Gain of the virtual visual servoing stage.
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)
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
void setCameraParameters(const vpCameraParameters &_cam)
double angleAppears
Angle used to detect a face appearance.
vpColVector m_errorCylinders
void setState(const vpMeSiteState &flag)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
vpColVector m_errorCircles
bool samePoint(const vpPoint &P1, const vpPoint &P2) const
void displayMovingEdges(const vpImage< unsigned char > &I)
unsigned int m_maxIter
Maximum number of iterations of the virtual visual servoing stage.
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)
std::vector< std::list< vpMbtDistanceCircle * > > circles
Vector of the tracked circles.
void getLline(std::list< vpMbtDistanceLine *> &linesList, const unsigned int level=0) const
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)
void insert(unsigned int i, const vpColVector &v)
vpRobust m_robustCylinders
virtual void initFaceFromLines(vpMbtPolygon &polygon)
void getLcircle(std::list< vpMbtDistanceCircle *> &circlesList, const unsigned int level=0) const
void setName(const std::string &line_name)
void setScales(const std::vector< bool > &_scales)
vpPoint * p2
The second extremity on the axe.
void setCameraParameters(const vpCameraParameters &camera)
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)
unsigned int getHeight() const
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, const double r)
bool ogreShowConfigDialog
virtual unsigned int getNbPolygon() const
double getMinPolygonAreaThreshold() const
bool applyLodSettingInConfig
Implementation of column vector and the associated operations.
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="")
virtual void computeVVSPoseEstimation(const bool isoJoIdentity_, const unsigned int iter, vpMatrix &L, vpMatrix <L, vpColVector &R, const vpColVector &error, vpColVector &error_prev, vpColVector <R, double &mu, vpColVector &v, const vpColVector *const w=NULL, vpColVector *const m_w_prev=NULL)
bool hasFarClippingDistance() const
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
static vpHomogeneousMatrix direct(const vpColVector &v)
virtual void computeCovarianceMatrixVVS(const bool isoJoIdentity_, const vpColVector &w_true, const vpHomogeneousMatrix &cMoPrev, const vpMatrix &L_true, const vpMatrix &LVJ_true, const vpColVector &error)
void setMeanWeight(const double _wmean)
bool isVisible(const unsigned int i)
void updateMovingEdgeWeights()
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)
void visibleFace(const vpImage< unsigned char > &_I, const vpHomogeneousMatrix &_cMo, bool &newvisibleline)
virtual void computeVVSInit()
void addPolygon(const int &index)
void setNearClippingDistance(const double &dist)
void setMeanWeight(const double w_mean)
vpColVector error
The error vector.
std::vector< std::list< vpMbtDistanceLine * > > lines
virtual void setClipping(const unsigned int &flags)
bool Reinit
Indicates if the line has to be reinitialized.
double radius
The radius of the cylinder.
double getMinLineLengthThreshold() const
std::vector< vpMbtMeLine * > meline
The moving edge container.
unsigned int clippingFlag
Flags specifying which clipping to used.
vpMatrix m_L_edge
Interaction matrix.
void addPolygon(vpMbtPolygon &p)
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > *> &_pyramid)
void trackMovingEdge(const vpImage< unsigned char > &I)
void displayOgre(const vpHomogeneousMatrix &cMo)
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 computeVVSFirstPhase(const vpImage< unsigned char > &I, const unsigned int iter, double &count, const unsigned int lvl=0)
void setName(const std::string &cyl_name)
static int() sign(double x)
void resize(unsigned int n_data)
Resize containers for sort methods.
vpMbtMeLine * meline2
The moving edge containers (second line of the cylinder)
void removeLine(const std::string &name)
unsigned int getWidth() const
void computeVVSFirstPhaseFactor(const vpImage< unsigned char > &I, const unsigned int lvl=0)
void computeJTR(const vpMatrix &J, const vpColVector &R, vpColVector &JTR) const
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()
virtual void computeVVSCheckLevenbergMarquardt(const unsigned int iter, vpColVector &error, const vpColVector &m_error_prev, const vpHomogeneousMatrix &cMoPrev, double &mu, bool &reStartFromLastIncrement, vpColVector *const w=NULL, const vpColVector *const m_w_prev=NULL)
void setMovingEdge(const vpMe &_ecm)
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
vpPoint * p1
The center of the circle.
bool useScanLine
Use scanline rendering.
void getLcylinder(std::list< vpMbtDistanceCylinder *> &cylindersList, const unsigned int level=0) const
void buildFrom(vpPoint &_p1, vpPoint &_p2)
void resize(const unsigned int i, const bool flagNullify=true)
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)