36 #include <visp3/mbt/vpMbGenericTracker.h> 38 #include <visp3/core/vpDisplay.h> 39 #include <visp3/core/vpExponentialMap.h> 40 #include <visp3/core/vpTrackingException.h> 41 #include <visp3/mbt/vpMbtXmlGenericParser.h> 44 : m_error(), m_L(), m_mapOfCameraTransformationMatrix(), m_mapOfFeatureFactors(), m_mapOfTrackers(),
45 m_percentageGdPt(0.4), m_referenceCameraName(
"Camera"), m_thresholdOutlier(0.5), m_w(), m_weightedError()
55 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 69 }
else if (nbCameras == 1) {
75 for (
unsigned int i = 1; i <= nbCameras; i++) {
91 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 103 if (trackerTypes.empty()) {
107 if (trackerTypes.size() == 1) {
113 for (
size_t i = 1; i <= trackerTypes.size(); i++) {
114 std::stringstream ss;
129 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 138 const std::vector<int> &trackerTypes)
142 if (cameraNames.size() != trackerTypes.size() || cameraNames.empty()) {
144 "cameraNames.size() != trackerTypes.size() || cameraNames.empty()");
147 for (
size_t i = 0; i < cameraNames.size(); i++) {
160 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 180 double rawTotalProjectionError = 0.0;
181 unsigned int nbTotalFeaturesUsed = 0;
183 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
185 TrackerWrapper *tracker = it->second;
187 double curProjError = tracker->getProjectionError();
188 unsigned int nbFeaturesUsed = tracker->nbFeaturesForProjErrorComputation;
190 if (nbFeaturesUsed > 0) {
191 nbTotalFeaturesUsed += nbFeaturesUsed;
192 rawTotalProjectionError += (
vpMath::rad(curProjError) * nbFeaturesUsed);
196 if (nbTotalFeaturesUsed > 0) {
215 double normRes_1 = -1;
216 unsigned int iter = 0;
225 bool isoJoIdentity_ =
true;
232 std::map<std::string, vpVelocityTwistMatrix> mapOfVelocityTwist;
237 mapOfVelocityTwist[it->first] = cVo;
241 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 250 bool reStartFromLastIncrement =
false;
252 if (reStartFromLastIncrement) {
253 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
255 TrackerWrapper *tracker = it->second;
259 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 262 tracker->ctTc0 = c_curr_tTc_curr0;
267 if (!reStartFromLastIncrement) {
272 if (!isoJoIdentity_) {
275 LVJ_true = (
m_L * (cVo *
oJo));
281 isoJoIdentity_ =
true;
288 if (isoJoIdentity_) {
292 unsigned int rank = (
m_L * cVo).kernel(K);
302 isoJoIdentity_ =
false;
311 unsigned int start_index = 0;
312 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
314 TrackerWrapper *tracker = it->second;
317 for (
unsigned int i = 0; i < tracker->m_error_edge.getRows(); i++) {
318 double wi = tracker->m_w_edge[i] * tracker->m_factor[i] * factorEdge;
319 W_true[start_index + i] = wi;
325 for (
unsigned int j = 0; j <
m_L.
getCols(); j++) {
326 m_L[start_index + i][j] *= wi;
330 start_index += tracker->m_error_edge.
getRows();
333 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 335 for (
unsigned int i = 0; i < tracker->m_error_klt.getRows(); i++) {
336 double wi = tracker->m_w_klt[i] * factorKlt;
337 W_true[start_index + i] = wi;
343 for (
unsigned int j = 0; j <
m_L.
getCols(); j++) {
344 m_L[start_index + i][j] *= wi;
348 start_index += tracker->m_error_klt.
getRows();
353 for (
unsigned int i = 0; i < tracker->m_error_depthNormal.getRows(); i++) {
354 double wi = tracker->m_w_depthNormal[i] * factorDepth;
360 for (
unsigned int j = 0; j <
m_L.
getCols(); j++) {
361 m_L[start_index + i][j] *= wi;
365 start_index += tracker->m_error_depthNormal.
getRows();
369 for (
unsigned int i = 0; i < tracker->m_error_depthDense.getRows(); i++) {
370 double wi = tracker->m_w_depthDense[i] * factorDepthDense;
376 for (
unsigned int j = 0; j <
m_L.
getCols(); j++) {
377 m_L[start_index + i][j] *= wi;
381 start_index += tracker->m_error_depthDense.
getRows();
386 normRes = sqrt(num / den);
394 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 395 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
397 TrackerWrapper *tracker = it->second;
401 tracker->ctTc0 = c_curr_tTc_curr0;
406 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
408 TrackerWrapper *tracker = it->second;
418 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
420 TrackerWrapper *tracker = it->second;
423 tracker->updateMovingEdgeWeights();
435 unsigned int nbFeatures = 0;
437 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
439 TrackerWrapper *tracker = it->second;
440 tracker->computeVVSInit(mapOfImages[it->first]);
442 nbFeatures += tracker->m_error.getRows();
456 "computeVVSInteractionMatrixAndR" 457 "esidu() should not be called");
462 std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist)
464 unsigned int start_index = 0;
466 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
468 TrackerWrapper *tracker = it->second;
471 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 473 tracker->ctTc0 = c_curr_tTc_curr0;
476 tracker->computeVVSInteractionMatrixAndResidu(mapOfImages[it->first]);
478 m_L.
insert(tracker->m_L * mapOfVelocityTwist[it->first], start_index, 0);
481 start_index += tracker->m_error.getRows();
487 unsigned int start_index = 0;
489 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
491 TrackerWrapper *tracker = it->second;
492 tracker->computeVVSWeights();
495 start_index += tracker->m_w.getRows();
514 const bool displayFullModel)
518 TrackerWrapper *tracker = it->second;
519 tracker->display(I, cMo_, cam_, col, thickness, displayFullModel);
540 const bool displayFullModel)
544 TrackerWrapper *tracker = it->second;
545 tracker->display(I, cMo_, cam_, col, thickness, displayFullModel);
570 const unsigned int thickness,
const bool displayFullModel)
573 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
574 it->second->display(I1, c1Mo, cam1, color, thickness, displayFullModel);
577 it->second->display(I2, c2Mo, cam2, color, thickness, displayFullModel);
579 std::cerr <<
"The tracker is not set as a stereo configuration! There are " <<
m_mapOfTrackers.size() <<
" cameras!" 603 const bool displayFullModel)
606 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
607 it->second->display(I1, c1Mo, cam1, color, thickness, displayFullModel);
610 it->second->display(I2, c2Mo, cam2, color, thickness, displayFullModel);
612 std::cerr <<
"The tracker is not set as a stereo configuration! There are " <<
m_mapOfTrackers.size() <<
" cameras!" 629 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
630 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
631 const vpColor &col,
const unsigned int thickness,
const bool displayFullModel)
635 it_img != mapOfImages.end(); ++it_img) {
636 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it_img->first);
637 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(it_img->first);
638 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_img->first);
640 if (it_tracker !=
m_mapOfTrackers.end() && it_camPose != mapOfCameraPoses.end() &&
641 it_cam != mapOfCameraParameters.end()) {
642 TrackerWrapper *tracker = it_tracker->second;
643 tracker->display(*it_img->second, it_camPose->second, it_cam->second, col, thickness, displayFullModel);
645 std::cerr <<
"Missing elements for image:" << it_img->first <<
"!" << std::endl;
662 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
663 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
664 const vpColor &col,
const unsigned int thickness,
const bool displayFullModel)
667 for (std::map<std::string,
const vpImage<vpRGBa> *>::const_iterator it_img = mapOfImages.begin();
668 it_img != mapOfImages.end(); ++it_img) {
669 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it_img->first);
670 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(it_img->first);
671 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_img->first);
673 if (it_tracker !=
m_mapOfTrackers.end() && it_camPose != mapOfCameraPoses.end() &&
674 it_cam != mapOfCameraParameters.end()) {
675 TrackerWrapper *tracker = it_tracker->second;
676 tracker->display(*it_img->second, it_camPose->second, it_cam->second, col, thickness, displayFullModel);
678 std::cerr <<
"Missing elements for image:" << it_img->first <<
"!" << std::endl;
690 std::vector<std::string> cameraNames;
692 for (std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.begin();
694 cameraNames.push_back(it_tracker->first);
711 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
712 it->second->getCameraParameters(cam1);
715 it->second->getCameraParameters(cam2);
717 std::cerr <<
"The tracker is not set as a stereo configuration! There are " <<
m_mapOfTrackers.size() <<
" cameras!" 730 mapOfCameraParameters.clear();
732 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
735 it->second->getCameraParameters(cam_);
736 mapOfCameraParameters[it->first] = cam_;
748 std::map<std::string, int> trackingTypes;
750 TrackerWrapper *traker;
751 for (std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.begin();
753 traker = it_tracker->second;
754 trackingTypes[it_tracker->first] = traker->getTrackerType();
757 return trackingTypes;
771 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
772 clippingFlag1 = it->second->getClipping();
775 clippingFlag2 = it->second->getClipping();
777 std::cerr <<
"The tracker is not set as a stereo configuration! There are " <<
m_mapOfTrackers.size() <<
" cameras!" 789 mapOfClippingFlags.clear();
791 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
793 TrackerWrapper *tracker = it->second;
794 mapOfClippingFlags[it->first] = tracker->getClipping();
807 return it->second->getFaces();
821 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.find(cameraName);
823 return it->second->getFaces();
826 std::cerr <<
"The camera: " << cameraName <<
" cannot be found!" << std::endl;
830 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 838 TrackerWrapper *tracker = it->second;
839 return tracker->getFeaturesCircle();
853 TrackerWrapper *tracker = it->second;
854 return tracker->getFeaturesKltCylinder();
868 TrackerWrapper *tracker = it->second;
869 return tracker->getFeaturesKlt();
888 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 901 TrackerWrapper *tracker = it->second;
902 return tracker->getKltImagePoints();
907 return std::vector<vpImagePoint>();
922 TrackerWrapper *tracker = it->second;
923 return tracker->getKltImagePointsWithId();
928 return std::map<int, vpImagePoint>();
940 TrackerWrapper *tracker = it->second;
941 return tracker->getKltMaskBorder();
958 TrackerWrapper *tracker = it->second;
959 return tracker->getKltNbPoints();
977 TrackerWrapper *tracker;
978 tracker = it_tracker->second;
979 return tracker->getKltOpencv();
998 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
999 klt1 = it->second->getKltOpencv();
1002 klt2 = it->second->getKltOpencv();
1004 std::cerr <<
"The tracker is not set as a stereo configuration! There are " <<
m_mapOfTrackers.size() <<
" cameras!" 1018 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1020 TrackerWrapper *tracker = it->second;
1021 mapOfKlts[it->first] = tracker->getKltOpencv();
1025 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408) 1035 TrackerWrapper *tracker = it->second;
1036 return tracker->getKltPoints();
1041 return std::vector<cv::Point2f>();
1069 const unsigned int level)
const 1071 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.find(cameraName);
1073 it->second->getLcircle(circlesList, level);
1075 std::cerr <<
"The camera: " << cameraName <<
" does not exist!" << std::endl;
1094 const unsigned int level)
const 1096 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.find(cameraName);
1098 it->second->getLcylinder(cylindersList, level);
1100 std::cerr <<
"The camera: " << cameraName <<
" does not exist!" << std::endl;
1119 const unsigned int level)
const 1121 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.find(cameraName);
1123 it->second->getLline(linesList, level);
1125 std::cerr <<
"The camera: " << cameraName <<
" does not exist!" << std::endl;
1139 return it->second->getMovingEdge();
1158 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1159 it->second->getMovingEdge(me1);
1162 it->second->getMovingEdge(me2);
1164 std::cerr <<
"The tracker is not set as a stereo configuration! There are " <<
m_mapOfTrackers.size() <<
" cameras!" 1169 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 1180 mapOfMovingEdges.clear();
1182 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1184 TrackerWrapper *tracker = it->second;
1185 mapOfMovingEdges[it->first] = tracker->getMovingEdge();
1208 unsigned int nbGoodPoints = 0;
1211 nbGoodPoints = it->second->getNbPoints(level);
1216 return nbGoodPoints;
1235 mapOfNbPoints.clear();
1237 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1239 TrackerWrapper *tracker = it->second;
1240 mapOfNbPoints[it->first] = tracker->getNbPoints(level);
1253 return it->second->getNbPolygon();
1267 mapOfNbPolygons.clear();
1269 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1271 TrackerWrapper *tracker = it->second;
1272 mapOfNbPolygons[it->first] = tracker->getNbPolygon();
1290 return it->second->getPolygon(index);
1310 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.find(cameraName);
1312 return it->second->getPolygon(index);
1315 std::cerr <<
"The camera: " << cameraName <<
" does not exist!" << std::endl;
1334 std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
1337 std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > > polygonFaces;
1341 TrackerWrapper *tracker = it->second;
1342 polygonFaces = tracker->getPolygonFaces(orderPolygons, useVisibility, clipPolygon);
1347 return polygonFaces;
1368 std::map<std::string, std::vector<std::vector<vpPoint> > > &mapOfPoints,
1369 const bool orderPolygons,
const bool useVisibility,
const bool clipPolygon)
1371 mapOfPolygons.clear();
1372 mapOfPoints.clear();
1374 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1376 TrackerWrapper *tracker = it->second;
1377 std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > > polygonFaces =
1378 tracker->getPolygonFaces(orderPolygons, useVisibility, clipPolygon);
1380 mapOfPolygons[it->first] = polygonFaces.first;
1381 mapOfPoints[it->first] = polygonFaces.second;
1396 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1397 it->second->getPose(c1Mo);
1400 it->second->getPose(c2Mo);
1402 std::cerr <<
"The tracker is not set as a stereo configuration! There are " <<
m_mapOfTrackers.size() <<
" cameras!" 1415 mapOfCameraPoses.clear();
1417 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1419 TrackerWrapper *tracker = it->second;
1420 tracker->getPose(mapOfCameraPoses[it->first]);
1426 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1428 TrackerWrapper *tracker = it->second;
1435 const double ,
const int ,
const std::string & )
1440 #ifdef VISP_HAVE_MODULE_GUI 1479 const std::string &initFile1,
const std::string &initFile2,
const bool displayHelp)
1482 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1483 TrackerWrapper *tracker = it->second;
1484 tracker->initClick(I1, initFile1, displayHelp);
1488 tracker = it->second;
1489 tracker->initClick(I2, initFile2, displayHelp);
1493 tracker = it->second;
1496 tracker->getPose(
cMo);
1500 "Cannot initClick()! Require two cameras but there are %d cameras!",
m_mapOfTrackers.size());
1542 const std::map<std::string, std::string> &mapOfInitFiles,
const bool displayHelp)
1545 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1547 std::map<std::string, std::string>::const_iterator it_initFile = mapOfInitFiles.find(
m_referenceCameraName);
1549 if (it_tracker !=
m_mapOfTrackers.end() && it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1550 TrackerWrapper *tracker = it_tracker->second;
1551 tracker->initClick(*it_img->second, it_initFile->second, displayHelp);
1552 tracker->getPose(
cMo);
1558 std::vector<std::string> vectorOfMissingCameraPoses;
1563 it_img = mapOfImages.find(it_tracker->first);
1564 it_initFile = mapOfInitFiles.find(it_tracker->first);
1566 if (it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1568 TrackerWrapper *tracker = it_tracker->second;
1569 tracker->initClick(*it_img->second, it_initFile->second, displayHelp);
1571 vectorOfMissingCameraPoses.push_back(it_tracker->first);
1577 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameraPoses.begin();
1578 it != vectorOfMissingCameraPoses.end(); ++it) {
1579 it_img = mapOfImages.find(*it);
1580 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1589 "Missing image or missing camera transformation " 1590 "matrix! Cannot set the pose for camera: %s!",
1598 const int ,
const std::string & )
1643 const std::string &initFile1,
const std::string &initFile2)
1646 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1647 TrackerWrapper *tracker = it->second;
1648 tracker->initFromPoints(I1, initFile1);
1652 tracker = it->second;
1653 tracker->initFromPoints(I2, initFile2);
1657 tracker = it->second;
1660 tracker->getPose(
cMo);
1663 tracker->getCameraParameters(
cam);
1667 "Cannot initFromPoints()! Require two cameras but " 1668 "there are %d cameras!",
1674 const std::map<std::string, std::string> &mapOfInitPoints)
1678 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1680 std::map<std::string, std::string>::const_iterator it_initPoints = mapOfInitPoints.find(
m_referenceCameraName);
1682 if (it_tracker !=
m_mapOfTrackers.end() && it_img != mapOfImages.end() && it_initPoints != mapOfInitPoints.end()) {
1683 TrackerWrapper *tracker = it_tracker->second;
1684 tracker->initFromPoints(*it_img->second, it_initPoints->second);
1685 tracker->getPose(
cMo);
1691 std::vector<std::string> vectorOfMissingCameraPoints;
1695 it_img = mapOfImages.find(it_tracker->first);
1696 it_initPoints = mapOfInitPoints.find(it_tracker->first);
1698 if (it_img != mapOfImages.end() && it_initPoints != mapOfInitPoints.end()) {
1700 it_tracker->second->initFromPoints(*it_img->second, it_initPoints->second);
1702 vectorOfMissingCameraPoints.push_back(it_tracker->first);
1706 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameraPoints.begin();
1707 it != vectorOfMissingCameraPoints.end(); ++it) {
1708 it_img = mapOfImages.find(*it);
1709 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1717 "Missing image or missing camera transformation " 1718 "matrix! Cannot init the pose for camera: %s!",
1736 const std::string &initFile1,
const std::string &initFile2)
1739 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1740 TrackerWrapper *tracker = it->second;
1741 tracker->initFromPose(I1, initFile1);
1745 tracker = it->second;
1746 tracker->initFromPose(I2, initFile2);
1750 tracker = it->second;
1753 tracker->getPose(
cMo);
1756 tracker->getCameraParameters(
cam);
1760 "Cannot initFromPose()! Require two cameras but there " 1781 const std::map<std::string, std::string> &mapOfInitPoses)
1785 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1787 std::map<std::string, std::string>::const_iterator it_initPose = mapOfInitPoses.find(
m_referenceCameraName);
1789 if (it_tracker !=
m_mapOfTrackers.end() && it_img != mapOfImages.end() && it_initPose != mapOfInitPoses.end()) {
1790 TrackerWrapper *tracker = it_tracker->second;
1791 tracker->initFromPose(*it_img->second, it_initPose->second);
1792 tracker->getPose(
cMo);
1798 std::vector<std::string> vectorOfMissingCameraPoses;
1802 it_img = mapOfImages.find(it_tracker->first);
1803 it_initPose = mapOfInitPoses.find(it_tracker->first);
1805 if (it_img != mapOfImages.end() && it_initPose != mapOfInitPoses.end()) {
1807 it_tracker->second->initFromPose(*it_img->second, it_initPose->second);
1809 vectorOfMissingCameraPoses.push_back(it_tracker->first);
1813 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameraPoses.begin();
1814 it != vectorOfMissingCameraPoses.end(); ++it) {
1815 it_img = mapOfImages.find(*it);
1816 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1824 "Missing image or missing camera transformation " 1825 "matrix! Cannot init the pose for camera: %s!",
1845 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1846 it->second->initFromPose(I1, c1Mo);
1850 it->second->initFromPose(I2, c2Mo);
1855 "This method requires 2 cameras but there are %d cameras!",
m_mapOfTrackers.size());
1873 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
1877 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1879 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
1881 if (it_tracker !=
m_mapOfTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1882 TrackerWrapper *tracker = it_tracker->second;
1883 tracker->initFromPose(*it_img->second, it_camPose->second);
1884 tracker->getPose(
cMo);
1890 std::vector<std::string> vectorOfMissingCameraPoses;
1894 it_img = mapOfImages.find(it_tracker->first);
1895 it_camPose = mapOfCameraPoses.find(it_tracker->first);
1897 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1899 it_tracker->second->initFromPose(*it_img->second, it_camPose->second);
1901 vectorOfMissingCameraPoses.push_back(it_tracker->first);
1905 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameraPoses.begin();
1906 it != vectorOfMissingCameraPoses.end(); ++it) {
1907 it_img = mapOfImages.find(*it);
1908 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1916 "Missing image or missing camera transformation " 1917 "matrix! Cannot set the pose for camera: %s!",
1940 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
1942 TrackerWrapper *tracker = it->second;
1943 tracker->loadConfigFile(configFile);
1977 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.begin();
1978 TrackerWrapper *tracker = it_tracker->second;
1979 tracker->loadConfigFile(configFile1);
1982 tracker = it_tracker->second;
1983 tracker->loadConfigFile(configFile2);
2011 for (std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.begin();
2013 TrackerWrapper *tracker = it_tracker->second;
2015 std::map<std::string, std::string>::const_iterator it_config = mapOfConfigFiles.find(it_tracker->first);
2016 if (it_config != mapOfConfigFiles.end()) {
2017 tracker->loadConfigFile(it_config->second);
2020 it_tracker->first.c_str());
2027 TrackerWrapper *tracker = it->second;
2028 tracker->getCameraParameters(
cam);
2070 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2072 TrackerWrapper *tracker = it->second;
2073 tracker->loadModel(modelFile, verbose);
2112 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.begin();
2113 TrackerWrapper *tracker = it_tracker->second;
2114 tracker->loadModel(modelFile1, verbose);
2117 tracker = it_tracker->second;
2118 tracker->loadModel(modelFile2, verbose);
2150 for (std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.begin();
2152 std::map<std::string, std::string>::const_iterator it_model = mapOfModelFiles.find(it_tracker->first);
2154 if (it_model != mapOfModelFiles.end()) {
2155 TrackerWrapper *tracker = it_tracker->second;
2156 tracker->loadModel(it_model->second, verbose);
2159 it_tracker->first.c_str());
2164 #ifdef VISP_HAVE_PCL 2166 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds)
2168 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2170 TrackerWrapper *tracker = it->second;
2171 tracker->preTracking(mapOfImages[it->first], mapOfPointClouds[it->first]);
2177 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
2178 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
2179 std::map<std::string, unsigned int> &mapOfPointCloudHeights)
2181 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2183 TrackerWrapper *tracker = it->second;
2184 tracker->preTracking(mapOfImages[it->first], mapOfPointClouds[it->first], mapOfPointCloudWidths[it->first],
2185 mapOfPointCloudHeights[it->first]);
2208 TrackerWrapper *tracker = it_tracker->second;
2209 tracker->reInitModel(I, cad_name, cMo_, verbose);
2212 tracker->getPose(
cMo);
2236 const std::string &cad_name1,
const std::string &cad_name2,
2241 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.begin();
2243 it_tracker->second->reInitModel(I1, cad_name1, c1Mo, verbose);
2247 it_tracker->second->reInitModel(I2, cad_name2, c2Mo, verbose);
2252 it_tracker->second->getPose(
cMo);
2272 const std::map<std::string, std::string> &mapOfModelFiles,
2273 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
2277 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2279 std::map<std::string, std::string>::const_iterator it_model = mapOfModelFiles.find(
m_referenceCameraName);
2280 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
2282 if (it_tracker !=
m_mapOfTrackers.end() && it_img != mapOfImages.end() && it_model != mapOfModelFiles.end() &&
2283 it_camPose != mapOfCameraPoses.end()) {
2284 TrackerWrapper *tracker = it_tracker->second;
2285 tracker->reInitModel(*it_img->second, it_model->second, it_camPose->second, verbose);
2288 tracker->getPose(
cMo);
2293 std::vector<std::string> vectorOfMissingCameras;
2296 it_img = mapOfImages.find(it_tracker->first);
2297 it_model = mapOfModelFiles.find(it_tracker->first);
2298 it_camPose = mapOfCameraPoses.find(it_tracker->first);
2300 if (it_img != mapOfImages.end() && it_model != mapOfModelFiles.end() && it_camPose != mapOfCameraPoses.end()) {
2301 TrackerWrapper *tracker = it_tracker->second;
2302 tracker->reInitModel(*it_img->second, it_model->second, it_camPose->second, verbose);
2304 vectorOfMissingCameras.push_back(it_tracker->first);
2309 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameras.begin(); it != vectorOfMissingCameras.end();
2311 it_img = mapOfImages.find(*it);
2312 it_model = mapOfModelFiles.find(*it);
2313 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2316 if (it_img != mapOfImages.end() && it_model != mapOfModelFiles.end() &&
2319 m_mapOfTrackers[*it]->reInitModel(*it_img->second, it_model->second, cCurrentMo, verbose);
2336 #ifdef VISP_HAVE_OGRE 2363 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 2370 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2372 TrackerWrapper *tracker = it->second;
2373 tracker->resetTracker();
2390 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2392 TrackerWrapper *tracker = it->second;
2393 tracker->setAngleAppear(a);
2412 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2413 it->second->setAngleAppear(a1);
2416 it->second->setAngleAppear(a2);
2441 for (std::map<std::string, double>::const_iterator it = mapOfAngles.begin(); it != mapOfAngles.end(); ++it) {
2442 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it->first);
2445 TrackerWrapper *tracker = it_tracker->second;
2446 tracker->setAngleAppear(it->second);
2468 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2470 TrackerWrapper *tracker = it->second;
2471 tracker->setAngleDisappear(a);
2490 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2491 it->second->setAngleDisappear(a1);
2494 it->second->setAngleDisappear(a2);
2519 for (std::map<std::string, double>::const_iterator it = mapOfAngles.begin(); it != mapOfAngles.end(); ++it) {
2520 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it->first);
2523 TrackerWrapper *tracker = it_tracker->second;
2524 tracker->setAngleDisappear(it->second);
2542 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2544 TrackerWrapper *tracker = it->second;
2545 tracker->setCameraParameters(camera);
2560 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2561 it->second->setCameraParameters(camera1);
2564 it->second->setCameraParameters(camera2);
2568 it->second->getCameraParameters(
cam);
2588 for (std::map<std::string, vpCameraParameters>::const_iterator it = mapOfCameraParameters.begin();
2589 it != mapOfCameraParameters.end(); ++it) {
2590 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it->first);
2593 TrackerWrapper *tracker = it_tracker->second;
2594 tracker->setCameraParameters(it->second);
2617 it->second = cameraTransformationMatrix;
2631 const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix)
2633 for (std::map<std::string, vpHomogeneousMatrix>::const_iterator it = mapOfTransformationMatrix.begin();
2634 it != mapOfTransformationMatrix.end(); ++it) {
2635 std::map<std::string, vpHomogeneousMatrix>::iterator it_camTrans =
2639 it_camTrans->second = it->second;
2657 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2659 TrackerWrapper *tracker = it->second;
2660 tracker->setClipping(flags);
2677 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2678 it->second->setClipping(flags1);
2681 it->second->setClipping(flags2);
2690 std::stringstream ss;
2691 ss <<
"Require two cameras! There are " <<
m_mapOfTrackers.size() <<
" cameras!";
2707 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2709 TrackerWrapper *tracker = it->second;
2710 tracker->setDepthDenseFilteringMaxDistance(maxDistance);
2724 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2726 TrackerWrapper *tracker = it->second;
2727 tracker->setDepthDenseFilteringMethod(method);
2742 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2744 TrackerWrapper *tracker = it->second;
2745 tracker->setDepthDenseFilteringMinDistance(minDistance);
2760 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2762 TrackerWrapper *tracker = it->second;
2763 tracker->setDepthDenseFilteringOccupancyRatio(occupancyRatio);
2777 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2779 TrackerWrapper *tracker = it->second;
2780 tracker->setDepthDenseSamplingStep(stepX, stepY);
2793 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2795 TrackerWrapper *tracker = it->second;
2796 tracker->setDepthNormalFaceCentroidMethod(method);
2810 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2812 TrackerWrapper *tracker = it->second;
2813 tracker->setDepthNormalFeatureEstimationMethod(method);
2826 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2828 TrackerWrapper *tracker = it->second;
2829 tracker->setDepthNormalPclPlaneEstimationMethod(method);
2842 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2844 TrackerWrapper *tracker = it->second;
2845 tracker->setDepthNormalPclPlaneEstimationRansacMaxIter(maxIter);
2858 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2860 TrackerWrapper *tracker = it->second;
2861 tracker->setDepthNormalPclPlaneEstimationRansacThreshold(thresold);
2875 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2877 TrackerWrapper *tracker = it->second;
2878 tracker->setDepthNormalSamplingStep(stepX, stepY);
2891 for (std::map<std::string, unsigned int>::const_iterator it = mapOfClippingFlags.begin();
2892 it != mapOfClippingFlags.end(); ++it) {
2893 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it->first);
2896 TrackerWrapper *tracker = it_tracker->second;
2897 tracker->setClipping(it->second);
2928 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2930 TrackerWrapper *tracker = it->second;
2931 tracker->setDisplayFeatures(displayF);
2946 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2948 TrackerWrapper *tracker = it->second;
2949 tracker->setFarClippingDistance(dist);
2964 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
2965 it->second->setFarClippingDistance(dist1);
2968 it->second->setFarClippingDistance(dist2);
2972 distFarClip = it->second->getFarClippingDistance();
2989 for (std::map<std::string, double>::const_iterator it = mapOfClippingDists.begin(); it != mapOfClippingDists.end();
2991 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it->first);
2994 TrackerWrapper *tracker = it_tracker->second;
2995 tracker->setFarClippingDistance(it->second);
3014 std::map<vpTrackerType, double>::const_iterator it_factor = mapOfFeatureFactors.find(it->first);
3015 if (it_factor != mapOfFeatureFactors.end()) {
3016 it->second = it_factor->second;
3040 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3042 TrackerWrapper *tracker = it->second;
3043 tracker->setGoodMovingEdgesRatioThreshold(threshold);
3047 #ifdef VISP_HAVE_OGRE 3061 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3063 TrackerWrapper *tracker = it->second;
3064 tracker->setGoodNbRayCastingAttemptsRatio(ratio);
3081 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3083 TrackerWrapper *tracker = it->second;
3084 tracker->setNbRayCastingAttemptsForVisibility(attempts);
3089 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 3099 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3101 TrackerWrapper *tracker = it->second;
3102 tracker->setKltOpencv(t);
3117 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3118 it->second->setKltOpencv(t1);
3121 it->second->setKltOpencv(t2);
3135 for (std::map<std::string, vpKltOpencv>::const_iterator it = mapOfKlts.begin(); it != mapOfKlts.end(); ++it) {
3136 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it->first);
3139 TrackerWrapper *tracker = it_tracker->second;
3140 tracker->setKltOpencv(it->second);
3156 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3158 TrackerWrapper *tracker = it->second;
3159 tracker->setKltThresholdAcceptation(th);
3178 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3180 TrackerWrapper *tracker = it->second;
3181 tracker->setLod(useLod, name);
3185 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 3195 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3197 TrackerWrapper *tracker = it->second;
3198 tracker->setKltMaskBorder(e);
3213 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3214 it->second->setKltMaskBorder(e1);
3218 it->second->setKltMaskBorder(e2);
3232 for (std::map<std::string, unsigned int>::const_iterator it = mapOfErosions.begin(); it != mapOfErosions.end();
3234 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it->first);
3237 TrackerWrapper *tracker = it_tracker->second;
3238 tracker->setKltMaskBorder(it->second);
3257 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3259 TrackerWrapper *tracker = it->second;
3260 tracker->setMinLineLengthThresh(minLineLengthThresh, name);
3276 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3278 TrackerWrapper *tracker = it->second;
3279 tracker->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
3292 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3294 TrackerWrapper *tracker = it->second;
3295 tracker->setMovingEdge(me);
3311 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3312 it->second->setMovingEdge(me1);
3316 it->second->setMovingEdge(me2);
3330 for (std::map<std::string, vpMe>::const_iterator it = mapOfMe.begin(); it != mapOfMe.end(); ++it) {
3331 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it->first);
3334 TrackerWrapper *tracker = it_tracker->second;
3335 tracker->setMovingEdge(it->second);
3351 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3353 TrackerWrapper *tracker = it->second;
3354 tracker->setNearClippingDistance(dist);
3369 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3370 it->second->setNearClippingDistance(dist1);
3374 it->second->setNearClippingDistance(dist2);
3395 for (std::map<std::string, double>::const_iterator it = mapOfDists.begin(); it != mapOfDists.end(); ++it) {
3396 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it->first);
3399 TrackerWrapper *tracker = it_tracker->second;
3400 tracker->setNearClippingDistance(it->second);
3425 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3427 TrackerWrapper *tracker = it->second;
3428 tracker->setOgreShowConfigDialog(showConfigDialog);
3446 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3448 TrackerWrapper *tracker = it->second;
3449 tracker->setOgreVisibilityTest(v);
3452 #ifdef VISP_HAVE_OGRE 3453 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3455 TrackerWrapper *tracker = it->second;
3456 tracker->faces.getOgreContext()->setWindowName(
"Multi Generic MBT (" + it->first +
")");
3472 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3474 TrackerWrapper *tracker = it->second;
3475 tracker->setOptimizationMethod(opt);
3495 "to be configured with only one camera!");
3502 TrackerWrapper *tracker = it->second;
3503 tracker->setPose(I, cdMo);
3525 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3526 it->second->setPose(I1, c1Mo);
3530 it->second->setPose(I2, c2Mo);
3535 it->second->getPose(
cMo);
3562 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
3566 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
3568 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
3570 if (it_tracker !=
m_mapOfTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
3571 TrackerWrapper *tracker = it_tracker->second;
3572 tracker->setPose(*it_img->second, it_camPose->second);
3573 tracker->getPose(
cMo);
3579 std::vector<std::string> vectorOfMissingCameraPoses;
3584 it_img = mapOfImages.find(it_tracker->first);
3585 it_camPose = mapOfCameraPoses.find(it_tracker->first);
3587 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
3589 TrackerWrapper *tracker = it_tracker->second;
3590 tracker->setPose(*it_img->second, it_camPose->second);
3592 vectorOfMissingCameraPoses.push_back(it_tracker->first);
3597 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameraPoses.begin();
3598 it != vectorOfMissingCameraPoses.end(); ++it) {
3599 it_img = mapOfImages.find(*it);
3600 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
3608 "Missing image or missing camera transformation " 3609 "matrix! Cannot set pose for camera: %s!",
3633 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3635 TrackerWrapper *tracker = it->second;
3636 tracker->setProjectionErrorComputation(flag);
3647 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.find(referenceCameraName);
3651 std::cerr <<
"The reference camera: " << referenceCameraName <<
" does not exist!";
3659 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3661 TrackerWrapper *tracker = it->second;
3662 tracker->setScanLineVisibilityTest(v);
3679 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3681 TrackerWrapper *tracker = it->second;
3682 tracker->setTrackerType(type);
3697 for (std::map<std::string, int>::const_iterator it = mapOfTrackerTypes.begin(); it != mapOfTrackerTypes.end(); ++it) {
3698 std::map<std::string, TrackerWrapper *>::const_iterator it_tracker =
m_mapOfTrackers.find(it->first);
3700 TrackerWrapper *tracker = it_tracker->second;
3701 tracker->setTrackerType(it->second);
3717 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3719 TrackerWrapper *tracker = it->second;
3720 tracker->setUseEdgeTracking(name, useEdgeTracking);
3724 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 3736 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3738 TrackerWrapper *tracker = it->second;
3739 tracker->setUseKltTracking(name, useKltTracking);
3747 bool isOneTestTrackingOk =
false;
3748 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3750 TrackerWrapper *tracker = it->second;
3752 tracker->testTracking();
3753 isOneTestTrackingOk =
true;
3758 if (!isOneTestTrackingOk) {
3759 std::ostringstream oss;
3760 oss <<
"Not enough moving edges to track the object. Try to reduce the " 3778 std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
3781 std::map<std::string, const std::vector<vpColVector> *> mapOfPointClouds;
3782 std::map<std::string, unsigned int> mapOfWidths, mapOfHeights;
3784 track(mapOfImages, mapOfPointClouds, mapOfWidths, mapOfHeights);
3800 std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3801 std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
3802 mapOfImages[it->first] = &I1;
3805 mapOfImages[it->first] = &I2;
3807 std::map<std::string, const std::vector<vpColVector> *> mapOfPointClouds;
3808 std::map<std::string, unsigned int> mapOfWidths, mapOfHeights;
3810 track(mapOfImages, mapOfPointClouds, mapOfWidths, mapOfHeights);
3812 std::stringstream ss;
3813 ss <<
"Require two cameras! There are " <<
m_mapOfTrackers.size() <<
" cameras!";
3827 std::map<std::string, const std::vector<vpColVector> *> mapOfPointClouds;
3828 std::map<std::string, unsigned int> mapOfWidths, mapOfHeights;
3830 track(mapOfImages, mapOfPointClouds, mapOfWidths, mapOfHeights);
3833 #ifdef VISP_HAVE_PCL 3843 std::map<std::string, pcl::PointCloud<pcl::PointXYZ>::ConstPtr> &mapOfPointClouds)
3845 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3847 TrackerWrapper *tracker = it->second;
3850 #
if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
3858 #
if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
3862 mapOfImages[it->first] == NULL) {
3867 mapOfPointClouds[it->first] ==
nullptr) {
3883 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3885 TrackerWrapper *tracker = it->second;
3887 tracker->postTracking(mapOfImages[it->first], mapOfPointClouds[it->first]);
3905 std::map<std::string,
const std::vector<vpColVector> *> &mapOfPointClouds,
3906 std::map<std::string, unsigned int> &mapOfPointCloudWidths,
3907 std::map<std::string, unsigned int> &mapOfPointCloudHeights)
3909 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3911 TrackerWrapper *tracker = it->second;
3914 #
if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
3922 #
if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
3926 mapOfImages[it->first] == NULL) {
3931 (mapOfPointClouds[it->first] == NULL)) {
3936 preTracking(mapOfImages, mapOfPointClouds, mapOfPointCloudWidths, mapOfPointCloudHeights);
3947 for (std::map<std::string, TrackerWrapper *>::const_iterator it =
m_mapOfTrackers.begin();
3949 TrackerWrapper *tracker = it->second;
3951 tracker->postTracking(mapOfImages[it->first], mapOfPointCloudWidths[it->first], mapOfPointCloudHeights[it->first]);
3958 vpMbGenericTracker::TrackerWrapper::TrackerWrapper()
3964 #ifdef VISP_HAVE_OGRE 3969 vpMbGenericTracker::TrackerWrapper::TrackerWrapper(
const int trackerType)
3973 #
if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
3983 #ifdef VISP_HAVE_OGRE 3988 vpMbGenericTracker::TrackerWrapper::~TrackerWrapper() {}
4001 double normRes_1 = -1;
4002 unsigned int iter = 0;
4004 double factorEdge = 1.0;
4005 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4006 double factorKlt = 1.0;
4008 double factorDepth = 1.0;
4009 double factorDepthDense = 1.0;
4017 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4020 bool isoJoIdentity_ =
true;
4026 unsigned int nb_edge_features = m_error_edge.
getRows();
4027 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4028 unsigned int nb_klt_features = m_error_klt.getRows();
4030 unsigned int nb_depth_features = m_error_depthNormal.getRows();
4031 unsigned int nb_depth_dense_features = m_error_depthDense.getRows();
4036 bool reStartFromLastIncrement =
false;
4039 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4040 if (reStartFromLastIncrement) {
4047 if (!reStartFromLastIncrement) {
4052 if (!isoJoIdentity_) {
4055 LVJ_true = (
m_L * cVo *
oJo);
4061 isoJoIdentity_ =
true;
4068 if (isoJoIdentity_) {
4072 unsigned int rank = (
m_L * cVo).kernel(K);
4082 isoJoIdentity_ =
false;
4091 unsigned int start_index = 0;
4093 for (
unsigned int i = 0; i < nb_edge_features; i++) {
4094 double wi = m_w_edge[i] * m_factor[i] * factorEdge;
4101 for (
unsigned int j = 0; j <
m_L.
getCols(); j++) {
4106 start_index += nb_edge_features;
4109 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4111 for (
unsigned int i = 0; i < nb_klt_features; i++) {
4112 double wi = m_w_klt[i] * factorKlt;
4113 W_true[start_index + i] = wi;
4119 for (
unsigned int j = 0; j <
m_L.
getCols(); j++) {
4120 m_L[start_index + i][j] *= wi;
4124 start_index += nb_klt_features;
4129 for (
unsigned int i = 0; i < nb_depth_features; i++) {
4130 double wi = m_w_depthNormal[i] * factorDepth;
4131 m_w[start_index + i] = m_w_depthNormal[i];
4134 num += wi *
vpMath::sqr(m_error[start_index + i]);
4137 for (
unsigned int j = 0; j <
m_L.
getCols(); j++) {
4138 m_L[start_index + i][j] *= wi;
4142 start_index += nb_depth_features;
4146 for (
unsigned int i = 0; i < nb_depth_dense_features; i++) {
4147 double wi = m_w_depthDense[i] * factorDepthDense;
4148 m_w[start_index + i] = m_w_depthDense[i];
4151 num += wi *
vpMath::sqr(m_error[start_index + i]);
4154 for (
unsigned int j = 0; j <
m_L.
getCols(); j++) {
4155 m_L[start_index + i][j] *= wi;
4165 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4166 if (m_trackerType & KLT_TRACKER) {
4173 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4174 if (m_trackerType & KLT_TRACKER) {
4178 normRes_1 = normRes;
4180 normRes = sqrt(num / den);
4193 void vpMbGenericTracker::TrackerWrapper::computeVVSInit()
4196 "TrackerWrapper::computeVVSInit(" 4197 ") should not be called!");
4202 initMbtTracking(ptr_I);
4204 unsigned int nbFeatures = 0;
4207 nbFeatures += m_error_edge.getRows();
4209 m_error_edge.clear();
4210 m_weightedError_edge.clear();
4215 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4218 nbFeatures += m_error_klt.getRows();
4220 m_error_klt.clear();
4221 m_weightedError_klt.clear();
4229 nbFeatures += m_error_depthNormal.getRows();
4231 m_error_depthNormal.clear();
4232 m_weightedError_depthNormal.clear();
4233 m_L_depthNormal.clear();
4234 m_w_depthNormal.clear();
4239 nbFeatures += m_error_depthDense.getRows();
4241 m_error_depthDense.clear();
4242 m_weightedError_depthDense.clear();
4243 m_L_depthDense.clear();
4244 m_w_depthDense.clear();
4247 m_L.
resize(nbFeatures, 6,
false,
false);
4255 void vpMbGenericTracker::TrackerWrapper::computeVVSInteractionMatrixAndResidu()
4259 "computeVVSInteractionMatrixAndR" 4260 "esidu() should not be called!");
4263 void vpMbGenericTracker::TrackerWrapper::computeVVSInteractionMatrixAndResidu(
const vpImage<unsigned char> *
const ptr_I)
4269 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4283 unsigned int start_index = 0;
4284 if (m_trackerType & EDGE_TRACKER) {
4288 start_index += m_error_edge.getRows();
4291 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4292 if (m_trackerType & KLT_TRACKER) {
4296 start_index += m_error_klt.getRows();
4300 if (m_trackerType & DEPTH_NORMAL_TRACKER) {
4301 m_L.
insert(m_L_depthNormal, start_index, 0);
4304 start_index += m_error_depthNormal.getRows();
4307 if (m_trackerType & DEPTH_DENSE_TRACKER) {
4308 m_L.
insert(m_L_depthDense, start_index, 0);
4317 unsigned int start_index = 0;
4323 start_index += m_w_edge.getRows();
4326 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4331 start_index += m_w_klt.getRows();
4336 if (m_depthNormalUseRobust) {
4338 m_w.
insert(start_index, m_w_depthNormal);
4341 start_index += m_w_depthNormal.getRows();
4346 m_w.
insert(start_index, m_w_depthDense);
4354 const unsigned int thickness,
const bool displayFullModel)
4358 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4368 for (
unsigned int i = 0; i < scales.size(); i += 1) {
4370 for (std::list<vpMbtDistanceLine *>::const_iterator it = lines[scaleLevel].begin();
4371 it != lines[scaleLevel].end(); ++it) {
4372 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
4375 for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[scaleLevel].begin();
4376 it != cylinders[scaleLevel].end(); ++it) {
4377 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
4380 for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[scaleLevel].begin();
4381 it != circles[scaleLevel].end(); ++it) {
4382 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
4390 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4392 for (std::list<vpMbtDistanceKltPoints *>::const_iterator it = kltPolygons.begin(); it != kltPolygons.end();
4400 for (std::list<vpMbtDistanceKltCylinder *>::const_iterator it = kltCylinders.begin(); it != kltCylinders.end();
4417 #ifdef VISP_HAVE_OGRE 4426 const unsigned int thickness,
const bool displayFullModel)
4430 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4440 for (
unsigned int i = 0; i < scales.size(); i += 1) {
4442 for (std::list<vpMbtDistanceLine *>::const_iterator it = lines[scaleLevel].begin();
4443 it != lines[scaleLevel].end(); ++it) {
4444 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
4447 for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[scaleLevel].begin();
4448 it != cylinders[scaleLevel].end(); ++it) {
4449 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
4452 for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[scaleLevel].begin();
4453 it != circles[scaleLevel].end(); ++it) {
4454 (*it)->display(I, cMo_, camera, col, thickness, displayFullModel);
4462 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4464 for (std::list<vpMbtDistanceKltPoints *>::const_iterator it = kltPolygons.begin(); it != kltPolygons.end();
4472 for (std::list<vpMbtDistanceKltCylinder *>::const_iterator it = kltCylinders.begin(); it != kltCylinders.end();
4489 #ifdef VISP_HAVE_OGRE 4505 bool reInitialisation =
false;
4509 #ifdef VISP_HAVE_OGRE 4532 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4543 initMovingEdge(I,
cMo);
4553 void vpMbGenericTracker::TrackerWrapper::initCircle(
const vpPoint &p1,
const vpPoint &p2,
const vpPoint &p3,
4554 const double radius,
const int idFace,
const std::string &name)
4560 void vpMbGenericTracker::TrackerWrapper::initCylinder(
const vpPoint &p1,
const vpPoint &p2,
const double radius,
4561 const int idFace,
const std::string &name)
4566 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4572 void vpMbGenericTracker::TrackerWrapper::initFaceFromCorners(
vpMbtPolygon &polygon)
4577 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4589 void vpMbGenericTracker::TrackerWrapper::initFaceFromLines(
vpMbtPolygon &polygon)
4594 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4614 void vpMbGenericTracker::TrackerWrapper::loadConfigFile(
const std::string &configFile)
4616 #ifdef VISP_HAVE_XML2 4634 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4652 std::cout <<
" *********** Parsing XML for";
4654 std::vector<std::string> tracker_names;
4656 tracker_names.push_back(
"Edge");
4657 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4659 tracker_names.push_back(
"Klt");
4662 tracker_names.push_back(
"Depth Normal");
4664 tracker_names.push_back(
"Depth Dense");
4666 for (
size_t i = 0; i < tracker_names.size(); i++) {
4667 std::cout <<
" " << tracker_names[i];
4668 if (i == tracker_names.size() - 1) {
4673 std::cout <<
"Model-Based Tracker ************ " << std::endl;
4674 xmlp.
parse(configFile.c_str());
4714 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4738 std::cerr <<
"You need the libXML2 to read the config file: " << configFile << std::endl;
4742 #ifdef VISP_HAVE_PCL 4744 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud)
4752 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4763 bool newvisibleface =
false;
4781 if (m_trackerType & EDGE_TRACKER) {
4795 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud)
4801 std::cerr <<
"Error in moving edge tracking" << std::endl;
4806 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4811 std::cerr <<
"Error in KLT tracking: " << e.
what() << std::endl;
4821 std::cerr <<
"Error in Depth normal tracking" << std::endl;
4830 std::cerr <<
"Error in Depth dense tracking" << std::endl;
4838 const unsigned int pointcloud_width,
4839 const unsigned int pointcloud_height)
4847 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4858 bool newvisibleface =
false;
4876 if (m_trackerType & EDGE_TRACKER) {
4890 const std::vector<vpColVector> *
const point_cloud,
4891 const unsigned int pointcloud_width,
4892 const unsigned int pointcloud_height)
4898 std::cerr <<
"Error in moving edge tracking" << std::endl;
4903 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4908 std::cerr <<
"Error in KLT tracking: " << e.
what() << std::endl;
4918 std::cerr <<
"Error in Depth tracking" << std::endl;
4927 std::cerr <<
"Error in Depth dense tracking" << std::endl;
4933 void vpMbGenericTracker::TrackerWrapper::reInitModel(
const vpImage<unsigned char> &I,
const std::string &cad_name,
4943 for (
unsigned int i = 0; i < scales.size(); i++) {
4945 for (std::list<vpMbtDistanceLine *>::const_iterator it = lines[i].begin(); it != lines[i].end(); ++it) {
4952 for (std::list<vpMbtDistanceCylinder *>::const_iterator it = cylinders[i].begin(); it != cylinders[i].end();
4960 for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles[i].begin(); it != circles[i].end(); ++it) {
4968 cylinders[i].clear();
4976 nbvisiblepolygone = 0;
4979 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 4980 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 4982 cvReleaseImage(&cur);
4988 for (std::list<vpMbtDistanceKltPoints *>::const_iterator it = kltPolygons.begin(); it != kltPolygons.end(); ++it) {
4990 if (kltpoly != NULL) {
4995 kltPolygons.clear();
4997 for (std::list<vpMbtDistanceKltCylinder *>::const_iterator it = kltCylinders.begin(); it != kltCylinders.end();
5000 if (kltPolyCylinder != NULL) {
5001 delete kltPolyCylinder;
5003 kltPolyCylinder = NULL;
5005 kltCylinders.clear();
5008 for (std::list<vpMbtDistanceCircle *>::const_iterator it = circles_disp.begin(); it != circles_disp.end(); ++it) {
5015 circles_disp.clear();
5017 firstInitialisation =
true;
5022 for (
size_t i = 0; i < m_depthNormalFaces.size(); i++) {
5023 delete m_depthNormalFaces[i];
5024 m_depthNormalFaces[i] = NULL;
5026 m_depthNormalFaces.clear();
5029 for (
size_t i = 0; i < m_depthDenseNormalFaces.size(); i++) {
5030 delete m_depthDenseNormalFaces[i];
5031 m_depthDenseNormalFaces[i] = NULL;
5033 m_depthDenseNormalFaces.clear();
5041 void vpMbGenericTracker::TrackerWrapper::resetTracker()
5044 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 5051 void vpMbGenericTracker::TrackerWrapper::setCameraParameters(
const vpCameraParameters &camera)
5056 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 5065 void vpMbGenericTracker::TrackerWrapper::setFarClippingDistance(
const double &dist)
5070 void vpMbGenericTracker::TrackerWrapper::setNearClippingDistance(
const double &dist)
5075 void vpMbGenericTracker::TrackerWrapper::setOgreVisibilityTest(
const bool &v)
5078 #ifdef VISP_HAVE_OGRE 5085 bool performKltSetPose =
false;
5087 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 5089 performKltSetPose =
true;
5098 if (!performKltSetPose) {
5113 if (m_trackerType & EDGE_TRACKER) {
5114 initPyramid(I, Ipyramid);
5116 unsigned int i = (
unsigned int) scales.size();
5121 initMovingEdge(*Ipyramid[i],
cMo);
5126 cleanPyramid(Ipyramid);
5129 if (m_trackerType & EDGE_TRACKER)
5130 initMovingEdge(I,
cMo);
5140 void vpMbGenericTracker::TrackerWrapper::setProjectionErrorComputation(
const bool &flag)
5145 void vpMbGenericTracker::TrackerWrapper::setScanLineVisibilityTest(
const bool &v)
5148 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) 5155 void vpMbGenericTracker::TrackerWrapper::setTrackerType(
const int type)
5158 #
if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
5165 m_trackerType = type;
5168 void vpMbGenericTracker::TrackerWrapper::testTracking()
5176 #ifdef VISP_HAVE_PCL
5182 #
if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
5186 std::cerr <<
"Bad tracker type: " << m_trackerType << std::endl;
5190 #ifdef VISP_HAVE_PCL 5195 #ifdef VISP_HAVE_PCL 5197 const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud)
5200 #
if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
5204 std::cerr <<
"Bad tracker type: " << m_trackerType << std::endl;
5209 #
if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
5236 postTracking(ptr_I, point_cloud);
5239 std::cerr <<
"Exception: " << e.
what() << std::endl;
virtual void setDepthDenseFilteringOccupancyRatio(const double occupancyRatio)
virtual void setDisplayFeatures(const bool displayF)
virtual unsigned int getClipping() const
bool m_computeInteraction
void setWindowName(const Ogre::String &n)
unsigned int getDepthNormalSamplingStepY() const
virtual void setFeatureFactors(const std::map< vpTrackerType, double > &mapOfFeatureFactors)
virtual void setDisplayFeatures(const bool displayF)
virtual void initFaceFromLines(vpMbtPolygon &polygon)
virtual void loadModel(const std::string &modelFile, const bool verbose=false)
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
virtual void loadConfigFile(const std::string &configFile)
Implementation of a matrix and operations on matrices.
virtual void setKltThresholdAcceptation(const double th)
vpMatrix covarianceMatrix
Covariance matrix.
void displayPrimitive(const vpImage< unsigned char > &_I)
void setMovingEdge(const vpMe &me)
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
virtual void computeVVSWeights()
virtual void setScanLineVisibilityTest(const bool &v)
virtual void track(const vpImage< unsigned char > &I)
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")
virtual std::pair< std::vector< vpPolygon >, std::vector< std::vector< vpPoint > > > getPolygonFaces(const bool orderPolygons=true, const bool useVisibility=true, const bool clipPolygon=false)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual void getLline(const std::string &cameraName, std::list< vpMbtDistanceLine *> &linesList, const unsigned int level=0) const
vpColVector m_w
Robust weights.
bool hasFarClippingDistance() const
int getDepthNormalPclPlaneEstimationMethod() const
void setKltQuality(const double &q)
virtual void setAngleDisappear(const double &a)
bool hasEnoughPoints() const
bool hasEnoughPoints() const
void parse(const std::string &filename)
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
virtual std::list< vpMbtDistanceKltPoints * > & getFeaturesKlt()
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual void setReferenceCameraName(const std::string &referenceCameraName)
virtual std::map< std::string, int > getCameraTrackerTypes() const
void setKltPyramidLevels(const unsigned int &pL)
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
virtual void resetTracker()
void segmentPointCloud(const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &point_cloud)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
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.
void setBackgroundSizeOgre(const unsigned int &h, const unsigned int &w)
double getFarClippingDistance() const
virtual void initCylinder(const vpPoint &, const vpPoint &, const double, const int, const std::string &name="")
vpHomogeneousMatrix cMo
The current pose.
virtual void setClipping(const unsigned int &flags)
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w)
double getDepthNormalPclPlaneEstimationRansacThreshold() const
void setOgreShowConfigDialog(const bool showConfigDialog)
virtual void resetTracker()
virtual void setGoodNbRayCastingAttemptsRatio(const double &ratio)
virtual void setAngleDisappear(const double &a)
virtual void computeVVSInit()
error that can be emited by ViSP classes.
Manage a cylinder used in the model-based tracker.
vpMbScanLine & getMbScanLineRenderer()
unsigned int getRows() const
vpHomogeneousMatrix inverse() const
Manage the line of a polygon used in the model-based tracker.
virtual double getGoodMovingEdgesRatioThreshold() const
virtual void setDepthNormalFaceCentroidMethod(const vpMbtFaceDepthNormal::vpFaceCentroidType &method)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
virtual void computeVVSInteractionMatrixAndResidu()
bool useOgre
Use Ogre3d for visibility tests.
void getCameraParameters(vpCameraParameters &_cam) const
virtual void setDepthDenseFilteringMethod(const int method)
unsigned int getKltBlockSize() const
void setKltMaskBorder(const unsigned int &mb)
double getNearClippingDistance() const
virtual void setMovingEdge(const vpMe &me)
virtual void setCameraParameters(const vpCameraParameters &camera)
void displayFeaturesOnImage(const vpImage< unsigned char > &I, const unsigned int lvl)
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
virtual int getKltNbPoints() const
unsigned int setVisibleOgre(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed)
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
void updateMovingEdge(const vpImage< unsigned char > &I)
std::map< vpTrackerType, double > m_mapOfFeatureFactors
Ponderation between each feature type in the VVS stage.
std::map< std::string, TrackerWrapper * > m_mapOfTrackers
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages)
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
virtual void reinit(const vpImage< unsigned char > &I)
virtual void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
unsigned int getDepthDenseSamplingStepY() const
virtual void computeVVSInteractionMatrixAndResidu()
virtual void computeVVSInit()
double getAngleAppear() const
Implementation of a polygon of the model containing points of interest. It is used by the model-based...
virtual void setDepthDenseSamplingStep(const unsigned int stepX, const unsigned int stepY)
Class that defines what is a point.
virtual void getLcylinder(const std::string &cameraName, std::list< vpMbtDistanceCylinder *> &cylindersList, const unsigned int level=0) const
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)
virtual void setNearClippingDistance(const double &dist)
vpMatrix m_L
Interaction matrix.
unsigned int getCols() const
void setDepthNormalSamplingStepX(const unsigned int stepX)
Parse an Xml file to extract configuration parameters of a mbtConfig object.Data parser for the model...
void initOgre(const vpCameraParameters &cam=vpCameraParameters())
double distFarClip
Distance for near clipping.
vpAROgre * getOgreContext()
void setKltHarrisParam(const double &hp)
virtual vpHomogeneousMatrix getPose() const
void segmentPointCloud(const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &point_cloud)
void setDepthDenseSamplingStepX(const unsigned int stepX)
Manage a circle used in the model-based tracker.
void insert(const vpMatrix &A, const unsigned int r, const unsigned int c)
virtual void initFaceFromLines(vpMbtPolygon &polygon)
vpMatrix oJo
The Degrees of Freedom to estimate.
virtual void setKltMaskBorder(const unsigned int &e)
vpColVector m_weightedError
Weighted error.
virtual void initFromPose(const vpImage< unsigned char > &I1, const vpImage< unsigned char > &I2, const std::string &initFile1, const std::string &initFile2)
virtual void setDepthNormalPclPlaneEstimationMethod(const int method)
Error that can be emited by the vpTracker class and its derivates.
vp_deprecated void init()
virtual void setScanLineVisibilityTest(const bool &v)
Implementation of a polygon of the model used by the model-based tracker.
virtual void setCameraParameters(const vpCameraParameters &camera)
void setAngleDisappear(const double &adisappear)
void initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
virtual void setProjectionErrorComputation(const bool &flag)
void setEdgeMe(const vpMe &_ecm)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
virtual std::vector< cv::Point2f > getKltPoints() const
void displayPrimitive(const vpImage< unsigned char > &_I)
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
virtual std::list< vpMbtDistanceCircle * > & getFeaturesCircle()
bool useScanLine
Use Scanline for visibility tests.
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
void setKltMinDistance(const double &mD)
static double sqr(double x)
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
virtual void setUseKltTracking(const std::string &name, const bool &useKltTracking)
virtual unsigned int getNbPolygon() const
virtual vpMbtPolygon * getPolygon(const unsigned int index)
double getAngleDisappear() const
bool getFovClipping() const
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
Generic class defining intrinsic camera parameters.
virtual unsigned int getKltMaskBorder() const
unsigned int getKltWindowSize() const
virtual unsigned int getNbPoints(const unsigned int level=0) const
virtual std::list< vpMbtDistanceKltCylinder * > & getFeaturesKltCylinder()
unsigned int getKltMaxFeatures() const
Implementation of a polygon of the model containing points of interest. It is used by the model-based...
virtual void initClick(const vpImage< unsigned char > &I1, const vpImage< unsigned char > &I2, const std::string &initFile1, const std::string &initFile2, const bool displayHelp=false)
virtual void setAngleAppear(const double &a)
double getKltMinDistance() const
virtual double getKltThresholdAcceptation() const
virtual void getLcircle(const std::string &cameraName, std::list< vpMbtDistanceCircle *> &circlesList, const unsigned int level=0) const
virtual void computeVVSInteractionMatrixAndResidu()
double m_initialMu
Initial Mu for Levenberg Marquardt optimization loop.
double m_lambda
Gain of the virtual visual servoing stage.
virtual void computeVVSWeights(vpRobust &robust, const vpColVector &error, vpColVector &w)
virtual void setFarClippingDistance(const double &dist)
virtual void setAngleAppear(const double &a)
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
unsigned int getDepthNormalSamplingStepX() const
void setDepthNormalPclPlaneEstimationRansacMaxIter(const int maxIter)
double angleAppears
Angle used to detect a face appearance.
virtual bool isVisible(const vpHomogeneousMatrix &cMo, const double alpha, const bool &modulo=false, const vpCameraParameters &cam=vpCameraParameters(), const vpImage< unsigned char > &I=vpImage< unsigned char >())
void setKltWindowSize(const unsigned int &w)
void reinitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
unsigned int m_maxIter
Maximum number of iterations of the virtual visual servoing stage.
virtual void setDepthDenseFilteringMaxDistance(const double maxDistance)
virtual void setScanLineVisibilityTest(const bool &v)
virtual void computeVVSWeights()
void setAngleAppear(const double &aappear)
const char * what() const
static double rad(double deg)
virtual void testTracking()
virtual void computeVVSInteractionMatrixAndResidu()
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
void computeProjectionError(const vpImage< unsigned char > &_I)
void insert(unsigned int i, const vpColVector &v)
virtual void initFaceFromLines(vpMbtPolygon &polygon)
virtual void setNearClippingDistance(const double &dist)
virtual void computeVVSInit()
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void resetTracker()
void setDepthDenseSamplingStepY(const unsigned int stepY)
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")
virtual void setScanLineVisibilityTest(const bool &v)
virtual void initFaceFromCorners(vpMbtPolygon &polygon)
double m_stopCriteriaEpsilon
Epsilon threshold to stop the VVS optimization loop.
double minPolygonAreaThresholdGeneral
Minimum polygon area threshold for LOD mode (general setting)
static double deg(double rad)
void computeVisibility(const unsigned int width, const unsigned int height)
virtual void setOgreVisibilityTest(const bool &v)
bool displayFeatures
If true, the features are displayed.
unsigned int getHeight() const
virtual void initFromPoints(const vpImage< unsigned char > &I1, const vpImage< unsigned char > &I2, const std::string &initFile1, const std::string &initFile2)
void setCameraParameters(const vpCameraParameters &cam)
bool ogreShowConfigDialog
void preTracking(const vpImage< unsigned char > &I)
virtual ~vpMbGenericTracker()
vpColVector m_error
(s - s*)
bool hasNearClippingDistance() const
virtual void init(const vpImage< unsigned char > &I)
bool applyLodSettingInConfig
Implementation of column vector and the associated operations.
virtual void setOgreVisibilityTest(const bool &v)
std::string m_referenceCameraName
Name of the reference camera.
virtual void setFarClippingDistance(const double &dist)
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 preTracking(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages, std::map< std::string, pcl::PointCloud< pcl::PointXYZ >::ConstPtr > &mapOfPointClouds)
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)
double getLodMinLineLengthThreshold() const
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
virtual std::vector< std::string > getCameraNames() const
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
static vpHomogeneousMatrix direct(const vpColVector &v)
virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
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 updateMovingEdgeWeights()
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 void getCameraParameters(vpCameraParameters &cam1, vpCameraParameters &cam2) const
unsigned int getDepthDenseSamplingStepX() const
void visibleFace(const vpImage< unsigned char > &_I, const vpHomogeneousMatrix &_cMo, bool &newvisibleline)
virtual void computeVVSInit()
virtual void setDepthDenseFilteringMinDistance(const double minDistance)
virtual void initFaceFromLines(vpMbtPolygon &polygon)
vpMbtPolygon * polygon
Pointer to the polygon that define a face.
virtual void computeVVSInit()
int getDepthNormalPclPlaneEstimationRansacMaxIter() const
virtual void computeVVSInteractionMatrixAndResidu()
virtual std::map< int, vpImagePoint > getKltImagePointsWithId() const
virtual void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
virtual void setDepthNormalPclPlaneEstimationRansacMaxIter(const int maxIter)
unsigned int getKltMaskBorder() const
virtual void setTrackerType(const int type)
void setCameraParameters(const vpCameraParameters &_cam)
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setClipping(const unsigned int &flags)
double getKltQuality() const
void computeVisibility(const unsigned int width, const unsigned int height)
void getEdgeMe(vpMe &_ecm) const
void setDepthNormalFeatureEstimationMethod(const vpMbtFaceDepthNormal::vpFeatureEstimationType &method)
unsigned int clippingFlag
Flags specifying which clipping to used.
void trackMovingEdge(const vpImage< unsigned char > &I)
void displayOgre(const vpHomogeneousMatrix &cMo)
virtual void setClipping(const unsigned int &flags)
virtual void setKltOpencv(const vpKltOpencv &t)
virtual void setDepthNormalSamplingStep(const unsigned int stepX, const unsigned int stepY)
virtual vpKltOpencv getKltOpencv() const
virtual std::vector< vpImagePoint > getKltImagePoints() const
virtual void initFaceFromLines(vpMbtPolygon &polygon)
void setDepthNormalPclPlaneEstimationMethod(const int method)
virtual void setFarClippingDistance(const double &dist)
void setKltBlockSize(const unsigned int &bs)
void setDepthNormalPclPlaneEstimationRansacThreshold(const double threshold)
void setKltMaxFeatures(const unsigned int &mF)
double getKltHarrisParam() const
virtual void setCameraParameters(const vpCameraParameters &camera)
unsigned int getWidth() const
virtual void setDepthNormalPclPlaneEstimationRansacThreshold(const double thresold)
void computeVVSFirstPhaseFactor(const vpImage< unsigned char > &I, const unsigned int lvl=0)
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)
virtual void computeProjectionError()
void setDepthNormalSamplingStepY(const unsigned int stepY)
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 setCameraTransformationMatrix(const std::string &cameraName, const vpHomogeneousMatrix &cameraTransformationMatrix)
vpMbtFaceDepthNormal::vpFeatureEstimationType getDepthNormalFeatureEstimationMethod() const
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)
virtual vpMe getMovingEdge() const
virtual void setLod(const bool useLod, const std::string &name="")
double m_thresholdOutlier
double getLodMinPolygonAreaThreshold() const
virtual void setGoodMovingEdgesRatioThreshold(const double threshold)
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cdMo)
virtual void setCameraParameters(const vpCameraParameters &camera)
void resize(const unsigned int i, const bool flagNullify=true)
unsigned int getKltPyramidLevels() const
virtual void setProjectionErrorComputation(const bool &flag)
virtual void setNearClippingDistance(const double &dist)
void computeFov(const unsigned int &w, const unsigned int &h)