41 #include <visp3/core/vpDebug.h>
42 #include <visp3/core/vpException.h>
43 #include <visp3/core/vpExponentialMap.h>
44 #include <visp3/core/vpMath.h>
45 #include <visp3/core/vpMatrixException.h>
46 #include <visp3/core/vpPixelMeterConversion.h>
47 #include <visp3/core/vpPolygon3D.h>
48 #include <visp3/core/vpTrackingException.h>
49 #include <visp3/core/vpVelocityTwistMatrix.h>
50 #include <visp3/mbt/vpMbEdgeTracker.h>
51 #include <visp3/mbt/vpMbtDistanceLine.h>
52 #include <visp3/mbt/vpMbtXmlGenericParser.h>
53 #include <visp3/vision/vpPose.h>
66 : me(), lines(1), circles(1), cylinders(1), nline(0), ncircle(0), ncylinder(0), nbvisiblepolygone(0),
67 percentageGdPt(0.4), scales(1), Ipyramid(0), scaleLevel(0), nbFeaturesForProjErrorComputation(0), m_factor(),
68 m_robustLines(), m_robustCylinders(), m_robustCircles(), m_wLines(), m_wCylinders(), m_wCircles(), m_errorLines(),
69 m_errorCylinders(), m_errorCircles(), m_L_edge(), m_error_edge(), m_w_edge(), m_weightedError_edge(),
70 m_robust_edge(), m_featuresToBeDisplayedEdge()
88 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
90 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
98 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
107 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
133 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
135 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
140 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
146 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
165 double residu_1 = 1e3;
168 unsigned int iter = 0;
181 while (reloop ==
true && iter < 10) {
186 count = count / (double)nbrow;
218 while (std::fabs((residu_1 - r) * 1e8) > std::numeric_limits<double>::epsilon() && (iter <
m_maxIter)) {
221 bool reStartFromLastIncrement =
false;
225 if (!reStartFromLastIncrement) {
233 if (!isoJoIdentity) {
239 double wi = 0.0, eri = 0.0;
240 double num = 0.0, den = 0.0;
242 for (
unsigned int i = 0; i < nbrow; i++) {
251 for (
unsigned int j = 0; j < 6; j++) {
257 for (
unsigned int i = 0; i < nbrow; i++) {
300 double e_prev = 0, e_cur, e_next;
302 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[lvl].begin(); it !=
lines[lvl].end(); ++it) {
303 if ((*it)->isTracked()) {
311 int index = *itindex;
323 std::list<vpMeSite>::const_iterator itListLine;
325 unsigned int indexFeature = 0;
327 for (
size_t a = 0; a < l->
meline.size(); a++) {
328 if (iter == 0 && l->
meline[a] !=
nullptr)
329 itListLine = l->
meline[a]->getMeList().begin();
331 for (
unsigned int i = 0; i < l->
nbFeature[a]; i++) {
332 for (
unsigned int j = 0; j < 6; j++) {
333 m_L_edge[n + i][j] = l->
L[indexFeature][j];
351 if (indexFeature == 0) {
354 e_next = l->
error[1];
366 e_cur = l->
error[indexFeature];
373 e_cur = l->
error[indexFeature];
374 e_next = l->
error[indexFeature + 1];
375 if (fabs(e_cur - e_prev) < limite) {
378 if (fabs(e_cur - e_next) < limite) {
390 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[lvl].begin(); it !=
cylinders[lvl].end();
392 if ((*it)->isTracked()) {
397 std::list<vpMeSite>::const_iterator itCyl1;
398 std::list<vpMeSite>::const_iterator itCyl2;
399 if (iter == 0 && (cy->
meline1 !=
nullptr || cy->
meline2 !=
nullptr)) {
400 itCyl1 = cy->
meline1->getMeList().begin();
401 itCyl2 = cy->
meline2->getMeList().begin();
404 for (
unsigned int i = 0; i < cy->
nbFeature; i++) {
405 for (
unsigned int j = 0; j < 6; j++) {
418 if (i < cy->nbFeaturel1) {
432 e_cur = cy->
error[0];
434 e_next = cy->
error[1];
444 e_cur = cy->
error[i];
446 e_next = cy->
error[i + 1];
458 e_cur = cy->
error[i];
465 e_cur = cy->
error[i];
472 e_cur = cy->
error[i];
473 e_next = cy->
error[i + 1];
474 if (fabs(e_cur - e_prev) < limite) {
477 if (fabs(e_cur - e_next) < limite) {
488 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[lvl].begin(); it !=
circles[lvl].end(); ++it) {
489 if ((*it)->isTracked()) {
494 std::list<vpMeSite>::const_iterator itCir;
495 if (iter == 0 && (ci->
meEllipse !=
nullptr)) {
496 itCir = ci->
meEllipse->getMeList().begin();
499 for (
unsigned int i = 0; i < ci->
nbFeature; i++) {
500 for (
unsigned int j = 0; j < 6; j++) {
520 e_cur = ci->
error[0];
522 e_next = ci->
error[1];
534 e_cur = ci->
error[i];
541 e_cur = ci->
error[i];
542 e_next = ci->
error[i + 1];
543 if (fabs(e_cur - e_prev) < limite) {
546 if (fabs(e_cur - e_next) < limite) {
565 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[lvl].begin(); it !=
lines[lvl].end(); ++it) {
566 if ((*it)->isTracked()) {
573 int index = *itindex;
584 for (
size_t a = 0; a < l->
meline.size(); a++) {
585 std::list<vpMeSite>::const_iterator itListLine;
586 if (l->
meline[a] !=
nullptr) {
587 itListLine = l->
meline[a]->getMeList().begin();
589 for (
unsigned int i = 0; i < l->
nbFeature[a]; i++) {
602 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[lvl].begin(); it !=
cylinders[lvl].end();
604 if ((*it)->isTracked()) {
608 std::list<vpMeSite>::const_iterator itCyl1;
609 std::list<vpMeSite>::const_iterator itCyl2;
611 itCyl1 = cy->
meline1->getMeList().begin();
612 itCyl2 = cy->
meline2->getMeList().begin();
615 for (
unsigned int i = 0; i < cy->
nbFeature; i++) {
618 if (i < cy->nbFeaturel1) {
634 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[lvl].begin(); it !=
circles[lvl].end(); ++it) {
635 if ((*it)->isTracked()) {
639 std::list<vpMeSite>::const_iterator itCir;
641 itCir = ci->
meEllipse->getMeList().begin();
644 for (
unsigned int i = 0; i < ci->
nbFeature; i++) {
663 for (
unsigned int i = 0; i < nerror; i++) {
669 for (
unsigned int j = 0; j < 6; j++) {
675 for (
unsigned int i = 0; i < nerror; i++) {
693 unsigned int rank = (
m_L_edge * cVo).kernel(K);
702 isoJoIdentity =
false;
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...");
771 "computeVVSInteractionMatrixAndR"
772 "esidu() should not be called!");
782 unsigned int nlines = 0;
783 unsigned int ncylinders = 0;
784 unsigned int ncircles = 0;
788 if ((*it)->isTracked()) {
792 for (
unsigned int j = 0; j < 6; j++) {
803 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
805 if ((*it)->isTracked()) {
808 for (
unsigned int i = 0; i < cy->
nbFeature; i++) {
809 for (
unsigned int j = 0; j < 6; j++) {
821 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
823 if ((*it)->isTracked()) {
826 for (
unsigned int i = 0; i < ci->
nbFeature; i++) {
827 for (
unsigned int j = 0; j < 6; j++) {
845 if (nberrors_lines > 0)
847 if (nberrors_cylinders > 0)
849 if (nberrors_circles > 0)
868 unsigned int nbFeatures = 0;
873 for (
size_t a = 0; a < l->
meline.size(); a++) {
874 if (l->
meline[a] !=
nullptr) {
875 double lineNormGradient;
876 unsigned int lineNbFeatures;
881 nbFeatures += lineNbFeatures;
887 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
892 double cylinderNormGradient = 0;
893 unsigned int cylinderNbFeatures = 0;
898 nbFeatures += cylinderNbFeatures;
902 double cylinderNormGradient = 0;
903 unsigned int cylinderNbFeatures = 0;
908 nbFeatures += cylinderNbFeatures;
913 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
917 double circleNormGradient = 0;
918 unsigned int circleNbFeatures = 0;
923 nbFeatures += circleNbFeatures;
927 if (nbFeatures > 0) {
945 int nbExpectedPoint = 0;
953 for (
size_t a = 0; a < l->
meline.size(); a++) {
954 if (l->
meline[a] !=
nullptr) {
955 nbExpectedPoint += (int)l->
meline[a]->expecteddensity;
956 for (std::list<vpMeSite>::const_iterator itme = l->
meline[a]->getMeList().begin();
957 itme != l->
meline[a]->getMeList().end(); ++itme) {
969 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
973 nbExpectedPoint += (int)cy->
meline1->expecteddensity;
974 for (std::list<vpMeSite>::const_iterator itme1 = cy->
meline1->getMeList().begin();
975 itme1 != cy->
meline1->getMeList().end(); ++itme1) {
982 nbExpectedPoint += (int)cy->
meline2->expecteddensity;
983 for (std::list<vpMeSite>::const_iterator itme2 = cy->
meline2->getMeList().begin();
984 itme2 != cy->
meline2->getMeList().end(); ++itme2) {
994 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
998 nbExpectedPoint += ci->
meEllipse->getExpectedDensity();
999 for (std::list<vpMeSite>::const_iterator itme = ci->
meEllipse->getMeList().begin();
1000 itme != ci->
meEllipse->getMeList().end(); ++itme) {
1013 if (nbGoodPoint < nb_min || nbExpectedPoint < 2) {
1014 std::ostringstream oss;
1015 oss <<
"Not enough moving edges (" << nbGoodPoint <<
") to track the object: expected " << nb_min
1017 <<
" using vpMbTracker::setGoodMovingEdgesRatioThreshold()";
1033 unsigned int lvl = (
unsigned int)
scales.size();
1048 vpTRACE(
"Error in moving edge tracking");
1091 bool newvisibleface =
false;
1147 #ifdef VISP_HAVE_OGRE
1176 unsigned int i = (
unsigned int)
scales.size();
1231 #if defined(VISP_HAVE_PUGIXML)
1244 std::cout <<
" *********** Parsing XML for Mb Edge Tracker ************ " << std::endl;
1246 xmlp.
parse(configFile);
1302 bool displayFullModel)
1309 std::vector<std::vector<double> > models =
1312 for (
size_t i = 0; i < models.size(); i++) {
1320 double n20 = models[i][3];
1321 double n11 = models[i][4];
1322 double n02 = models[i][5];
1327 #ifdef VISP_HAVE_OGRE
1345 const vpColor &col,
unsigned int thickness,
bool displayFullModel)
1352 std::vector<std::vector<double> > models =
1355 for (
size_t i = 0; i < models.size(); i++) {
1363 double n20 = models[i][3];
1364 double n11 = models[i][4];
1365 double n02 = models[i][5];
1370 #ifdef VISP_HAVE_OGRE
1378 std::vector<std::vector<double> > features;
1380 const unsigned int lvl = 0;
1381 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[lvl].begin(); it !=
lines[lvl].end(); ++it) {
1385 features.insert(features.end(), currentFeatures.begin(), currentFeatures.end());
1389 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[lvl].begin(); it !=
cylinders[lvl].end();
1394 features.insert(features.end(), currentFeatures.begin(), currentFeatures.end());
1398 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[lvl].begin(); it !=
circles[lvl].end(); ++it) {
1402 features.insert(features.end(), currentFeatures.begin(), currentFeatures.end());
1427 bool displayFullModel)
1429 std::vector<std::vector<double> > models;
1431 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
1435 std::vector<std::vector<double> > currentModel =
1436 (*it)->getModelForDisplay(width, height, cMo, cam, displayFullModel);
1437 models.insert(models.end(), currentModel.begin(), currentModel.end());
1440 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1442 std::vector<std::vector<double> > currentModel =
1443 (*it)->getModelForDisplay(width, height, cMo, cam, displayFullModel);
1444 models.insert(models.end(), currentModel.begin(), currentModel.end());
1447 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1449 std::vector<double> paramsCircle = (*it)->getModelForDisplay(cMo, cam, displayFullModel);
1450 if (!paramsCircle.empty()) {
1451 models.push_back(paramsCircle);
1541 const bool doNotTrack =
false;
1546 bool isvisible =
false;
1550 int index = *itindex;
1571 for (
size_t a = 0; a < l->
meline.size(); a++) {
1572 if (l->
meline[a] !=
nullptr)
1574 if (a < l->nbFeature.size())
1583 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1587 bool isvisible =
false;
1620 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1623 bool isvisible =
false;
1657 const bool doNotTrack =
false;
1670 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1681 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1703 if ((*it)->isTracked()) {
1713 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1715 if ((*it)->isTracked()) {
1725 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1727 if ((*it)->isTracked()) {
1744 if ((*it)->isTracked()) {
1746 unsigned int indexLine = 0;
1748 for (
size_t a = 0; a < l->
meline.size(); a++) {
1750 std::list<vpMeSite>::iterator itListLine;
1751 itListLine = l->
meline[a]->getMeList().begin();
1753 for (
unsigned int i = 0; i < l->
nbFeature[a]; i++) {
1756 if (
m_w_edge[n + indexLine] < 0.5) {
1783 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1785 if ((*it)->isTracked()) {
1788 std::list<vpMeSite>::iterator itListCyl1;
1789 std::list<vpMeSite>::iterator itListCyl2;
1792 itListCyl1 = cy->
meline1->getMeList().begin();
1793 itListCyl2 = cy->
meline2->getMeList().begin();
1795 for (
unsigned int i = 0; i < cy->
nbFeaturel1; i++) {
1820 for (
unsigned int i = cy->
nbFeaturel1; i < cy->nbFeature; i++) {
1849 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1851 if ((*it)->isTracked()) {
1854 std::list<vpMeSite>::iterator itListCir;
1857 itListCir = ci->
meEllipse->getMeList().begin();
1861 for (
unsigned int i = 0; i < ci->
nbFeature; i++) {
1903 if ((*it)->isTracked()) {
1911 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
1913 if ((*it)->isTracked()) {
1921 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
1923 if ((*it)->isTracked()) {
1936 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
1938 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
1939 for (
size_t a = 0; a < (*it)->meline.size(); a++) {
1940 if ((*it)->meline[a] !=
nullptr) {
1941 delete (*it)->meline[a];
1942 (*it)->meline[a] =
nullptr;
1946 (*it)->meline.clear();
1947 (*it)->nbFeature.clear();
1948 (*it)->nbFeatureTotal = 0;
1951 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
1953 if ((*it)->meline1 !=
nullptr) {
1954 delete (*it)->meline1;
1955 (*it)->meline1 =
nullptr;
1957 if ((*it)->meline2 !=
nullptr) {
1958 delete (*it)->meline2;
1959 (*it)->meline2 =
nullptr;
1962 (*it)->nbFeature = 0;
1963 (*it)->nbFeaturel1 = 0;
1964 (*it)->nbFeaturel2 = 0;
1967 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
1968 if ((*it)->meEllipse !=
nullptr) {
1969 delete (*it)->meEllipse;
1970 (*it)->meEllipse =
nullptr;
1972 (*it)->nbFeature = 0;
1994 bool already_here =
false;
1997 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2000 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2004 already_here =
true;
2010 if (!already_here) {
2033 lines[i].push_back(l);
2050 for (
unsigned int i = 0; i <
scales.size(); i++) {
2052 for (std::list<vpMbtDistanceLine *>::iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2054 if (name.compare(l->
getName()) == 0) {
2074 const std::string &name)
2077 bool already_here =
false;
2080 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2083 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
2092 if (!already_here) {
2135 bool already_here =
false;
2138 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2141 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
2151 if (!already_here) {
2179 for (
unsigned int i = 0; i <
scales.size(); i++) {
2181 for (std::list<vpMbtDistanceCylinder *>::iterator it =
cylinders[i].begin(); it !=
cylinders[i].end(); ++it) {
2183 if (name.compare(cy->
getName()) == 0) {
2201 for (
unsigned int i = 0; i <
scales.size(); i++) {
2203 for (std::list<vpMbtDistanceCircle *>::iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
2205 if (name.compare(ci->
getName()) == 0) {
2223 for (
unsigned int i = 0; i < nbpt - 1; i++)
2243 bool changed =
false;
2251 #ifdef VISP_HAVE_OGRE
2260 newvisibleline =
true;
2263 newvisibleline =
false;
2287 for (
unsigned int i = 0; i < nbpt - 1; i++)
2311 for (
unsigned int i = 0; i < nbpt - 1; i++)
2317 unsigned int &nberrors_circles)
2319 unsigned int nbrow = 0;
2321 nberrors_cylinders = 0;
2322 nberrors_circles = 0;
2336 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
2347 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
2373 const std::string &name)
2375 addCircle(p1, p2, p3, radius, (
int)idFace, name);
2389 const std::string &name)
2406 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2408 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2415 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
2423 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
2439 #ifdef VISP_HAVE_OGRE
2480 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2482 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2489 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
2497 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
2540 unsigned int nbGoodPoints = 0;
2542 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[level].begin(); it !=
lines[level].end(); ++it) {
2545 for (
size_t a = 0; a < l->
meline.size(); a++) {
2547 for (std::list<vpMeSite>::const_iterator itme = l->
meline[a]->getMeList().begin();
2548 itme != l->
meline[a]->getMeList().end(); ++itme) {
2557 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[level].begin(); it !=
cylinders[level].end();
2561 for (std::list<vpMeSite>::const_iterator itme1 = cy->
meline1->getMeList().begin();
2562 itme1 != cy->
meline1->getMeList().end(); ++itme1) {
2566 for (std::list<vpMeSite>::const_iterator itme2 = cy->
meline2->getMeList().begin();
2567 itme2 != cy->
meline2->getMeList().end(); ++itme2) {
2575 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[level].begin(); it !=
circles[level].end(); ++it) {
2578 for (std::list<vpMeSite>::const_iterator itme = ci->
meEllipse->getMeList().begin();
2579 itme != ci->
meEllipse->getMeList().end(); ++itme) {
2586 return nbGoodPoints;
2612 unsigned int nbActivatedLevels = 0;
2613 for (
unsigned int i = 0; i < scale.size(); i++) {
2615 nbActivatedLevels++;
2619 if (scale.empty() || (nbActivatedLevels == 0)) {
2620 vpERROR_TRACE(
" !! WARNING : must use at least one level for the "
2621 "tracking. Use the global one");
2623 this->
scales.push_back(
true);
2637 lines.resize(scale.size());
2641 for (
unsigned int i = 0; i <
lines.size(); i++) {
2657 std::cerr <<
"Far clipping value cannot be inferior than near clipping "
2658 "value. Far clipping won't be considered."
2661 std::cerr <<
"Far clipping value cannot be inferior than 0. Far clipping "
2662 "won't be considered."
2668 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2670 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2687 std::cerr <<
"Near clipping value cannot be superior than far clipping "
2688 "value. Near clipping won't be considered."
2691 std::cerr <<
"Near clipping value cannot be inferior than 0. Near "
2692 "clipping won't be considered."
2698 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2700 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2722 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2724 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2750 _pyramid.resize(
scales.size());
2756 _pyramid[0] =
nullptr;
2759 for (
unsigned int i = 1; i < _pyramid.size(); i += 1) {
2761 unsigned int cScale =
static_cast<unsigned int>(pow(2., (
int)i));
2763 for (
unsigned int k = 0, ii = 0; k < I->
getHeight(); k += 1, ii += cScale) {
2764 for (
unsigned int l = 0, jj = 0; l < I->
getWidth(); l += 1, jj += cScale) {
2765 (*I)[k][l] = _I[ii][jj];
2771 _pyramid[i] =
nullptr;
2784 if (_pyramid.size() > 0) {
2785 _pyramid[0] =
nullptr;
2786 for (
unsigned int i = 1; i < _pyramid.size(); i += 1) {
2787 if (_pyramid[i] !=
nullptr) {
2789 _pyramid[i] =
nullptr;
2809 std::ostringstream oss;
2811 std::string errorMsg =
"level " + oss.str() +
" is not used, cannot get its distance lines.";
2815 linesList =
lines[level];
2831 std::ostringstream oss;
2833 std::string errorMsg =
"level " + oss.str() +
" is not used, cannot get its distance lines.";
2853 std::ostringstream oss;
2855 std::string errorMsg =
"level " + oss.str() +
" is not used, cannot get its distance lines.";
2870 const double ratio = pow(2., (
int)_scale);
2891 const double ratio = pow(2., (
int)_scale);
2919 if ((*it)->isTracked()) {
2926 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[
scaleLevel].begin();
2928 if ((*it)->isTracked()) {
2935 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[
scaleLevel].begin();
2937 if ((*it)->isTracked()) {
2957 for (
unsigned int i = 0; i <
scales.size(); i += 1) {
2959 for (std::list<vpMbtDistanceLine *>::const_iterator it =
lines[i].begin(); it !=
lines[i].end(); ++it) {
2970 (*it)->setTracked(name, useEdgeTracking);
2973 for (std::list<vpMbtDistanceCylinder *>::const_iterator it =
cylinders[i].begin(); it !=
cylinders[i].end();
2975 if (
faces[(
unsigned)(*it)->index_polygon]->getName() == name) {
2976 (*it)->setTracked(useEdgeTracking);
2980 for (std::list<vpMbtDistanceCircle *>::const_iterator it =
circles[i].begin(); it !=
circles[i].end(); ++it) {
2981 if (
faces[(
unsigned)(*it)->index_polygon]->getName() == name) {
2982 (*it)->setTracked(useEdgeTracking);
void setWindowName(const Ogre::String &n)
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int getRows() const
Generic class defining intrinsic camera parameters.
void computeFov(const unsigned int &w, const unsigned int &h)
void initFromCalibrationMatrix(const vpMatrix &_K)
Implementation of column vector and the associated operations.
void insert(unsigned int i, const vpColVector &v)
void resize(unsigned int i, bool flagNullify=true)
Class to define RGB colors available for display functionalities.
static const vpColor cyan
static const vpColor blue
static const vpColor purple
static const vpColor yellow
static const vpColor green
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void displayEllipse(const vpImage< unsigned char > &I, const vpImagePoint ¢er, const double &coef1, const double &coef2, const double &coef3, bool use_normalized_centered_moments, const vpColor &color, unsigned int thickness=1, bool display_center=false, bool display_arc=false)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
static vpHomogeneousMatrix direct(const vpColVector &v)
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
unsigned int getWidth() const
unsigned int getHeight() const
static double rad(double deg)
static Type maximum(const Type &a, const Type &b)
static double sqr(double x)
static bool equal(double x, double y, double threshold=0.001)
static Type minimum(const Type &a, const Type &b)
static int sign(double x)
static double deg(double rad)
Implementation of a matrix and operations on matrices.
vpMatrix pseudoInverse(double svThreshold=1e-6) const
void removeCircle(const std::string &name)
void computeVVS(const vpImage< unsigned char > &_I, unsigned int lvl)
vpColVector m_errorCircles
void updateMovingEdgeWeights()
vpColVector m_w_edge
Robust weights.
void upScale(const unsigned int _scale)
void addLine(vpPoint &p1, vpPoint &p2, int polygon=-1, std::string name="")
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
std::vector< std::list< vpMbtDistanceLine * > > lines
vpMe me
The moving edges parameters.
virtual void computeVVSInteractionMatrixAndResidu() VP_OVERRIDE
void displayFeaturesOnImage(const vpImage< unsigned char > &I)
void getLcylinder(std::list< vpMbtDistanceCylinder * > &cylindersList, unsigned int level=0) const
virtual void init(const vpImage< unsigned char > &I) VP_OVERRIDE
void computeProjectionError(const vpImage< unsigned char > &_I)
virtual void testTracking() VP_OVERRIDE
virtual void setNearClippingDistance(const double &dist) VP_OVERRIDE
virtual void computeVVSWeights()
virtual void track(const vpImage< unsigned char > &I) VP_OVERRIDE
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false) VP_OVERRIDE
vpColVector m_error_edge
(s - s*)
void downScale(const unsigned int _scale)
void cleanPyramid(std::vector< const vpImage< unsigned char > * > &_pyramid)
void removeCylinder(const std::string &name)
std::vector< std::list< vpMbtDistanceCylinder * > > cylinders
Vector of the tracked cylinders.
void computeVVSFirstPhase(const vpImage< unsigned char > &I, unsigned int iter, double &count, unsigned int lvl=0)
void addCircle(const vpPoint &P1, const vpPoint &P2, const vpPoint &P3, double r, int idFace=-1, const std::string &name="")
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > * > &_pyramid)
std::vector< std::vector< double > > m_featuresToBeDisplayedEdge
Display features.
unsigned int nbvisiblepolygone
Number of polygon (face) currently visible.
void addCylinder(const vpPoint &P1, const vpPoint &P2, double r, int idFace=-1, const std::string &name="")
virtual void computeVVSInit() VP_OVERRIDE
std::vector< std::list< vpMbtDistanceCircle * > > circles
Vector of the tracked circles.
void getLcircle(std::list< vpMbtDistanceCircle * > &circlesList, unsigned int level=0) const
void initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
void removeLine(const std::string &name)
virtual std::vector< std::vector< double > > getFeaturesForDisplayEdge()
virtual void initFaceFromLines(vpMbtPolygon &polygon) VP_OVERRIDE
void setScales(const std::vector< bool > &_scales)
void trackMovingEdge(const vpImage< unsigned char > &I)
std::vector< const vpImage< unsigned char > * > Ipyramid
virtual void setFarClippingDistance(const double &dist) VP_OVERRIDE
virtual unsigned int getNbPoints(unsigned int level=0) const
vpColVector m_weightedError_edge
Weighted error.
virtual void initFaceFromCorners(vpMbtPolygon &polygon) VP_OVERRIDE
std::vector< bool > scales
Vector of scale level to use for the multi-scale tracking.
void computeVVSFirstPhaseFactor(const vpImage< unsigned char > &I, unsigned int lvl=0)
void updateMovingEdge(const vpImage< unsigned char > &I)
virtual ~vpMbEdgeTracker() VP_OVERRIDE
vpMatrix m_L_edge
Interaction matrix.
vpRobust m_robustCylinders
unsigned int initMbtTracking(unsigned int &nberrors_lines, unsigned int &nberrors_cylinders, unsigned int &nberrors_circles)
void reInitLevel(const unsigned int _lvl)
virtual void setClipping(const unsigned int &flags) VP_OVERRIDE
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
virtual std::vector< std::vector< double > > getModelForDisplay(unsigned int width, unsigned int height, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, bool displayFullModel=false) VP_OVERRIDE
void computeVVSFirstPhasePoseEstimation(unsigned int iter, bool &isoJoIdentity)
void resetTracker() VP_OVERRIDE
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="") VP_OVERRIDE
void setMovingEdge(const vpMe &me)
void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
virtual void setCameraParameters(const vpCameraParameters &cam) VP_OVERRIDE
void getLline(std::list< vpMbtDistanceLine * > &linesList, unsigned int level=0) const
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace=0, const std::string &name="") VP_OVERRIDE
unsigned int nbFeaturesForProjErrorComputation
Number of features used in the computation of the projection error.
vpColVector m_factor
Edge VVS variables.
void visibleFace(const vpImage< unsigned char > &_I, const vpHomogeneousMatrix &_cMo, bool &newvisibleline)
void addPolygon(vpMbtPolygon &p)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo) VP_OVERRIDE
vpColVector m_errorCylinders
virtual void loadConfigFile(const std::string &configFile, bool verbose=true) VP_OVERRIDE
vpAROgre * getOgreContext()
void computeClippedPolygons(const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam)
bool isAppearing(unsigned int i)
unsigned int setVisibleOgre(unsigned int width, unsigned int height, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed)
bool isVisible(unsigned int i)
void initOgre(const vpCameraParameters &cam=vpCameraParameters())
unsigned int setVisible(unsigned int width, unsigned int height, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angle, bool &changed)
void setBackgroundSizeOgre(const unsigned int &h, const unsigned int &w)
void computeScanLineRender(const vpCameraParameters &cam, const unsigned int &w, const unsigned int &h)
void displayOgre(const vpHomogeneousMatrix &cMo)
void setOgreShowConfigDialog(bool showConfigDialog)
double m_lambda
Gain of the virtual visual servoing stage.
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
bool m_projectionErrorDisplay
Display gradient and model orientation for projection error computation.
virtual void setMinLineLengthThresh(double minLineLengthThresh, const std::string &name="")
vpImage< unsigned char > m_I
Grayscale image buffer, used when passing color images.
unsigned int m_projectionErrorDisplayLength
Length of the arrows used to show the gradient and model orientation.
bool samePoint(const vpPoint &P1, const vpPoint &P2) const
bool useLodGeneral
True if LOD mode is enabled.
double minPolygonAreaThresholdGeneral
Minimum polygon area threshold for LOD mode (general setting)
bool m_computeInteraction
vpMatrix oJo
The Degrees of Freedom to estimate.
virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name="")
vpUniRand m_rand
Random number generator used in vpMbtDistanceLine::buildFrom()
vpMatrix covarianceMatrix
Covariance matrix.
double m_initialMu
Initial Mu for Levenberg Marquardt optimization loop.
vpHomogeneousMatrix m_cMo
The current pose.
vpMatrix m_SobelX
Sobel kernel in X.
virtual void computeVVSCheckLevenbergMarquardt(unsigned int iter, vpColVector &error, const vpColVector &m_error_prev, const vpHomogeneousMatrix &cMoPrev, double &mu, bool &reStartFromLastIncrement, vpColVector *const w=nullptr, const vpColVector *const m_w_prev=nullptr)
vpCameraParameters m_cam
The camera parameters.
bool useOgre
Use Ogre3d for visibility tests.
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
virtual void setLod(bool useLod, const std::string &name="")
unsigned int m_projectionErrorDisplayThickness
Thickness of the arrows used to show the gradient and model orientation.
virtual void computeCovarianceMatrixVVS(const bool isoJoIdentity, const vpColVector &w_true, const vpHomogeneousMatrix &cMoPrev, const vpMatrix &L_true, const vpMatrix &LVJ_true, const vpColVector &error)
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
virtual void computeVVSPoseEstimation(const bool isoJoIdentity, 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=nullptr, vpColVector *const m_w_prev=nullptr)
bool displayFeatures
If true, the features are displayed.
double angleDisappears
Angle used to detect a face disappearance.
virtual unsigned int getNbPolygon() const
virtual void setNearClippingDistance(const double &dist)
bool applyLodSettingInConfig
virtual void setFarClippingDistance(const double &dist)
double distFarClip
Distance for near clipping.
bool m_isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
bool useScanLine
Use Scanline for visibility tests.
void computeJTR(const vpMatrix &J, const vpColVector &R, vpColVector &JTR) const
vpMatrix m_SobelY
Sobel kernel in Y.
virtual void setClipping(const unsigned int &flags)
double angleAppears
Angle used to detect a face appearance.
const vpImage< bool > * m_mask
Mask used to disable tracking on a part of image.
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
double distNearClip
Distance for near clipping.
unsigned int m_maxIter
Maximum number of iterations of the virtual visual servoing stage.
bool ogreShowConfigDialog
unsigned int clippingFlag
Flags specifying which clipping to used.
virtual void loadConfigFile(const std::string &configFile, bool verbose=true)
Manage a circle used in the model-based tracker.
void setVisible(bool _isvisible)
void setMovingEdge(vpMe *Me)
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
std::vector< std::vector< double > > getFeaturesForDisplay()
void setCameraParameters(const vpCameraParameters &camera)
vpColVector error
The error vector.
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
vpPoint * p1
The center of the circle.
unsigned int nbFeature
The number of moving edges.
vpMatrix L
The interaction matrix.
void setIndex(unsigned int i)
std::string getName() const
void trackMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo)
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, const vpPoint &_p3, double r)
vpPoint * p2
A point on the plane containing the circle.
void setMeanWeight(double _wmean)
bool Reinit
Indicates if the circle has to be reinitialized.
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpImage< bool > *mask=nullptr)
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, bool doNotTrack, const vpImage< bool > *mask=nullptr)
double radius
The radius of the circle.
int index_polygon
Index of the faces which contain the line.
void initInteractionMatrixError()
vpPoint * p3
An other point on the plane containing the circle.
vpMbtMeEllipse * meEllipse
The moving edge containers.
void setName(const std::string &circle_name)
Manage a cylinder used in the model-based tracker.
void setMeanWeight1(double wmean)
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, double r)
void setCameraParameters(const vpCameraParameters &camera)
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo, const vpImage< unsigned char > &I)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpImage< bool > *mask=nullptr)
void setName(const std::string &cyl_name)
vpMbtMeLine * meline2
The moving edge containers (second line of the cylinder)
void setVisible(bool _isvisible)
vpMatrix L
The interaction matrix.
unsigned int nbFeaturel2
The number of moving edges on line 2.
bool Reinit
Indicates if the line has to be reinitialized.
vpPoint * p2
The second extremity on the axe.
void initInteractionMatrixError()
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void setMovingEdge(vpMe *Me)
void setMeanWeight2(double wmean)
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, bool doNotTrack, const vpImage< bool > *mask=nullptr)
double radius
The radius of the cylinder.
unsigned int nbFeaturel1
The number of moving edges on line 1.
vpColVector error
The error vector.
std::string getName() const
std::vector< std::vector< double > > getFeaturesForDisplay()
unsigned int nbFeature
The number of moving edges.
int index_polygon
Index of the face which contains the cylinder.
void setIndex(unsigned int i)
void trackMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
vpPoint * p1
The first extremity on the axe.
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder)
Manage the line of a polygon used in the model-based tracker.
void setMovingEdge(vpMe *Me)
std::vector< unsigned int > nbFeature
The number of moving edges.
void updateMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
void setIndex(unsigned int i)
void computeInteractionMatrixError(const vpHomogeneousMatrix &cMo)
vpPoint * p2
The second extremity.
void initInteractionMatrixError()
std::list< int > Lindex_polygon
Index of the faces which contain the line.
void buildFrom(vpPoint &_p1, vpPoint &_p2, vpUniRand &rand_gen)
unsigned int nbFeatureTotal
The number of moving edges.
bool Reinit
Indicates if the line has to be reinitialized.
std::string getName() const
vpColVector error
The error vector.
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
bool closeToImageBorder(const vpImage< unsigned char > &I, const unsigned int threshold)
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, bool doNotTrack, const vpImage< bool > *mask=nullptr)
std::vector< std::vector< double > > getFeaturesForDisplay()
bool useScanLine
Use scanline rendering.
vpPoint * p1
The first extremity.
std::vector< vpMbtMeLine * > meline
The moving edge container.
vpMatrix L
The interaction matrix.
void setCameraParameters(const vpCameraParameters &camera)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpImage< bool > *mask=nullptr)
void setName(const std::string &line_name)
void setMeanWeight(double w_mean)
void setVisible(bool _isvisible)
void addPolygon(const int &index)
void trackMovingEdge(const vpImage< unsigned char > &I)
vpMbtPolygon & getPolygon()
Implementation of a polygon of the model used by the model-based tracker.
std::string getName() const
Parse an Xml file to extract configuration parameters of a mbtConfig object.
void getCameraParameters(vpCameraParameters &cam) const
double getAngleAppear() const
void setEdgeMe(const vpMe &ecm)
void getEdgeMe(vpMe &ecm) const
double getLodMinLineLengthThreshold() const
void setAngleDisappear(const double &adisappear)
double getAngleDisappear() const
void setAngleAppear(const double &aappear)
void parse(const std::string &filename)
double getNearClippingDistance() const
bool hasNearClippingDistance() const
bool hasFarClippingDistance() const
void setCameraParameters(const vpCameraParameters &cam)
double getFarClippingDistance() const
bool getFovClipping() const
double getLodMinPolygonAreaThreshold() const
void setVerbose(bool verbose)
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'....
@ TOO_NEAR
Point not tracked anymore, since too near from its neighbor.
@ THRESHOLD
Point not tracked due to the likelihood that is below the threshold, but retained in the ME list.
@ CONTRAST
Point not tracked due to a contrast problem, but retained in the ME list.
@ M_ESTIMATOR
Point detected as an outlier during virtual visual-servoing.
@ NO_SUPPRESSION
Point successfully tracked.
vpMeSiteState getState() const
void setState(const vpMeSiteState &flag)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
void setFarClippingDistance(const double &dist)
unsigned int getNbPoint() const
void setNearClippingDistance(const double &dist)
vpPoint * p
corners in the object frame
void setClipping(const unsigned int &flags)
@ TUKEY
Tukey influence function.
void MEstimator(const vpRobustEstimatorType method, const vpColVector &residues, vpColVector &weights)
void setMinMedianAbsoluteDeviation(double mad_min)
Error that can be emitted by the vpTracker class and its derivatives.
@ notEnoughPointError
Not enough point to track.
@ fatalError
Tracker fatal error.
vpVelocityTwistMatrix & buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)