46 #include <visp3/core/vpConfig.h> 48 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100) 50 #include <visp3/core/vpTrackingException.h> 51 #include <visp3/core/vpVelocityTwistMatrix.h> 52 #include <visp3/mbt/vpMbKltMultiTracker.h> 58 : m_mapOfCameraTransformationMatrix(), m_mapOfKltTrackers(), m_referenceCameraName(
"Camera"), m_L_kltMulti(),
59 m_error_kltMulti(), m_w_kltMulti(), m_weightedError_kltMulti()
79 }
else if (nbCameras == 1) {
84 }
else if (nbCameras == 2) {
95 for (
unsigned int i = 1; i <= nbCameras; i++) {
118 if (cameraNames.empty()) {
122 for (std::vector<std::string>::const_iterator it = cameraNames.begin(); it != cameraNames.end(); ++it) {
135 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
150 const std::string &name)
152 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
154 it->second->addCircle(P1, P2, P3, r, name);
172 double normRes_1 = -1;
173 unsigned int iter = 0;
176 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
182 std::map<std::string, vpVelocityTwistMatrix> mapOfVelocityTwist;
187 mapOfVelocityTwist[it->first] = cVo;
190 while (((
int)((normRes - normRes_1) * 1e8) != 0) && (iter <
m_maxIter)) {
193 bool reStartFromLastIncrement =
false;
195 if (reStartFromLastIncrement) {
199 if (!reStartFromLastIncrement) {
221 for (
unsigned int j = 0; j < 6; j++) {
228 error_prev, LTR, mu, v);
255 "computeVVSInteractionMatrixAndR" 256 "esidu() should not be called!");
260 std::map<std::string, vpVelocityTwistMatrix> &mapOfVelocityTwist)
262 unsigned int startIdx = 0;
264 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
277 klt->
ctTc0 = c_curr_tTc_curr0;
290 unsigned int startIdx = 0;
291 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
314 const bool displayFullModel)
318 it->second->display(I, cMo_, cam_, col, thickness, displayFullModel);
337 const bool displayFullModel)
341 it->second->display(I, cMo_, cam_, color, thickness, displayFullModel);
364 const unsigned int thickness,
const bool displayFullModel)
367 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
368 it->second->display(I1, c1Mo, cam1, color, thickness, displayFullModel);
371 it->second->display(I2, c2Mo, cam2, color, thickness, displayFullModel);
373 std::cerr <<
"This display is only for the stereo case ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !" 395 const bool displayFullModel)
398 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
399 it->second->display(I1, c1Mo, cam1, color, thickness, displayFullModel);
402 it->second->display(I2, c2Mo, cam2, color, thickness, displayFullModel);
404 std::cerr <<
"This display is only for the stereo case ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !" 421 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
422 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
423 const vpColor &col,
const unsigned int thickness,
const bool displayFullModel)
428 it_img != mapOfImages.end(); ++it_img) {
429 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(it_img->first);
430 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(it_img->first);
431 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_img->first);
434 it_cam != mapOfCameraParameters.end()) {
435 it_klt->second->display(*it_img->second, it_camPose->second, it_cam->second, col, thickness, displayFullModel);
437 std::cerr <<
"Missing elements ! " << std::endl;
454 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
455 const std::map<std::string, vpCameraParameters> &mapOfCameraParameters,
456 const vpColor &col,
const unsigned int thickness,
const bool displayFullModel)
460 for (std::map<std::string,
const vpImage<vpRGBa> *>::const_iterator it_img = mapOfImages.begin();
461 it_img != mapOfImages.end(); ++it_img) {
462 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(it_img->first);
463 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(it_img->first);
464 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_img->first);
467 it_cam != mapOfCameraParameters.end()) {
468 it_klt->second->display(*it_img->second, it_camPose->second, it_cam->second, col, thickness, displayFullModel);
470 std::cerr <<
"Missing elements ! " << std::endl;
482 std::vector<std::string> cameraNames;
484 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
486 cameraNames.push_back(it_klt->first);
502 it->second->getCameraParameters(camera);
504 std::cerr <<
"The reference camera name: " <<
m_referenceCameraName <<
" does not exist !" << std::endl;
517 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
518 it->second->getCameraParameters(cam1);
521 it->second->getCameraParameters(cam2);
523 std::cerr <<
"Problem with the number of cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !" 536 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
538 it->second->getCameraParameters(camera);
540 std::cerr <<
"The camera: " << cameraName <<
" does not exist !" << std::endl;
552 mapOfCameraParameters.clear();
554 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
557 it->second->getCameraParameters(cam_);
558 mapOfCameraParameters[it->first] = cam_;
571 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
573 return it->second->getClipping();
575 std::cerr <<
"Cannot find camera: " << cameraName << std::endl;
590 return it->second->getFaces();
604 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
606 return it->second->getFaces();
609 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
620 std::map<std::string, vpMbHiddenFaces<vpMbtPolygon> > mapOfFaces;
621 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
623 mapOfFaces[it->first] = it->second->faces;
639 return it_klt->second->getFeaturesCircle();
655 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
658 return it->second->getFeaturesCircle();
660 std::cerr <<
"The camera: " << cameraName <<
" does not exist !";
677 return it_klt->second->getFeaturesKlt();
694 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
697 return it->second->getFeaturesKlt();
699 std::cerr <<
"The camera: " << cameraName <<
" does not exist !";
715 return it_klt->second->getFeaturesKltCylinder();
731 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
734 return it->second->getFeaturesKltCylinder();
736 std::cerr <<
"The camera: " << cameraName <<
" does not exist !";
752 std::map<std::string, std::vector<vpImagePoint> > mapOfFeatures;
754 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
756 mapOfFeatures[it->first] = it->second->getKltImagePoints();
759 return mapOfFeatures;
773 std::map<std::string, std::map<int, vpImagePoint> > mapOfFeatures;
775 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
777 mapOfFeatures[it->first] = it->second->getKltImagePointsWithId();
780 return mapOfFeatures;
790 std::map<std::string, vpKltOpencv> mapOfKltOpenCVTracker;
792 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
794 mapOfKltOpenCVTracker[it->first] = it->second->getKltOpencv();
797 return mapOfKltOpenCVTracker;
805 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408) 808 std::map<std::string, std::vector<cv::Point2f> > mapOfFeatures;
810 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
812 mapOfFeatures[it->first] = it->second->getKltPoints();
815 return mapOfFeatures;
820 std::map<std::string, CvPoint2D32f *> mapOfFeatures;
822 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
824 mapOfFeatures[it->first] = it->second->getKltPoints();
827 return mapOfFeatures;
838 std::map<std::string, int> mapOfFeatures;
840 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
842 mapOfFeatures[it->first] = it->second->getKltNbPoints();
845 return mapOfFeatures;
857 return it->second->getNbPolygon();
872 std::map<std::string, unsigned int> mapOfNbPolygons;
873 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
875 mapOfNbPolygons[it->first] = it->second->getNbPolygon();
878 return mapOfNbPolygons;
890 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
891 it->second->getPose(c1Mo);
894 it->second->getPose(c2Mo);
896 std::cerr <<
"Require two cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !" << std::endl;
910 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
912 it->second->getPose(cMo_);
914 std::cerr <<
"The camera: " << cameraName <<
" does not exist !" << std::endl;
926 mapOfCameraPoses.clear();
928 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
931 it->second->getPose(cMo_);
932 mapOfCameraPoses[it->first] = cMo_;
938 #ifdef VISP_HAVE_MODULE_GUI 950 const std::string &displayFile)
960 it->second->initClick(I, points3D_list, displayFile);
961 it->second->getPose(
cMo);
967 std::stringstream ss;
1003 const bool displayHelp)
1013 it->second->initClick(I, initFile, displayHelp);
1014 it->second->getPose(
cMo);
1020 std::stringstream ss;
1065 const std::string &initFile1,
const std::string &initFile2,
const bool displayHelp,
1066 const bool firstCameraIsReference)
1069 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1070 it->second->initClick(I1, initFile1, displayHelp);
1072 if (firstCameraIsReference) {
1074 it->second->getPose(
cMo);
1077 it->second->getCameraParameters(this->
cam);
1086 it->second->initClick(I2, initFile2, displayHelp);
1088 if (!firstCameraIsReference) {
1090 it->second->getPose(
cMo);
1093 it->second->getCameraParameters(this->
cam);
1100 std::stringstream ss;
1101 ss <<
"Cannot init click ! Require two cameras but there are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
1136 const std::string &initFile,
const bool displayHelp)
1140 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1143 if (it_img != mapOfImages.end()) {
1144 it_klt->second->initClick(*it_img->second, initFile, displayHelp);
1147 it_klt->second->getPose(
cMo);
1156 it_img = mapOfImages.find(it_klt->first);
1157 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1162 it_klt->second->cMo = cCurrentMo;
1163 it_klt->second->
init(*it_img->second);
1165 std::stringstream ss;
1172 std::stringstream ss;
1177 std::stringstream ss;
1213 const std::map<std::string, std::string> &mapOfInitFiles,
const bool displayHelp)
1216 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1218 std::map<std::string, std::string>::const_iterator it_initFile = mapOfInitFiles.find(
m_referenceCameraName);
1220 if (it_klt !=
m_mapOfKltTrackers.end() && it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1221 it_klt->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1222 it_klt->second->getPose(
cMo);
1231 std::vector<std::string> vectorOfMissingCameraPoses;
1236 it_img = mapOfImages.find(it_klt->first);
1237 it_initFile = mapOfInitFiles.find(it_klt->first);
1239 if (it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1241 it_klt->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1243 vectorOfMissingCameraPoses.push_back(it_klt->first);
1249 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
1250 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
1251 it_img = mapOfImages.find(*it1);
1252 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1260 std::stringstream ss;
1261 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 1262 "set the pose for camera: " 1268 #endif //#ifdef VISP_HAVE_MODULE_GUI 1295 char s[FILENAME_MAX];
1299 std::string ext =
".pos";
1300 size_t pos = initFile.rfind(ext);
1302 if (pos == initFile.size() - ext.size() && pos != 0)
1303 sprintf(s,
"%s", initFile.c_str());
1305 sprintf(s,
"%s.pos", initFile.c_str());
1307 finit.open(s, std::ios::in);
1309 std::cerr <<
"cannot read " << s << std::endl;
1313 for (
unsigned int i = 0; i < 6; i += 1) {
1314 finit >> init_pos[i];
1328 it_ref->second->initFromPose(I,
cMo);
1349 it_ref->second->initFromPose(I,
cMo);
1376 const bool firstCameraIsReference)
1379 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1380 it->second->initFromPose(I1, c1Mo);
1384 it->second->initFromPose(I2, c2Mo);
1386 if (firstCameraIsReference) {
1395 std::stringstream ss;
1396 ss <<
"This method requires 2 cameras but there are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
1414 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.find(it_klt->first);
1416 if (it_img != mapOfImages.end()) {
1417 it_klt->second->initFromPose(*it_img->second, cMo_);
1425 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1427 it_img = mapOfImages.find(it_klt->first);
1431 it_klt->second->initFromPose(*it_img->second, cCurrentMo);
1434 "Cannot find camera transformation matrix or image !");
1442 std::stringstream ss;
1455 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
1459 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1461 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
1463 if (it_klt !=
m_mapOfKltTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1464 it_klt->second->initFromPose(*it_img->second, it_camPose->second);
1465 it_klt->second->getPose(
cMo);
1474 std::vector<std::string> vectorOfMissingCameraPoses;
1478 it_img = mapOfImages.find(it_klt->first);
1479 it_camPose = mapOfCameraPoses.find(it_klt->first);
1481 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1483 it_klt->second->initFromPose(*it_img->second, it_camPose->second);
1485 vectorOfMissingCameraPoses.push_back(it_klt->first);
1489 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
1490 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
1491 it_img = mapOfImages.find(*it1);
1492 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1499 std::stringstream ss;
1500 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 1501 "set the pose for camera: " 1560 it->second->loadConfigFile(configFile);
1561 it->second->getCameraParameters(
cam);
1568 std::stringstream ss;
1591 const bool firstCameraIsReference)
1594 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1595 it->second->loadConfigFile(configFile1);
1597 if (firstCameraIsReference) {
1598 it->second->getCameraParameters(
cam);
1607 it->second->loadConfigFile(configFile2);
1609 if (!firstCameraIsReference) {
1610 it->second->getCameraParameters(
cam);
1618 std::stringstream ss;
1619 ss <<
"Cannot loadConfigFile. Require two cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
1639 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
1641 std::map<std::string, std::string>::const_iterator it_config = mapOfConfigFiles.find(it_klt->first);
1642 if (it_config != mapOfConfigFiles.end()) {
1643 it_klt->second->loadConfigFile(it_config->second);
1645 std::stringstream ss;
1646 ss <<
"Missing configuration file for camera: " << it_klt->first <<
" !";
1654 it->second->getCameraParameters(
cam);
1661 std::stringstream ss;
1694 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1696 it->second->loadModel(modelFile, verbose);
1707 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1723 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1731 klt->
reinit(*mapOfImages[it->first]);
1763 std::stringstream ss;
1764 ss <<
"This method requires exactly one camera, there are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
1773 it_klt->second->reInitModel(I, cad_name, cMo_, verbose);
1776 it_klt->second->getPose(
cMo);
1801 const bool firstCameraIsReference)
1804 std::map<std::string, vpMbKltTracker *>::const_iterator it_edge =
m_mapOfKltTrackers.begin();
1806 it_edge->second->reInitModel(I1, cad_name, c1Mo, verbose);
1808 if (firstCameraIsReference) {
1810 it_edge->second->getPose(
cMo);
1815 it_edge->second->reInitModel(I2, cad_name, c2Mo, verbose);
1817 if (!firstCameraIsReference) {
1819 it_edge->second->getPose(
cMo);
1840 const std::string &cad_name,
1841 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
1845 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1847 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
1849 if (it_klt !=
m_mapOfKltTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1850 it_klt->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1854 it_klt->second->getPose(
cMo);
1862 std::vector<std::string> vectorOfMissingCameras;
1865 it_img = mapOfImages.find(it_klt->first);
1866 it_camPose = mapOfCameraPoses.find(it_klt->first);
1868 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1869 it_klt->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1871 vectorOfMissingCameras.push_back(it_klt->first);
1876 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameras.begin(); it != vectorOfMissingCameras.end();
1878 it_img = mapOfImages.find(*it);
1879 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1884 m_mapOfKltTrackers[*it]->reInitModel(*it_img->second, cad_name, cCurrentMo, verbose);
1899 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1901 it->second->resetTracker();
1924 #ifdef VISP_HAVE_OGRE 1942 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1944 it->second->setAngleAppear(a);
1961 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1963 it->second->setAngleDisappear(a);
1981 it->second->setCameraParameters(camera);
1986 std::stringstream ss;
2002 const bool firstCameraIsReference)
2007 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2008 it->second->setCameraParameters(camera1);
2011 it->second->setCameraParameters(camera2);
2013 if (firstCameraIsReference) {
2014 this->
cam = camera1;
2016 this->
cam = camera2;
2019 std::stringstream ss;
2020 ss <<
"Require two cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
2033 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2035 it->second->setCameraParameters(camera);
2041 std::stringstream ss;
2042 ss <<
"The camera: " << cameraName <<
" does not exist !";
2054 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2056 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_klt->first);
2057 if (it_cam != mapOfCameraParameters.end()) {
2058 it_klt->second->setCameraParameters(it_cam->second);
2061 this->
cam = it_cam->second;
2064 std::stringstream ss;
2065 ss <<
"Missing camera parameters for camera: " << it_klt->first <<
" !";
2084 it->second = cameraTransformationMatrix;
2086 std::stringstream ss;
2087 ss <<
"Cannot find camera: " << cameraName <<
" !";
2100 const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix)
2103 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2105 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2106 mapOfTransformationMatrix.find(it_klt->first);
2108 if (it_camTrans == mapOfTransformationMatrix.end()) {
2127 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2129 it->second->setClipping(flags);
2143 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2145 it->second->setClipping(flags);
2147 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2160 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2162 it->second->setCovarianceComputation(flag);
2173 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2175 it->second->setDisplayFeatures(displayF);
2190 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2192 it->second->setFarClippingDistance(dist);
2204 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2206 it->second->setFarClippingDistance(dist);
2208 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2212 #ifdef VISP_HAVE_OGRE 2224 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2226 it->second->setGoodNbRayCastingAttemptsRatio(ratio);
2241 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2243 it->second->setNbRayCastingAttemptsForVisibility(attempts);
2255 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2257 it_klt->second->setKltOpencv(t);
2268 for (std::map<std::string, vpKltOpencv>::const_iterator it_kltOpenCV = mapOfOpenCVTrackers.begin();
2269 it_kltOpenCV != mapOfOpenCVTrackers.end(); ++it_kltOpenCV) {
2270 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(it_kltOpenCV->first);
2272 it_klt->second->setKltOpencv(it_kltOpenCV->second);
2274 std::cerr <<
"The camera: " << it_kltOpenCV->first <<
" does not exist !" << std::endl;
2292 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2294 it->second->setLod(useLod, name);
2312 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(cameraName);
2315 it_klt->second->setLod(useLod, name);
2317 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2328 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2330 it->second->setKltMaskBorder(e);
2341 std::cerr <<
"Useless for KLT tracker !" << std::endl;
2354 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2356 it->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2371 const std::string &name)
2373 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(cameraName);
2376 it_klt->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2378 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2391 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2393 it->second->setNearClippingDistance(dist);
2409 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2411 it->second->setOgreShowConfigDialog(showConfigDialog);
2425 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2427 it->second->setOgreVisibilityTest(v);
2430 #ifdef VISP_HAVE_OGRE 2431 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2433 it->second->faces.getOgreContext()->setWindowName(
"Multi MBT Klt (" + it->first +
")");
2448 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2450 it->second->setNearClippingDistance(dist);
2452 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2463 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2465 it->second->setOptimizationMethod(opt);
2483 it->second->setPose(I, cMo_);
2489 std::stringstream ss;
2494 std::stringstream ss;
2495 ss <<
"You are trying to set the pose with only one image and cMo " 2496 "but there are multiple cameras !";
2514 const bool firstCameraIsReference)
2517 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2518 it->second->setPose(I1, c1Mo);
2522 it->second->setPose(I2, c2Mo);
2524 if (firstCameraIsReference) {
2533 std::stringstream ss;
2534 ss <<
"This method requires 2 cameras but there are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
2552 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2555 if (it_img != mapOfImages.end()) {
2557 it_klt->second->setPose(*it_img->second, cMo_);
2568 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2570 it_img = mapOfImages.find(it_klt->first);
2574 it_klt->second->setPose(*it_img->second, cCurrentMo);
2581 std::stringstream ss;
2586 std::stringstream ss;
2603 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
2607 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2609 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
2611 if (it_klt !=
m_mapOfKltTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2612 it_klt->second->setPose(*it_img->second, it_camPose->second);
2613 it_klt->second->getPose(
cMo);
2622 std::vector<std::string> vectorOfMissingCameraPoses;
2627 it_img = mapOfImages.find(it_klt->first);
2628 it_camPose = mapOfCameraPoses.find(it_klt->first);
2630 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2632 it_klt->second->setPose(*it_img->second, it_camPose->second);
2634 vectorOfMissingCameraPoses.push_back(it_klt->first);
2639 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
2640 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
2641 it_img = mapOfImages.find(*it1);
2642 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2649 std::stringstream ss;
2650 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 2651 "set the pose for camera: " 2665 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(referenceCameraName);
2669 std::stringstream ss;
2670 ss <<
"The reference camera: " << referenceCameraName <<
" does not exist !";
2685 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2687 it->second->setScanLineVisibilityTest(v);
2698 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2700 it->second->setKltThresholdAcceptation(th);
2715 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2717 it->second->setUseKltTracking(name, useKltTracking);
2735 it->second->track(I);
2736 it->second->getPose(
cMo);
2738 std::stringstream ss;
2755 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2756 std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
2757 mapOfImages[it->first] = &I1;
2760 mapOfImages[it->first] = &I2;
2763 std::stringstream ss;
2764 ss <<
"Require two cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
2779 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2781 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.find(it_klt->first);
2783 if (it_img == mapOfImages.end()) {
2823 #elif !defined(VISP_BUILD_SHARED_LIBS) 2826 void dummy_vpMbKltMultiTracker(){};
2827 #endif // VISP_HAVE_OPENCV virtual unsigned int getClipping() const
bool m_computeInteraction
void setGoodNbRayCastingAttemptsRatio(const double &ratio)
virtual void setCovarianceComputation(const bool &flag)
Implementation of a matrix and operations on matrices.
virtual std::vector< std::string > getCameraNames() const
virtual std::map< std::string, int > getKltNbPoints() const
vpMatrix m_L_kltMulti
Interaction matrix.
virtual std::list< vpMbtDistanceKltCylinder * > & getFeaturesKltCylinder()
virtual void setFarClippingDistance(const double &dist)
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
virtual void track(const vpImage< unsigned char > &I)
virtual void addCircle(const vpPoint &P1, const vpPoint &P2, const vpPoint &P3, const double r, const std::string &name="")
virtual void setUseKltTracking(const std::string &name, const bool &useKltTracking)
virtual void setCovarianceComputation(const bool &flag)
virtual void setPose(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo)
virtual void setAngleDisappear(const double &a)
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
virtual void setAngleDisappear(const double &a)
virtual std::map< std::string, std::map< int, vpImagePoint > > getKltImagePointsWithId() const
virtual void loadConfigFile(const std::string &configFile)
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual std::list< vpMbtDistanceKltPoints * > & getFeaturesKlt()
virtual std::map< std::string, std::vector< vpImagePoint > > getKltImagePoints() const
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.
std::list< vpMbtDistanceKltCylinder * > kltCylinders
vpHomogeneousMatrix cMo
The current pose.
virtual void setKltThresholdAcceptation(const double th)
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w)
virtual void setDisplayFeatures(const bool displayF)
virtual void setCameraTransformationMatrix(const std::string &cameraName, const vpHomogeneousMatrix &cameraTransformationMatrix)
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)
error that can be emited by ViSP classes.
virtual void setThresholdAcceptation(const double th)
virtual void computeVVSInit()
virtual void computeVVSInteractionMatrixAndResidu()
unsigned int getRows() const
vpHomogeneousMatrix inverse() const
bool useOgre
Use Ogre3d for visibility tests.
virtual void setLod(const bool useLod, const std::string &name="")
virtual void init(const vpImage< unsigned char > &I)
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
virtual void computeVVS()
virtual void reinit(const vpImage< unsigned char > &I)
virtual void computeVVSInteractionMatrixAndResidu()
Class that defines what is a point.
vpCameraParameters cam
The camera parameters.
std::map< std::string, vpHomogeneousMatrix > m_mapOfCameraTransformationMatrix
vpHomogeneousMatrix ctTc0
virtual void setReferenceCameraName(const std::string &referenceCameraName)
virtual unsigned int getNbPolygon() const
virtual std::map< std::string, int > getNbKltPoints() const
virtual vpHomogeneousMatrix getPose() const
virtual void setKltMaskBorder(const unsigned int &e)
virtual std::map< std::string, vpKltOpencv > getKltOpencv() const
vpRobust m_robust_klt
Robust.
void insert(const vpMatrix &A, const unsigned int r, const unsigned int c)
vpMatrix oJo
The Degrees of Freedom to estimate.
Error that can be emited by the vpTracker class and its derivates.
vp_deprecated void init()
virtual vpMbHiddenFaces< vpMbtPolygon > & getFaces()
virtual void setClipping(const unsigned int &flags)
virtual void setOgreShowConfigDialog(const bool showConfigDialog)
virtual std::list< vpMbtDistanceCircle * > & getFeaturesCircle()
bool useScanLine
Use Scanline for visibility tests.
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
vpColVector m_weightedError_kltMulti
Weighted error.
unsigned int maskBorder
Erosion of the mask.
Generic class defining intrinsic camera parameters.
unsigned int m_nbFaceUsed
virtual void preTracking(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages)
double m_initialMu
Initial Mu for Levenberg Marquardt optimization loop.
double m_lambda
Gain of the virtual visual servoing stage.
virtual void computeVVSWeights(vpRobust &robust, const vpColVector &error, vpColVector &w)
virtual void setAngleAppear(const double &a)
virtual void setAngleAppear(const double &a)
Model based tracker using only KLT.
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
std::string m_referenceCameraName
Name of the reference camera.
double angleAppears
Angle used to detect a face appearance.
virtual ~vpMbKltMultiTracker()
unsigned int m_maxIter
Maximum number of iterations of the virtual visual servoing stage.
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
virtual void postTracking(std::map< std::string, const vpImage< unsigned char > *> &mapOfImages)
static double rad(double deg)
vpColVector m_w_kltMulti
Robust weights.
virtual void setKltOpencv(const vpKltOpencv &t)
void insert(unsigned int i, const vpColVector &v)
virtual void setNearClippingDistance(const double &dist)
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void setOgreVisibilityTest(const bool &v)
vpColVector m_w_klt
Robust weights.
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
std::list< vpMbtDistanceCircle * > circles_disp
Vector of the circles used here only to display the full model.
bool displayFeatures
If true, the features are displayed.
void preTracking(const vpImage< unsigned char > &I)
Implementation of column vector and the associated operations.
std::map< std::string, vpMbKltTracker * > m_mapOfKltTrackers
Map of Model-based klt trackers.
virtual std::map< std::string, unsigned int > getMultiNbPolygon() const
virtual void loadModel(const std::string &modelFile, const bool verbose=false)
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.
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
static vpHomogeneousMatrix direct(const vpColVector &v)
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false)
virtual void computeCovarianceMatrixVVS(const bool isoJoIdentity_, const vpColVector &w_true, const vpHomogeneousMatrix &cMoPrev, const vpMatrix &L_true, const vpMatrix &LVJ_true, const vpColVector &error)
double angleDisappears
Angle used to detect a face disappearance.
virtual void computeVVSInit()
virtual void setScanLineVisibilityTest(const bool &v)
virtual void getCameraParameters(vpCameraParameters &camera) const
virtual void setClipping(const unsigned int &flags)
virtual void initClick(const vpImage< unsigned char > &I, const std::vector< vpPoint > &points3D_list, const std::string &displayFile="")
virtual void computeVVSWeights()
unsigned int clippingFlag
Flags specifying which clipping to used.
virtual std::map< std::string, std::vector< cv::Point2f > > getKltPoints() const
vpColVector m_error_klt
(s - s*)
vpColVector m_error_kltMulti
(s - s*)
virtual void setFarClippingDistance(const double &dist)
virtual void setMaskBorder(const unsigned int &e)
virtual void resetTracker()
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)
std::list< vpMbtDistanceKltPoints * > kltPolygons
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
vpHomogeneousMatrix c0Mo
Initial pose.
virtual void setOptimizationMethod(const vpMbtOptimizationMethod &opt)
virtual void setScanLineVisibilityTest(const bool &v)
void resize(const unsigned int i, const bool flagNullify=true)
virtual void setNearClippingDistance(const double &dist)
vpMatrix m_L_klt
Interaction matrix.