46 #include <visp3/core/vpDebug.h> 47 #include <visp3/core/vpExponentialMap.h> 48 #include <visp3/core/vpTrackingException.h> 49 #include <visp3/core/vpVelocityTwistMatrix.h> 50 #include <visp3/mbt/vpMbEdgeMultiTracker.h> 56 : m_mapOfCameraTransformationMatrix(), m_mapOfEdgeTrackers(), m_mapOfPyramidalImages(),
57 m_referenceCameraName(
"Camera"), m_L_edgeMulti(), m_error_edgeMulti(), m_w_edgeMulti(), m_weightedError_edgeMulti()
77 }
else if (nbCameras == 1) {
82 }
else if (nbCameras == 2) {
93 for (
unsigned int i = 1; i <= nbCameras; i++) {
119 if (cameraNames.empty()) {
123 for (std::vector<std::string>::const_iterator it = cameraNames.begin(); it != cameraNames.end(); ++it) {
136 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
149 it1 != pyramid.end(); ++it1) {
150 if (it1->second.size() > 0) {
151 it1->second[0] = NULL;
152 for (
size_t i = 1; i < it1->second.size(); i++) {
153 if (it1->second[i] != NULL) {
154 delete it1->second[i];
155 it1->second[i] = NULL;
166 double rawTotalProjectionError = 0.0;
167 unsigned int nbTotalFeaturesUsed = 0;
168 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
170 double curProjError = it->second->getProjectionError();
171 unsigned int nbFeaturesUsed = it->second->nbFeaturesForProjErrorComputation;
173 if (nbFeaturesUsed > 0) {
174 nbTotalFeaturesUsed += nbFeaturesUsed;
175 rawTotalProjectionError += (
vpMath::rad(curProjError) * nbFeaturesUsed);
179 if (nbTotalFeaturesUsed > 0) {
190 const unsigned int lvl)
195 unsigned int iter = 0;
201 std::map<std::string, vpVelocityTwistMatrix> mapOfVelocityTwist;
206 mapOfVelocityTwist[it->first] = cVo;
215 while (reloop ==
true && iter < 10) {
216 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
224 unsigned int start_idx = 0;
225 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
227 double count_tmp = 0.0;
240 count = count / (double)nbrow;
256 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
273 double residu_1 = 1e3;
282 while (std::fabs((residu_1 - r) * 1e8) > std::numeric_limits<double>::epsilon() && (iter <
m_maxIter)) {
285 bool reStartFromLastIncrement =
false;
289 if (!reStartFromLastIncrement) {
297 if (!isoJoIdentity_) {
303 double wi = 0.0, eri = 0.0;
304 double num = 0.0, den = 0.0;
306 for (
unsigned int i = 0; i < nbrow; i++) {
315 for (
unsigned int j = 0; j < 6; j++) {
320 for (
unsigned int i = 0; i < nbrow; i++) {
348 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
361 for (
unsigned int i = 0; i < nerror; i++) {
367 for (
unsigned int j = 0; j < 6; j++) {
372 for (
unsigned int i = 0; i < nerror; i++) {
386 if (isoJoIdentity_) {
399 isoJoIdentity_ =
false;
407 if (isoJoIdentity_) {
417 v = -0.7 * LVJTLVJ.
pseudoInverse(LVJTLVJ.
getRows() * std::numeric_limits<double>::epsilon()) * LVJTR;
426 unsigned int nbrow = 0;
428 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
441 "No data found to compute the interaction matrix...");
455 "computeVVSInteractionMatrixAndR" 456 "esidu() should not be called!");
461 std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist)
463 unsigned int start_idx = 0;
465 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
481 unsigned int start_idx = 0;
483 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
508 const bool displayFullModel)
513 it->second->display(I, cMo_, cam_, col, thickness, displayFullModel);
532 const bool displayFullModel)
537 it->second->display(I, cMo_, cam_, col, thickness, displayFullModel);
561 const unsigned int thickness,
const bool displayFullModel)
566 it->second->display(I1, c1Mo, cam1, col, thickness, displayFullModel);
569 it->second->display(I2, c2Mo, cam2, col, thickness, displayFullModel);
571 std::cerr <<
"This display is only for the stereo case ! There are " <<
m_mapOfEdgeTrackers.size() <<
" camera !" 594 const unsigned int thickness,
const bool displayFullModel)
599 it->second->display(I1, c1Mo, cam1, col, thickness, displayFullModel);
602 it->second->display(I2, c2Mo, cam2, col, thickness, displayFullModel);
604 std::cerr <<
"This display is only for the stereo case ! There are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !" 622 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
623 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
624 const vpColor &col,
const unsigned int thickness,
const bool displayFullModel)
629 it_img != mapOfImages.end(); ++it_img) {
630 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(it_img->first);
631 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(it_img->first);
632 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_img->first);
635 it_cam != mapOfCameraParameters.end()) {
636 it_edge->second->display(*it_img->second, it_camPose->second, it_cam->second, col, thickness, displayFullModel);
638 std::cerr <<
"Missing elements !" << std::endl;
656 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
657 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
658 const vpColor &col,
const unsigned int thickness,
const bool displayFullModel)
662 for (std::map<std::string,
const vpImage<vpRGBa> *>::const_iterator it_img = mapOfImages.begin();
663 it_img != mapOfImages.end(); ++it_img) {
664 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(it_img->first);
665 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(it_img->first);
666 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_img->first);
669 it_cam != mapOfCameraParameters.end()) {
670 it_edge->second->display(*it_img->second, it_camPose->second, it_cam->second, col, thickness, displayFullModel);
672 std::cerr <<
"Missing elements !" << std::endl;
684 std::vector<std::string> cameraNames;
686 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
688 cameraNames.push_back(it_edge->first);
704 it->second->getCameraParameters(camera);
706 std::cerr <<
"The reference camera name: " <<
m_referenceCameraName <<
" does not exist !" << std::endl;
720 it->second->getCameraParameters(cam1);
723 it->second->getCameraParameters(cam2);
725 std::cerr <<
"Problem with the number of cameras ! There are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !" 738 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
740 it->second->getCameraParameters(camera);
742 std::cerr <<
"The camera: " << cameraName <<
" does not exist !" << std::endl;
754 mapOfCameraParameters.clear();
756 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
759 it->second->getCameraParameters(cam_);
760 mapOfCameraParameters[it->first] = cam_;
773 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
775 return it->second->getClipping();
777 std::cerr <<
"Cannot find camera: " << cameraName << std::endl;
792 return it->second->getFaces();
806 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
808 return it->second->getFaces();
811 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
822 std::map<std::string, vpMbHiddenFaces<vpMbtPolygon> > mapOfFaces;
823 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
825 mapOfFaces[it->first] = it->second->faces;
846 it_edge->second->getLcircle(circlesList, level);
864 const unsigned int level)
const 866 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
868 it->second->getLcircle(circlesList, level);
870 std::cerr <<
"The camera: " << cameraName <<
" does not exist !" << std::endl;
885 const unsigned int level)
const 890 it_edge->second->getLcylinder(cylindersList, level);
908 std::list<vpMbtDistanceCylinder *> &cylindersList,
909 const unsigned int level)
const 911 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
913 it->second->getLcylinder(cylindersList, level);
915 std::cerr <<
"The camera: " << cameraName <<
" does not exist !" << std::endl;
934 it_edge->second->getLline(linesList, level);
952 const unsigned int level)
const 954 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
956 it->second->getLline(linesList, level);
958 std::cerr <<
"The camera: " << cameraName <<
" does not exist !" << std::endl;
972 it_edge->second->getMovingEdge(p_me);
988 it_edge->second->getMovingEdge(me_tmp);
1005 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
1007 it->second->getMovingEdge(p_me);
1009 std::cerr <<
"The camera: " << cameraName <<
" does not exist !" << std::endl;
1043 unsigned int nbGoodPoints = 0;
1046 nbGoodPoints += it_edge->second->getNbPoints(level);
1051 return nbGoodPoints;
1069 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
1071 return it->second->getNbPoints(level);
1073 std::cerr <<
"The camera: " << cameraName <<
" does not exist !" << std::endl;
1088 return it->second->getNbPolygon();
1091 std::cerr <<
"The reference camera: " <<
m_referenceCameraName <<
" cannot be found !" << std::endl;
1103 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
1105 return it->second->getNbPolygon();
1108 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
1120 std::map<std::string, unsigned int> mapOfNbPolygons;
1121 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1123 mapOfNbPolygons[it->first] = it->second->getNbPolygon();
1126 return mapOfNbPolygons;
1138 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1139 it->second->getPose(c1Mo);
1142 it->second->getPose(c2Mo);
1144 std::cerr <<
"Require two cameras ! There are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !" << std::endl;
1158 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
1160 it->second->getPose(cMo_);
1162 std::cerr <<
"The camera: " << cameraName <<
" does not exist !" << std::endl;
1174 mapOfCameraPoses.clear();
1176 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1179 it->second->getPose(cMo_);
1180 mapOfCameraPoses[it->first] = cMo_;
1186 #ifdef VISP_HAVE_MODULE_GUI 1198 const std::string &displayFile)
1208 it->second->initClick(I, points3D_list, displayFile);
1209 it->second->getPose(
cMo);
1211 std::stringstream ss;
1248 const bool displayHelp)
1258 it->second->initClick(I, initFile, displayHelp);
1259 it->second->getPose(
cMo);
1261 std::stringstream ss;
1304 const std::string &initFile1,
const std::string &initFile2,
const bool displayHelp,
1305 const bool firstCameraIsReference)
1308 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1309 it->second->initClick(I1, initFile1, displayHelp);
1311 if (firstCameraIsReference) {
1313 it->second->getPose(
cMo);
1316 it->second->getCameraParameters(this->
cam);
1321 it->second->initClick(I2, initFile2, displayHelp);
1323 if (!firstCameraIsReference) {
1325 it->second->getPose(
cMo);
1328 it->second->getCameraParameters(this->
cam);
1331 std::stringstream ss;
1332 ss <<
"Cannot init click ! Require two cameras but there are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
1367 const std::string &initFile,
const bool displayHelp)
1371 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1374 if (it_img != mapOfImages.end()) {
1376 it_edge->second->initClick(*it_img->second, initFile, displayHelp);
1379 it_edge->second->getPose(
cMo);
1384 it_img = mapOfImages.find(it_edge->first);
1385 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1390 it_edge->second->setPose(*it_img->second, cCurrentMo);
1392 std::stringstream ss;
1399 std::stringstream ss;
1404 std::stringstream ss;
1440 const std::map<std::string, std::string> &mapOfInitFiles,
const bool displayHelp)
1443 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1445 std::map<std::string, std::string>::const_iterator it_initFile = mapOfInitFiles.find(
m_referenceCameraName);
1447 if (it_edge !=
m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1449 it_edge->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1452 it_edge->second->getPose(
cMo);
1458 std::vector<std::string> vectorOfMissingCameraPoses;
1463 it_img = mapOfImages.find(it_edge->first);
1464 it_initFile = mapOfInitFiles.find(it_edge->first);
1466 if (it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1467 it_edge->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1469 vectorOfMissingCameraPoses.push_back(it_edge->first);
1475 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
1476 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
1477 it_img = mapOfImages.find(*it1);
1478 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1485 std::stringstream ss;
1486 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 1487 "set the pose for camera: " 1493 #endif //#ifdef VISP_HAVE_MODULE_GUI 1519 "This method can only be used for the monocular case !");
1522 char s[FILENAME_MAX];
1526 std::string ext =
".pos";
1527 size_t pos = initFile.rfind(ext);
1529 if (pos == initFile.size() - ext.size() && pos != 0)
1530 sprintf(s,
"%s", initFile.c_str());
1532 sprintf(s,
"%s.pos", initFile.c_str());
1534 finit.open(s, std::ios::in);
1536 std::cerr <<
"cannot read " << s << std::endl;
1540 for (
unsigned int i = 0; i < 6; i += 1) {
1541 finit >> init_pos[i];
1553 it_ref->second->cMo =
cMo;
1554 it_ref->second->
init(I);
1566 std::stringstream ss;
1567 ss <<
"This method requires exactly one camera, there are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
1579 it_ref->second->cMo =
cMo;
1580 it_ref->second->
init(I);
1607 const bool firstCameraIsReference)
1636 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
1647 it != mapOfImages.end(); ++it) {
1648 pyramid[it->first].resize(
scales.size());
1709 it->second->loadConfigFile(configFile);
1710 it->second->getCameraParameters(
cam);
1713 this->
me = it->second->getMovingEdge();
1720 std::stringstream ss;
1743 const bool firstCameraIsReference)
1746 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1747 it->second->loadConfigFile(configFile1);
1749 if (firstCameraIsReference) {
1750 it->second->getCameraParameters(
cam);
1753 this->
me = it->second->getMovingEdge();
1762 it->second->loadConfigFile(configFile2);
1764 if (!firstCameraIsReference) {
1765 it->second->getCameraParameters(
cam);
1768 this->
me = it->second->getMovingEdge();
1776 std::stringstream ss;
1777 ss <<
"Cannot loadConfigFile. Require two cameras ! There are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
1797 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
1799 std::map<std::string, std::string>::const_iterator it_config = mapOfConfigFiles.find(it_edge->first);
1800 if (it_config != mapOfConfigFiles.end()) {
1801 it_edge->second->loadConfigFile(it_config->second);
1803 std::stringstream ss;
1804 ss <<
"Missing configuration file for camera: " << it_edge->first <<
" !";
1812 it->second->getCameraParameters(
cam);
1815 this->
me = it->second->getMovingEdge();
1822 std::stringstream ss;
1855 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1857 it->second->loadModel(modelFile, verbose);
1876 std::stringstream ss;
1877 ss <<
"This method requires exactly one camera, there are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
1883 it_edge->second->reInitModel(I, cad_name, cMo_, verbose);
1886 it_edge->second->getPose(
cMo);
1908 const bool firstCameraIsReference)
1911 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
1913 it_edge->second->reInitModel(I1, cad_name, c1Mo, verbose);
1915 if (firstCameraIsReference) {
1917 it_edge->second->getPose(
cMo);
1922 it_edge->second->reInitModel(I2, cad_name, c2Mo, verbose);
1924 if (!firstCameraIsReference) {
1926 it_edge->second->getPose(
cMo);
1944 const std::string &cad_name,
1945 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
1949 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1951 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
1953 if (it_edge !=
m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1954 it_edge->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1958 it_edge->second->getPose(
cMo);
1963 std::vector<std::string> vectorOfMissingCameras;
1966 it_img = mapOfImages.find(it_edge->first);
1967 it_camPose = mapOfCameraPoses.find(it_edge->first);
1969 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1970 it_edge->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1972 vectorOfMissingCameras.push_back(it_edge->first);
1977 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameras.begin(); it != vectorOfMissingCameras.end();
1979 it_img = mapOfImages.find(*it);
1980 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1999 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2001 it->second->resetTracker();
2006 #ifdef VISP_HAVE_OGRE 2040 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2042 it->second->setAngleAppear(a);
2059 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2061 it->second->setAngleDisappear(a);
2079 it->second->setCameraParameters(camera);
2084 std::stringstream ss;
2100 const bool firstCameraIsReference)
2105 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2106 it->second->setCameraParameters(camera1);
2109 it->second->setCameraParameters(camera2);
2111 if (firstCameraIsReference) {
2112 this->
cam = camera1;
2114 this->
cam = camera2;
2117 std::stringstream ss;
2131 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2133 it->second->setCameraParameters(camera);
2139 std::stringstream ss;
2140 ss <<
"The camera: " << cameraName <<
" does not exist !";
2152 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
2154 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_edge->first);
2155 if (it_cam != mapOfCameraParameters.end()) {
2156 it_edge->second->setCameraParameters(it_cam->second);
2159 this->
cam = it_cam->second;
2162 std::stringstream ss;
2163 ss <<
"Missing camera parameters for camera: " << it_edge->first <<
" !";
2182 it->second = cameraTransformationMatrix;
2184 std::stringstream ss;
2185 ss <<
"Cannot find camera: " << cameraName <<
" !";
2198 const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix)
2201 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
2203 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2204 mapOfTransformationMatrix.find(it_edge->first);
2206 if (it_camTrans == mapOfTransformationMatrix.end()) {
2226 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2228 it->second->setClipping(flags);
2244 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2246 it->second->setClipping(flags);
2248 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2261 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2263 it->second->setCovarianceComputation(flag);
2285 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2287 it->second->setDisplayFeatures(displayF);
2302 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2304 it->second->setFarClippingDistance(dist);
2316 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2318 it->second->setFarClippingDistance(dist);
2320 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2339 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2341 it->second->setGoodMovingEdgesRatioThreshold(threshold);
2347 #ifdef VISP_HAVE_OGRE 2359 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2361 it->second->setGoodNbRayCastingAttemptsRatio(ratio);
2376 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2378 it->second->setNbRayCastingAttemptsForVisibility(attempts);
2396 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2398 it->second->setLod(useLod, name);
2416 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(cameraName);
2419 it_edge->second->setLod(useLod, name);
2421 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2436 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2438 it->second->setMinLineLengthThresh(minLineLengthThresh, name);
2454 const std::string &name)
2456 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(cameraName);
2459 it_edge->second->setMinLineLengthThresh(minLineLengthThresh, name);
2461 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2475 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2477 it->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2492 const std::string &name)
2494 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(cameraName);
2497 it_edge->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2499 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2510 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2512 it->second->setMovingEdge(me);
2524 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2526 it->second->setMovingEdge(me);
2528 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2541 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2543 it->second->setNearClippingDistance(dist);
2555 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2557 it->second->setNearClippingDistance(dist);
2559 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2575 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2577 it->second->setOgreShowConfigDialog(showConfigDialog);
2591 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2593 it->second->setOgreVisibilityTest(v);
2596 #ifdef VISP_HAVE_OGRE 2597 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2599 it->second->faces.getOgreContext()->setWindowName(
"Multi MBT Edge (" + it->first +
")");
2613 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2615 it->second->setOptimizationMethod(opt);
2633 it->second->setPose(I, cMo_);
2636 std::stringstream ss;
2641 std::stringstream ss;
2642 ss <<
"You are trying to set the pose with only one image and cMo but " 2643 "there are multiple cameras !";
2661 const bool firstCameraIsReference)
2664 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2665 it->second->setPose(I1, c1Mo);
2669 it->second->setPose(I2, c2Mo);
2671 if (firstCameraIsReference) {
2677 std::stringstream ss;
2678 ss <<
"This method requires 2 cameras but there are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
2696 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2699 if (it_img != mapOfImages.end()) {
2701 it_edge->second->setPose(*it_img->second, cMo_);
2709 it_img = mapOfImages.find(it_edge->first);
2710 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2715 it_edge->second->setPose(*it_img->second, cCurrentMo);
2722 std::stringstream ss;
2727 std::stringstream ss;
2744 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
2748 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2750 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
2752 if (it_edge !=
m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2753 it_edge->second->setPose(*it_img->second, it_camPose->second);
2754 it_edge->second->getPose(
cMo);
2760 std::vector<std::string> vectorOfMissingCameraPoses;
2765 it_img = mapOfImages.find(it_edge->first);
2766 it_camPose = mapOfCameraPoses.find(it_edge->first);
2768 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2770 it_edge->second->setPose(*it_img->second, it_camPose->second);
2772 vectorOfMissingCameraPoses.push_back(it_edge->first);
2777 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
2778 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
2779 it_img = mapOfImages.find(*it1);
2780 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2787 std::stringstream ss;
2788 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 2789 "set the pose for camera: " 2808 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2810 it->second->setProjectionErrorComputation(flag);
2821 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(referenceCameraName);
2825 std::stringstream ss;
2826 ss <<
"The reference camera: " << referenceCameraName <<
" does not exist !";
2855 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2857 it->second->setScales(scale);
2871 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2873 it->second->setScanLineVisibilityTest(v);
2886 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2888 it->second->setUseEdgeTracking(name, useEdgeTracking);
2906 it->second->track(I);
2907 it->second->getPose(
cMo);
2909 std::stringstream ss;
2933 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2934 std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
2935 mapOfImages[it->first] = &I1;
2938 mapOfImages[it->first] = &I2;
2941 std::stringstream ss;
2957 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
2959 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.find(it_edge->first);
2961 if (it_img == mapOfImages.end()) {
2968 unsigned int lvl = (
unsigned int)
scales.size();
2978 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it1 =
m_mapOfEdgeTrackers.begin();
2981 it1->second->downScale(lvl);
2987 vpTRACE(
"Error in moving edge tracking");
2993 std::map<std::string, const vpImage<unsigned char> *> mapOfPyramidImages;
2997 mapOfPyramidImages[it->first] = it->second[lvl];
3007 bool isOneTestTrackingOk =
false;
3008 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3014 it->second->testTracking();
3015 isOneTestTrackingOk =
true;
3021 if (!isOneTestTrackingOk) {
3022 std::ostringstream oss;
3023 oss <<
"Not enough moving edges to track the object. Try to reduce " 3025 <<
percentageGdPt <<
" using setGoodMovingEdgesRatioThreshold()";
3030 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3032 it->second->displayFeaturesOnImage(*mapOfImages[it->first], lvl);
3037 bool newvisibleface =
false;
3038 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3040 it->second->visibleFace(*mapOfImages[it->first], it->second->cMo, newvisibleface);
3044 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3046 it->second->faces.computeClippedPolygons(it->second->cMo, it->second->cam);
3047 it->second->faces.computeScanLineRender(it->second->cam, mapOfImages[it->first]->getWidth(),
3048 mapOfImages[it->first]->getHeight());
3053 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3055 it->second->updateMovingEdge(*mapOfImages[it->first]);
3061 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3063 it->second->initMovingEdge(*mapOfImages[it->first], it->second->cMo);
3066 it->second->reinitMovingEdge(*mapOfImages[it->first], it->second->cMo);
3070 it->second->computeProjectionError(*mapOfImages[it->first]);
3077 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3079 it->second->upScale(lvl);
3087 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3089 it->second->cMo = cMo_1;
3090 it->second->reInitLevel(lvl);
3091 it->second->upScale(lvl);
3095 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3097 it->second->upScale(lvl);
virtual unsigned int getClipping() const
bool m_computeInteraction
std::string m_referenceCameraName
Name of the reference camera.
virtual void setCovarianceComputation(const bool &flag)
Implementation of a matrix and operations on matrices.
virtual void setUseEdgeTracking(const std::string &name, const bool &useEdgeTracking)
vpMatrix pseudoInverse(double svThreshold=1e-6) const
vpMatrix covarianceMatrix
Covariance matrix.
virtual void loadModel(const std::string &modelFile, const bool verbose=false)
virtual void computeVVSInteractionMatrixAndResidu()
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
virtual void setFarClippingDistance(const double &dist)
virtual void computeVVSWeights()
virtual void computeVVSInit()
virtual void setLod(const bool useLod, const std::string &name="")
vpColVector m_error_edge
(s - s*)
void upScale(const unsigned int _scale)
virtual void setAngleDisappear(const double &a)
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
virtual void computeProjectionError()
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
virtual void setDisplayFeatures(const bool displayF)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void getLline(std::list< vpMbtDistanceLine *> &linesList, const unsigned int level=0) const
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
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.
vpColVector m_factor
Edge VVS variables.
virtual void track(const vpImage< unsigned char > &I)
vpHomogeneousMatrix cMo
The current pose.
virtual void setProjectionErrorComputation(const bool &flag)
virtual void loadConfigFile(const std::string &configFile)
vpColVector m_w_edgeMulti
Robust weights.
virtual void computeVVSFirstPhasePoseEstimation(const unsigned int iter, bool &isoJoIdentity_)
vpColVector m_w_edge
Robust weights.
error that can be emited by ViSP classes.
void reInitLevel(const unsigned int _lvl)
virtual void setClipping(const unsigned int &flags)
unsigned int getRows() const
vpHomogeneousMatrix inverse() const
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
Make the complete tracking of an object by using its CAD model.
bool useOgre
Use Ogre3d for visibility tests.
vpColVector m_error_edgeMulti
(s - s*)
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
vpMe me
The moving edges parameters.
virtual void setReferenceCameraName(const std::string &referenceCameraName)
virtual std::map< std::string, unsigned int > getMultiNbPolygon() const
virtual void setNearClippingDistance(const double &dist)
void downScale(const unsigned int _scale)
vpCameraParameters cam
The camera parameters.
virtual void computeVVSWeights()
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 vpHomogeneousMatrix getPose() const
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
void insert(const vpMatrix &A, const unsigned int r, const unsigned int c)
vpMatrix oJo
The Degrees of Freedom to estimate.
std::vector< bool > scales
Vector of scale level to use for the multi-scale tracking.
virtual void initClick(const vpImage< unsigned char > &I, const std::vector< vpPoint > &points3D_list, const std::string &displayFile="")
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
vpMatrix m_L_edgeMulti
Interaction matrix.
Error that can be emited by the vpTracker class and its derivates.
void init(const vpImage< unsigned char > &I)
vp_deprecated void init()
virtual vpMe getMovingEdge() const
virtual void setOgreVisibilityTest(const bool &v)
bool useScanLine
Use Scanline for visibility tests.
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static double sqr(double x)
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
virtual void setCameraParameters(const vpCameraParameters &camera)
unsigned int nbFeaturesForProjErrorComputation
Number of features used in the computation of the projection error.
Generic class defining intrinsic camera parameters.
virtual void setCameraTransformationMatrix(const std::string &cameraName, const vpHomogeneousMatrix &cameraTransformationMatrix)
void getLcylinder(std::list< vpMbtDistanceCylinder *> &cylindersList, 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 setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
virtual void initPyramid(const std::map< std::string, const vpImage< unsigned char > *> &mapOfImages, std::map< std::string, std::vector< const vpImage< unsigned char > *> > &pyramid)
void getLcircle(std::list< vpMbtDistanceCircle *> &circlesList, const unsigned int level=0) const
virtual void setAngleAppear(const double &a)
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
std::map< std::string, vpMbEdgeTracker * > m_mapOfEdgeTrackers
Map of Model-based edge trackers.
double angleAppears
Angle used to detect a face appearance.
virtual void setCovarianceComputation(const bool &flag)
virtual unsigned int getNbPoints(const unsigned int level=0) const
unsigned int m_maxIter
Maximum number of iterations of the virtual visual servoing stage.
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static double rad(double deg)
virtual void resetTracker()
virtual void setMovingEdge(const vpMe &me)
void insert(unsigned int i, const vpColVector &v)
virtual void setScales(const std::vector< bool > &scales)
void setScales(const std::vector< bool > &_scales)
static double deg(double rad)
bool displayFeatures
If true, the features are displayed.
Implementation of column vector and the associated operations.
std::map< std::string, std::vector< const vpImage< unsigned char > * > > m_mapOfPyramidalImages
Map of pyramidal images for each camera.
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)
Implementation of a pose vector and operations on poses.
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
static vpHomogeneousMatrix direct(const vpColVector &v)
virtual void computeCovarianceMatrixVVS(const bool isoJoIdentity_, const vpColVector &w_true, const vpHomogeneousMatrix &cMoPrev, const vpMatrix &L_true, const vpMatrix &LVJ_true, const vpColVector &error)
void updateMovingEdgeWeights()
double angleDisappears
Angle used to detect a face disappearance.
virtual void computeVVSInit()
virtual unsigned int getNbPolygon() const
virtual void setScanLineVisibilityTest(const bool &v)
virtual void setClipping(const unsigned int &flags)
virtual void setAngleDisappear(const double &a)
virtual void setGoodMovingEdgesRatioThreshold(const double threshold)
virtual ~vpMbEdgeMultiTracker()
unsigned int clippingFlag
Flags specifying which clipping to used.
vpMatrix m_L_edge
Interaction matrix.
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > *> &_pyramid)
virtual void setFarClippingDistance(const double &dist)
void computeVVSFirstPhase(const vpImage< unsigned char > &I, const unsigned int iter, double &count, const unsigned int lvl=0)
virtual void getCameraParameters(vpCameraParameters &camera) const
void computeJTR(const vpMatrix &J, const vpColVector &R, vpColVector &JTR) const
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages, const unsigned int lvl)
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
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)
vpColVector m_weightedError_edgeMulti
Weighted error.
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
virtual std::vector< std::string > getCameraNames() const
virtual void setAngleAppear(const double &a)
void resize(const unsigned int i, const bool flagNullify=true)
virtual void cleanPyramid(std::map< std::string, std::vector< const vpImage< unsigned char > *> > &pyramid)
virtual void setProjectionErrorComputation(const bool &flag)
virtual void setNearClippingDistance(const double &dist)