44 #include <visp3/core/vpDebug.h> 45 #include <visp3/core/vpExponentialMap.h> 46 #include <visp3/core/vpTrackingException.h> 47 #include <visp3/core/vpVelocityTwistMatrix.h> 48 #include <visp3/mbt/vpMbEdgeMultiTracker.h> 50 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) 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) {
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 bool displayFullModel)
513 it->second->display(I, cMo, cam, col, thickness, displayFullModel);
532 bool displayFullModel)
537 it->second->display(I, cMo, cam, col, thickness, displayFullModel);
561 unsigned int thickness,
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 unsigned int thickness,
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,
unsigned int thickness,
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,
unsigned int thickness,
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 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 unsigned int level)
const 890 it_edge->second->getLcylinder(cylindersList, level);
908 std::list<vpMbtDistanceCylinder *> &cylindersList,
909 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 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(
m_cMo);
1211 std::stringstream ss;
1260 it->second->initClick(I, initFile, displayHelp, T);
1261 it->second->getPose(
m_cMo);
1263 std::stringstream ss;
1306 const std::string &initFile1,
const std::string &initFile2,
bool displayHelp,
1307 bool firstCameraIsReference)
1310 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1311 it->second->initClick(I1, initFile1, displayHelp);
1313 if (firstCameraIsReference) {
1315 it->second->getPose(
m_cMo);
1318 it->second->getCameraParameters(
m_cam);
1323 it->second->initClick(I2, initFile2, displayHelp);
1325 if (!firstCameraIsReference) {
1327 it->second->getPose(
m_cMo);
1330 it->second->getCameraParameters(
m_cam);
1333 std::stringstream ss;
1334 ss <<
"Cannot init click ! Require two cameras but there are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
1369 const std::string &initFile,
bool displayHelp)
1373 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1376 if (it_img != mapOfImages.end()) {
1378 it_edge->second->initClick(*it_img->second, initFile, displayHelp);
1381 it_edge->second->getPose(
m_cMo);
1386 it_img = mapOfImages.find(it_edge->first);
1387 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1392 it_edge->second->setPose(*it_img->second, cCurrentMo);
1394 std::stringstream ss;
1401 std::stringstream ss;
1406 std::stringstream ss;
1442 const std::map<std::string, std::string> &mapOfInitFiles,
bool displayHelp)
1445 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1447 std::map<std::string, std::string>::const_iterator it_initFile = mapOfInitFiles.find(
m_referenceCameraName);
1449 if (it_edge !=
m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1451 it_edge->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1454 it_edge->second->getPose(
m_cMo);
1460 std::vector<std::string> vectorOfMissingCameraPoses;
1465 it_img = mapOfImages.find(it_edge->first);
1466 it_initFile = mapOfInitFiles.find(it_edge->first);
1468 if (it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1469 it_edge->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1471 vectorOfMissingCameraPoses.push_back(it_edge->first);
1477 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
1478 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
1479 it_img = mapOfImages.find(*it1);
1480 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1487 std::stringstream ss;
1488 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 1489 "set the pose for camera: " 1495 #endif //#ifdef VISP_HAVE_MODULE_GUI 1521 "This method can only be used for the monocular case !");
1524 char s[FILENAME_MAX];
1528 std::string ext =
".pos";
1529 size_t pos = initFile.rfind(ext);
1531 if (pos == initFile.size() - ext.size() && pos != 0)
1532 sprintf(s,
"%s", initFile.c_str());
1534 sprintf(s,
"%s.pos", initFile.c_str());
1536 finit.open(s, std::ios::in);
1538 std::cerr <<
"cannot read " << s << std::endl;
1542 for (
unsigned int i = 0; i < 6; i += 1) {
1543 finit >> init_pos[i];
1555 it_ref->second->m_cMo =
m_cMo;
1556 it_ref->second->
init(I);
1568 std::stringstream ss;
1569 ss <<
"This method requires exactly one camera, there are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
1581 it_ref->second->m_cMo =
m_cMo;
1582 it_ref->second->
init(I);
1609 bool firstCameraIsReference)
1638 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
1649 it != mapOfImages.end(); ++it) {
1650 pyramid[it->first].resize(
scales.size());
1706 it->second->loadConfigFile(configFile);
1707 it->second->getCameraParameters(
m_cam);
1710 this->
me = it->second->getMovingEdge();
1717 std::stringstream ss;
1737 bool firstCameraIsReference)
1740 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1741 it->second->loadConfigFile(configFile1);
1743 if (firstCameraIsReference) {
1744 it->second->getCameraParameters(
m_cam);
1747 this->
me = it->second->getMovingEdge();
1756 it->second->loadConfigFile(configFile2);
1758 if (!firstCameraIsReference) {
1759 it->second->getCameraParameters(
m_cam);
1762 this->
me = it->second->getMovingEdge();
1770 std::stringstream ss;
1771 ss <<
"Cannot loadConfigFile. Require two cameras ! There are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
1788 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
1790 std::map<std::string, std::string>::const_iterator it_config = mapOfConfigFiles.find(it_edge->first);
1791 if (it_config != mapOfConfigFiles.end()) {
1792 it_edge->second->loadConfigFile(it_config->second);
1794 std::stringstream ss;
1795 ss <<
"Missing configuration file for camera: " << it_edge->first <<
" !";
1803 it->second->getCameraParameters(
m_cam);
1806 this->
me = it->second->getMovingEdge();
1813 std::stringstream ss;
1849 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1851 it->second->loadModel(modelFile, verbose, T);
1874 std::stringstream ss;
1875 ss <<
"This method requires exactly one camera, there are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
1881 it_edge->second->reInitModel(I, cad_name, cMo, verbose, T);
1884 it_edge->second->getPose(
m_cMo);
1906 bool firstCameraIsReference)
1909 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
1911 it_edge->second->reInitModel(I1, cad_name, c1Mo, verbose);
1913 if (firstCameraIsReference) {
1915 it_edge->second->getPose(
m_cMo);
1920 it_edge->second->reInitModel(I2, cad_name, c2Mo, verbose);
1922 if (!firstCameraIsReference) {
1924 it_edge->second->getPose(
m_cMo);
1942 const std::string &cad_name,
1943 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
1947 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1949 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
1951 if (it_edge !=
m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1952 it_edge->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1956 it_edge->second->getPose(
m_cMo);
1961 std::vector<std::string> vectorOfMissingCameras;
1964 it_img = mapOfImages.find(it_edge->first);
1965 it_camPose = mapOfCameraPoses.find(it_edge->first);
1967 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1968 it_edge->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1970 vectorOfMissingCameras.push_back(it_edge->first);
1975 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameras.begin(); it != vectorOfMissingCameras.end();
1977 it_img = mapOfImages.find(*it);
1978 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1997 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1999 it->second->resetTracker();
2004 #ifdef VISP_HAVE_OGRE 2038 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2040 it->second->setAngleAppear(a);
2057 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2059 it->second->setAngleDisappear(a);
2077 it->second->setCameraParameters(cam);
2082 std::stringstream ss;
2098 bool firstCameraIsReference)
2103 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2104 it->second->setCameraParameters(camera1);
2107 it->second->setCameraParameters(camera2);
2109 if (firstCameraIsReference) {
2115 std::stringstream ss;
2129 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2131 it->second->setCameraParameters(cam);
2137 std::stringstream ss;
2138 ss <<
"The camera: " << cameraName <<
" does not exist !";
2150 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
2152 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_edge->first);
2153 if (it_cam != mapOfCameraParameters.end()) {
2154 it_edge->second->setCameraParameters(it_cam->second);
2157 m_cam = it_cam->second;
2160 std::stringstream ss;
2161 ss <<
"Missing camera parameters for camera: " << it_edge->first <<
" !";
2180 it->second = cameraTransformationMatrix;
2182 std::stringstream ss;
2183 ss <<
"Cannot find camera: " << cameraName <<
" !";
2196 const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix)
2199 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
2201 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2202 mapOfTransformationMatrix.find(it_edge->first);
2204 if (it_camTrans == mapOfTransformationMatrix.end()) {
2224 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2226 it->second->setClipping(flags);
2242 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2244 it->second->setClipping(flags);
2246 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2259 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2261 it->second->setCovarianceComputation(flag);
2283 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2285 it->second->setDisplayFeatures(displayF);
2300 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2302 it->second->setFarClippingDistance(dist);
2314 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2316 it->second->setFarClippingDistance(dist);
2318 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2337 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2339 it->second->setGoodMovingEdgesRatioThreshold(threshold);
2345 #ifdef VISP_HAVE_OGRE 2357 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2359 it->second->setGoodNbRayCastingAttemptsRatio(ratio);
2374 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2376 it->second->setNbRayCastingAttemptsForVisibility(attempts);
2394 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2396 it->second->setLod(useLod, name);
2414 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(cameraName);
2417 it_edge->second->setLod(useLod, name);
2419 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2434 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2436 it->second->setMinLineLengthThresh(minLineLengthThresh, name);
2452 const std::string &name)
2454 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(cameraName);
2457 it_edge->second->setMinLineLengthThresh(minLineLengthThresh, name);
2459 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2473 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2475 it->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2490 const std::string &name)
2492 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(cameraName);
2495 it_edge->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2497 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2508 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2510 it->second->setMovingEdge(moving_edge);
2522 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2524 it->second->setMovingEdge(moving_edge);
2526 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2539 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2541 it->second->setNearClippingDistance(dist);
2553 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2555 it->second->setNearClippingDistance(dist);
2557 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2573 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2575 it->second->setOgreShowConfigDialog(showConfigDialog);
2589 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2591 it->second->setOgreVisibilityTest(v);
2594 #ifdef VISP_HAVE_OGRE 2595 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2597 it->second->faces.getOgreContext()->setWindowName(
"Multi MBT Edge (" + it->first +
")");
2611 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2613 it->second->setOptimizationMethod(opt);
2631 it->second->setPose(I, cMo);
2634 std::stringstream ss;
2639 std::stringstream ss;
2640 ss <<
"You are trying to set the pose with only one image and cMo but " 2641 "there are multiple cameras !";
2659 it->second->setPose(
m_I, cMo);
2662 std::stringstream ss;
2667 std::stringstream ss;
2668 ss <<
"You are trying to set the pose with only one image and cMo but " 2669 "there are multiple cameras !";
2687 bool firstCameraIsReference)
2690 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2691 it->second->setPose(I1, c1Mo);
2695 it->second->setPose(I2, c2Mo);
2697 if (firstCameraIsReference) {
2703 std::stringstream ss;
2704 ss <<
"This method requires 2 cameras but there are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
2722 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2725 if (it_img != mapOfImages.end()) {
2727 it_edge->second->setPose(*it_img->second, cMo);
2735 it_img = mapOfImages.find(it_edge->first);
2736 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2741 it_edge->second->setPose(*it_img->second, cCurrentMo);
2748 std::stringstream ss;
2753 std::stringstream ss;
2770 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
2774 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2776 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
2778 if (it_edge !=
m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2779 it_edge->second->setPose(*it_img->second, it_camPose->second);
2780 it_edge->second->getPose(
m_cMo);
2786 std::vector<std::string> vectorOfMissingCameraPoses;
2791 it_img = mapOfImages.find(it_edge->first);
2792 it_camPose = mapOfCameraPoses.find(it_edge->first);
2794 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2796 it_edge->second->setPose(*it_img->second, it_camPose->second);
2798 vectorOfMissingCameraPoses.push_back(it_edge->first);
2803 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
2804 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
2805 it_img = mapOfImages.find(*it1);
2806 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2813 std::stringstream ss;
2814 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 2815 "set the pose for camera: " 2834 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2836 it->second->setProjectionErrorComputation(flag);
2847 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(referenceCameraName);
2851 std::stringstream ss;
2852 ss <<
"The reference camera: " << referenceCameraName <<
" does not exist !";
2881 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2883 it->second->setScales(scale);
2897 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2899 it->second->setScanLineVisibilityTest(v);
2912 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2914 it->second->setUseEdgeTracking(name, useEdgeTracking);
2932 it->second->track(I);
2933 it->second->getPose(
m_cMo);
2935 std::stringstream ss;
2952 std::cout <<
"Not supported interface, this class is deprecated." << std::endl;
2967 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2968 std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
2969 mapOfImages[it->first] = &I1;
2972 mapOfImages[it->first] = &I2;
2975 std::stringstream ss;
2991 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
2993 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.find(it_edge->first);
2995 if (it_img == mapOfImages.end()) {
3002 unsigned int lvl = (
unsigned int)
scales.size();
3012 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it1 =
m_mapOfEdgeTrackers.begin();
3015 it1->second->downScale(lvl);
3021 vpTRACE(
"Error in moving edge tracking");
3027 std::map<std::string, const vpImage<unsigned char> *> mapOfPyramidImages;
3031 mapOfPyramidImages[it->first] = it->second[lvl];
3041 bool isOneTestTrackingOk =
false;
3042 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3048 it->second->testTracking();
3049 isOneTestTrackingOk =
true;
3055 if (!isOneTestTrackingOk) {
3056 std::ostringstream oss;
3057 oss <<
"Not enough moving edges to track the object. Try to reduce " 3059 <<
percentageGdPt <<
" using setGoodMovingEdgesRatioThreshold()";
3064 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3066 it->second->m_featuresToBeDisplayedEdge = it->second->getFeaturesForDisplayEdge();
3071 bool newvisibleface =
false;
3072 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3074 it->second->visibleFace(*mapOfImages[it->first], it->second->m_cMo, newvisibleface);
3078 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3080 it->second->faces.computeClippedPolygons(it->second->m_cMo, it->second->m_cam);
3081 it->second->faces.computeScanLineRender(it->second->m_cam, mapOfImages[it->first]->getWidth(),
3082 mapOfImages[it->first]->getHeight());
3087 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3089 it->second->updateMovingEdge(*mapOfImages[it->first]);
3095 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3097 it->second->initMovingEdge(*mapOfImages[it->first], it->second->m_cMo);
3100 it->second->reinitMovingEdge(*mapOfImages[it->first], it->second->m_cMo);
3104 it->second->computeProjectionError(*mapOfImages[it->first]);
3111 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3113 it->second->upScale(lvl);
3121 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3123 it->second->m_cMo = cMo_1;
3124 it->second->reInitLevel(lvl);
3125 it->second->upScale(lvl);
3129 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3131 it->second->upScale(lvl);
3141 #elif !defined(VISP_BUILD_SHARED_LIBS) 3143 void dummy_vpMbEdgeMultiTracker(){}
3144 #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) void computeVVSFirstPhase(const vpImage< unsigned char > &I, unsigned int iter, double &count, unsigned int lvl=0)
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 setLod(bool useLod, const std::string &name="")
virtual void computeVVSInteractionMatrixAndResidu()
void getLline(std::list< vpMbtDistanceLine *> &linesList, unsigned int level=0) const
virtual void setFarClippingDistance(const double &dist)
vpCameraParameters m_cam
The camera parameters.
virtual void computeVVSWeights()
virtual void computeVVSInit()
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
virtual void computeVVSCheckLevenbergMarquardt(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_error_edge
(s - s*)
void upScale(const unsigned int _scale)
virtual void setAngleDisappear(const double &a)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
virtual void computeProjectionError()
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
virtual void setGoodMovingEdgesRatioThreshold(double threshold)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void getLcylinder(std::list< vpMbtDistanceCylinder *> &cylindersList, unsigned int level=0) const
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
Class to define colors available for display functionnalities.
vpColVector m_factor
Edge VVS variables.
virtual void track(const vpImage< unsigned char > &I)
virtual void setProjectionErrorComputation(const bool &flag)
virtual void loadConfigFile(const std::string &configFile)
virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name="")
vpColVector m_w_edgeMulti
Robust weights.
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 setMovingEdge(const vpMe &moving_edge)
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)
virtual void computeVVSWeights()
virtual void setDisplayFeatures(bool displayF)
void getLcircle(std::list< vpMbtDistanceCircle *> &circlesList, unsigned int level=0) const
virtual vpHomogeneousMatrix getPose() const
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
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 void setOgreShowConfigDialog(bool showConfigDialog)
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)
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
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 initPyramid(const std::map< std::string, const vpImage< unsigned char > *> &mapOfImages, std::map< std::string, std::vector< const vpImage< unsigned char > *> > &pyramid)
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)
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()
void insert(unsigned int i, const vpColVector &v)
virtual void setScales(const std::vector< bool > &scales)
virtual void computeVVSFirstPhasePoseEstimation(unsigned int iter, bool &isoJoIdentity_)
void setScales(const std::vector< bool > &_scales)
void resize(unsigned int i, bool flagNullify=true)
virtual void computeVVSPoseEstimation(const bool isoJoIdentity_, unsigned int iter, vpMatrix &L, vpMatrix <L, vpColVector &R, const vpColVector &error, vpColVector &error_prev, vpColVector <R, double &mu, vpColVector &v, const vpColVector *const w=NULL, vpColVector *const m_w_prev=NULL)
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.
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 ~vpMbEdgeMultiTracker()
unsigned int clippingFlag
Flags specifying which clipping to used.
vpMatrix m_L_edge
Interaction matrix.
void insert(const vpMatrix &A, unsigned int r, unsigned int c)
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > *> &_pyramid)
virtual void setFarClippingDistance(const double &dist)
virtual void setMinLineLengthThresh(double minLineLengthThresh, const std::string &name="")
virtual void getCameraParameters(vpCameraParameters &camera) const
vpImage< unsigned char > m_I
Grayscale image buffer, used when passing color images.
void computeJTR(const vpMatrix &J, const vpColVector &R, vpColVector &JTR) const
vpHomogeneousMatrix m_cMo
The current pose.
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
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)
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages, unsigned int lvl)
virtual unsigned int getNbPoints(unsigned int level=0) const
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)