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) {
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;
1260 it->second->initClick(I, initFile, displayHelp, T);
1261 it->second->getPose(
cMo);
1263 std::stringstream ss;
1306 const std::string &initFile1,
const std::string &initFile2,
const bool displayHelp,
1307 const 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(
cMo);
1318 it->second->getCameraParameters(this->
cam);
1323 it->second->initClick(I2, initFile2, displayHelp);
1325 if (!firstCameraIsReference) {
1327 it->second->getPose(
cMo);
1330 it->second->getCameraParameters(this->
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,
const 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(
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,
const 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(
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->cMo =
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->cMo =
cMo;
1582 it_ref->second->
init(I);
1609 const bool firstCameraIsReference)
1638 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
1649 it != mapOfImages.end(); ++it) {
1650 pyramid[it->first].resize(
scales.size());
1711 it->second->loadConfigFile(configFile);
1712 it->second->getCameraParameters(
cam);
1715 this->
me = it->second->getMovingEdge();
1722 std::stringstream ss;
1745 const bool firstCameraIsReference)
1748 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1749 it->second->loadConfigFile(configFile1);
1751 if (firstCameraIsReference) {
1752 it->second->getCameraParameters(
cam);
1755 this->
me = it->second->getMovingEdge();
1764 it->second->loadConfigFile(configFile2);
1766 if (!firstCameraIsReference) {
1767 it->second->getCameraParameters(
cam);
1770 this->
me = it->second->getMovingEdge();
1778 std::stringstream ss;
1779 ss <<
"Cannot loadConfigFile. Require two cameras ! There are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
1799 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
1801 std::map<std::string, std::string>::const_iterator it_config = mapOfConfigFiles.find(it_edge->first);
1802 if (it_config != mapOfConfigFiles.end()) {
1803 it_edge->second->loadConfigFile(it_config->second);
1805 std::stringstream ss;
1806 ss <<
"Missing configuration file for camera: " << it_edge->first <<
" !";
1814 it->second->getCameraParameters(
cam);
1817 this->
me = it->second->getMovingEdge();
1824 std::stringstream ss;
1860 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
1862 it->second->loadModel(modelFile, verbose, T);
1885 std::stringstream ss;
1886 ss <<
"This method requires exactly one camera, there are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
1892 it_edge->second->reInitModel(I, cad_name, cMo_, verbose, T);
1895 it_edge->second->getPose(
cMo);
1917 const bool firstCameraIsReference)
1920 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
1922 it_edge->second->reInitModel(I1, cad_name, c1Mo, verbose);
1924 if (firstCameraIsReference) {
1926 it_edge->second->getPose(
cMo);
1931 it_edge->second->reInitModel(I2, cad_name, c2Mo, verbose);
1933 if (!firstCameraIsReference) {
1935 it_edge->second->getPose(
cMo);
1953 const std::string &cad_name,
1954 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
1958 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1960 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
1962 if (it_edge !=
m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1963 it_edge->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1967 it_edge->second->getPose(
cMo);
1972 std::vector<std::string> vectorOfMissingCameras;
1975 it_img = mapOfImages.find(it_edge->first);
1976 it_camPose = mapOfCameraPoses.find(it_edge->first);
1978 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1979 it_edge->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1981 vectorOfMissingCameras.push_back(it_edge->first);
1986 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameras.begin(); it != vectorOfMissingCameras.end();
1988 it_img = mapOfImages.find(*it);
1989 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2008 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2010 it->second->resetTracker();
2015 #ifdef VISP_HAVE_OGRE 2049 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2051 it->second->setAngleAppear(a);
2068 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2070 it->second->setAngleDisappear(a);
2088 it->second->setCameraParameters(camera);
2093 std::stringstream ss;
2109 const bool firstCameraIsReference)
2114 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2115 it->second->setCameraParameters(camera1);
2118 it->second->setCameraParameters(camera2);
2120 if (firstCameraIsReference) {
2121 this->
cam = camera1;
2123 this->
cam = camera2;
2126 std::stringstream ss;
2140 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2142 it->second->setCameraParameters(camera);
2148 std::stringstream ss;
2149 ss <<
"The camera: " << cameraName <<
" does not exist !";
2161 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
2163 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_edge->first);
2164 if (it_cam != mapOfCameraParameters.end()) {
2165 it_edge->second->setCameraParameters(it_cam->second);
2168 this->
cam = it_cam->second;
2171 std::stringstream ss;
2172 ss <<
"Missing camera parameters for camera: " << it_edge->first <<
" !";
2191 it->second = cameraTransformationMatrix;
2193 std::stringstream ss;
2194 ss <<
"Cannot find camera: " << cameraName <<
" !";
2207 const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix)
2210 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
2212 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2213 mapOfTransformationMatrix.find(it_edge->first);
2215 if (it_camTrans == mapOfTransformationMatrix.end()) {
2235 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2237 it->second->setClipping(flags);
2253 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2255 it->second->setClipping(flags);
2257 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2270 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2272 it->second->setCovarianceComputation(flag);
2294 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2296 it->second->setDisplayFeatures(displayF);
2311 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2313 it->second->setFarClippingDistance(dist);
2325 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2327 it->second->setFarClippingDistance(dist);
2329 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2348 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2350 it->second->setGoodMovingEdgesRatioThreshold(threshold);
2356 #ifdef VISP_HAVE_OGRE 2368 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2370 it->second->setGoodNbRayCastingAttemptsRatio(ratio);
2385 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2387 it->second->setNbRayCastingAttemptsForVisibility(attempts);
2405 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2407 it->second->setLod(useLod, name);
2425 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(cameraName);
2428 it_edge->second->setLod(useLod, name);
2430 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2445 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2447 it->second->setMinLineLengthThresh(minLineLengthThresh, name);
2463 const std::string &name)
2465 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(cameraName);
2468 it_edge->second->setMinLineLengthThresh(minLineLengthThresh, name);
2470 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2484 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2486 it->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2501 const std::string &name)
2503 std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.find(cameraName);
2506 it_edge->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2508 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2519 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2521 it->second->setMovingEdge(me);
2533 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2535 it->second->setMovingEdge(me);
2537 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2550 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2552 it->second->setNearClippingDistance(dist);
2564 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(cameraName);
2566 it->second->setNearClippingDistance(dist);
2568 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2584 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2586 it->second->setOgreShowConfigDialog(showConfigDialog);
2600 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2602 it->second->setOgreVisibilityTest(v);
2605 #ifdef VISP_HAVE_OGRE 2606 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2608 it->second->faces.getOgreContext()->setWindowName(
"Multi MBT Edge (" + it->first +
")");
2622 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2624 it->second->setOptimizationMethod(opt);
2642 it->second->setPose(I, cMo_);
2645 std::stringstream ss;
2650 std::stringstream ss;
2651 ss <<
"You are trying to set the pose with only one image and cMo but " 2652 "there are multiple cameras !";
2670 const bool firstCameraIsReference)
2673 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2674 it->second->setPose(I1, c1Mo);
2678 it->second->setPose(I2, c2Mo);
2680 if (firstCameraIsReference) {
2686 std::stringstream ss;
2687 ss <<
"This method requires 2 cameras but there are " <<
m_mapOfEdgeTrackers.size() <<
" cameras !";
2705 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2708 if (it_img != mapOfImages.end()) {
2710 it_edge->second->setPose(*it_img->second, cMo_);
2718 it_img = mapOfImages.find(it_edge->first);
2719 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2724 it_edge->second->setPose(*it_img->second, cCurrentMo);
2731 std::stringstream ss;
2736 std::stringstream ss;
2753 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
2757 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2759 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
2761 if (it_edge !=
m_mapOfEdgeTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2762 it_edge->second->setPose(*it_img->second, it_camPose->second);
2763 it_edge->second->getPose(
cMo);
2769 std::vector<std::string> vectorOfMissingCameraPoses;
2774 it_img = mapOfImages.find(it_edge->first);
2775 it_camPose = mapOfCameraPoses.find(it_edge->first);
2777 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2779 it_edge->second->setPose(*it_img->second, it_camPose->second);
2781 vectorOfMissingCameraPoses.push_back(it_edge->first);
2786 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
2787 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
2788 it_img = mapOfImages.find(*it1);
2789 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2796 std::stringstream ss;
2797 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 2798 "set the pose for camera: " 2817 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2819 it->second->setProjectionErrorComputation(flag);
2830 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.find(referenceCameraName);
2834 std::stringstream ss;
2835 ss <<
"The reference camera: " << referenceCameraName <<
" does not exist !";
2864 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2866 it->second->setScales(scale);
2880 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2882 it->second->setScanLineVisibilityTest(v);
2895 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2897 it->second->setUseEdgeTracking(name, useEdgeTracking);
2915 it->second->track(I);
2916 it->second->getPose(
cMo);
2918 std::stringstream ss;
2942 std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
2943 std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
2944 mapOfImages[it->first] = &I1;
2947 mapOfImages[it->first] = &I2;
2950 std::stringstream ss;
2966 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it_edge =
m_mapOfEdgeTrackers.begin();
2968 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.find(it_edge->first);
2970 if (it_img == mapOfImages.end()) {
2977 unsigned int lvl = (
unsigned int)
scales.size();
2987 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it1 =
m_mapOfEdgeTrackers.begin();
2990 it1->second->downScale(lvl);
2996 vpTRACE(
"Error in moving edge tracking");
3002 std::map<std::string, const vpImage<unsigned char> *> mapOfPyramidImages;
3006 mapOfPyramidImages[it->first] = it->second[lvl];
3016 bool isOneTestTrackingOk =
false;
3017 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3023 it->second->testTracking();
3024 isOneTestTrackingOk =
true;
3030 if (!isOneTestTrackingOk) {
3031 std::ostringstream oss;
3032 oss <<
"Not enough moving edges to track the object. Try to reduce " 3034 <<
percentageGdPt <<
" using setGoodMovingEdgesRatioThreshold()";
3039 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3041 it->second->displayFeaturesOnImage(*mapOfImages[it->first], lvl);
3046 bool newvisibleface =
false;
3047 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3049 it->second->visibleFace(*mapOfImages[it->first], it->second->cMo, newvisibleface);
3053 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3055 it->second->faces.computeClippedPolygons(it->second->cMo, it->second->cam);
3056 it->second->faces.computeScanLineRender(it->second->cam, mapOfImages[it->first]->getWidth(),
3057 mapOfImages[it->first]->getHeight());
3062 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3064 it->second->updateMovingEdge(*mapOfImages[it->first]);
3070 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3072 it->second->initMovingEdge(*mapOfImages[it->first], it->second->cMo);
3075 it->second->reinitMovingEdge(*mapOfImages[it->first], it->second->cMo);
3079 it->second->computeProjectionError(*mapOfImages[it->first]);
3086 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3088 it->second->upScale(lvl);
3096 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3098 it->second->cMo = cMo_1;
3099 it->second->reInitLevel(lvl);
3100 it->second->upScale(lvl);
3104 for (std::map<std::string, vpMbEdgeTracker *>::const_iterator it =
m_mapOfEdgeTrackers.begin();
3106 it->second->upScale(lvl);
3116 #elif !defined(VISP_BUILD_SHARED_LIBS) 3118 void dummy_vpMbEdgeMultiTracker(){}
3119 #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) 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 covarianceMatrix
Covariance matrix.
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*)
virtual void loadModel(const std::string &modelFile, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
void upScale(const unsigned int _scale)
virtual unsigned int getClipping() const
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.
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)
virtual std::map< std::string, unsigned int > getMultiNbPolygon() const
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_)
virtual void cleanPyramid(std::map< std::string, std::vector< const vpImage< unsigned char > * > > &pyramid)
vpColVector m_w_edge
Robust weights.
error that can be emited by ViSP classes.
void reInitLevel(const unsigned int _lvl)
virtual vpMe getMovingEdge() const
virtual void setClipping(const unsigned int &flags)
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 unsigned int getNbPolygon() const
virtual void setReferenceCameraName(const std::string &referenceCameraName)
virtual void setNearClippingDistance(const double &dist)
void downScale(const unsigned int _scale)
vpCameraParameters cam
The camera parameters.
virtual void computeVVSWeights()
void computeJTR(const vpMatrix &J, const vpColVector &R, vpColVector &JTR) const
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)
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 vpHomogeneousMatrix getPose() const
virtual void setOgreVisibilityTest(const bool &v)
bool useScanLine
Use Scanline for visibility tests.
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
virtual void computeVVS(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages, const unsigned int lvl)
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.
void getLcircle(std::list< vpMbtDistanceCircle * > &circlesList, const unsigned int level=0) const
Generic class defining intrinsic camera parameters.
virtual void setCameraTransformationMatrix(const std::string &cameraName, const vpHomogeneousMatrix &cameraTransformationMatrix)
void initPyramid(const vpImage< unsigned char > &_I, std::vector< const vpImage< unsigned char > * > &_pyramid)
virtual void computeVVSInteractionMatrixAndResidu()
double m_initialMu
Initial Mu for Levenberg Marquardt optimization loop.
void getLline(std::list< vpMbtDistanceLine * > &linesList, const unsigned int level=0) const
double m_lambda
Gain of the virtual visual servoing stage.
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
virtual void setAngleAppear(const double &a)
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
unsigned int getRows() const
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()
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.
virtual void getCameraParameters(vpCameraParameters &camera) const
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.
vpHomogeneousMatrix inverse() const
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.
void getLcylinder(std::list< vpMbtDistanceCylinder * > &cylindersList, const unsigned int level=0) const
virtual void computeVVSInit()
virtual std::vector< std::string > getCameraNames() const
virtual unsigned int getNbPoints(const unsigned int level=0) const
virtual void setScanLineVisibilityTest(const bool &v)
vpMatrix pseudoInverse(double svThreshold=1e-6) const
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.
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 reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
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 void setAngleAppear(const double &a)
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 resize(const unsigned int i, const bool flagNullify=true)
virtual void setProjectionErrorComputation(const bool &flag)
virtual void setNearClippingDistance(const double &dist)