44 #include <visp3/core/vpConfig.h> 46 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) 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 bool displayFullModel)
318 it->second->display(I, cMo, cam, col, thickness, displayFullModel);
337 bool displayFullModel)
341 it->second->display(I, cMo, cam, color, thickness, displayFullModel);
364 unsigned int thickness,
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 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,
unsigned int thickness,
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,
unsigned int thickness,
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(
m_cMo);
967 std::stringstream ss;
1016 it->second->initClick(I, initFile, displayHelp, T);
1017 it->second->getPose(
m_cMo);
1023 std::stringstream ss;
1068 const std::string &initFile1,
const std::string &initFile2,
bool displayHelp,
1069 bool firstCameraIsReference)
1072 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1073 it->second->initClick(I1, initFile1, displayHelp);
1075 if (firstCameraIsReference) {
1077 it->second->getPose(
m_cMo);
1080 it->second->getCameraParameters(
m_cam);
1089 it->second->initClick(I2, initFile2, displayHelp);
1091 if (!firstCameraIsReference) {
1093 it->second->getPose(
m_cMo);
1096 it->second->getCameraParameters(
m_cam);
1103 std::stringstream ss;
1104 ss <<
"Cannot init click ! Require two cameras but there are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
1139 const std::string &initFile,
bool displayHelp)
1143 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1146 if (it_img != mapOfImages.end()) {
1147 it_klt->second->initClick(*it_img->second, initFile, displayHelp);
1150 it_klt->second->getPose(
m_cMo);
1159 it_img = mapOfImages.find(it_klt->first);
1160 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1165 it_klt->second->m_cMo = cCurrentMo;
1166 it_klt->second->
init(*it_img->second);
1168 std::stringstream ss;
1175 std::stringstream ss;
1180 std::stringstream ss;
1216 const std::map<std::string, std::string> &mapOfInitFiles,
bool displayHelp)
1219 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1221 std::map<std::string, std::string>::const_iterator it_initFile = mapOfInitFiles.find(
m_referenceCameraName);
1223 if (it_klt !=
m_mapOfKltTrackers.end() && it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1224 it_klt->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1225 it_klt->second->getPose(
m_cMo);
1234 std::vector<std::string> vectorOfMissingCameraPoses;
1239 it_img = mapOfImages.find(it_klt->first);
1240 it_initFile = mapOfInitFiles.find(it_klt->first);
1242 if (it_img != mapOfImages.end() && it_initFile != mapOfInitFiles.end()) {
1244 it_klt->second->initClick(*it_img->second, it_initFile->second, displayHelp);
1246 vectorOfMissingCameraPoses.push_back(it_klt->first);
1252 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
1253 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
1254 it_img = mapOfImages.find(*it1);
1255 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1263 std::stringstream ss;
1264 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 1265 "set the pose for camera: " 1271 #endif //#ifdef VISP_HAVE_MODULE_GUI 1298 char s[FILENAME_MAX];
1302 std::string ext =
".pos";
1303 size_t pos = initFile.rfind(ext);
1305 if (pos == initFile.size() - ext.size() && pos != 0)
1306 sprintf(s,
"%s", initFile.c_str());
1308 sprintf(s,
"%s.pos", initFile.c_str());
1310 finit.open(s, std::ios::in);
1312 std::cerr <<
"cannot read " << s << std::endl;
1316 for (
unsigned int i = 0; i < 6; i += 1) {
1317 finit >> init_pos[i];
1331 it_ref->second->initFromPose(I,
m_cMo);
1352 it_ref->second->initFromPose(I, cMo);
1379 bool firstCameraIsReference)
1382 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1383 it->second->initFromPose(I1, c1Mo);
1387 it->second->initFromPose(I2, c2Mo);
1389 if (firstCameraIsReference) {
1398 std::stringstream ss;
1399 ss <<
"This method requires 2 cameras but there are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
1417 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.find(it_klt->first);
1419 if (it_img != mapOfImages.end()) {
1420 it_klt->second->initFromPose(*it_img->second, cMo);
1428 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1430 it_img = mapOfImages.find(it_klt->first);
1434 it_klt->second->initFromPose(*it_img->second, cCurrentMo);
1437 "Cannot find camera transformation matrix or image !");
1445 std::stringstream ss;
1458 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
1462 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1464 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
1466 if (it_klt !=
m_mapOfKltTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1467 it_klt->second->initFromPose(*it_img->second, it_camPose->second);
1468 it_klt->second->getPose(
m_cMo);
1477 std::vector<std::string> vectorOfMissingCameraPoses;
1481 it_img = mapOfImages.find(it_klt->first);
1482 it_camPose = mapOfCameraPoses.find(it_klt->first);
1484 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1486 it_klt->second->initFromPose(*it_img->second, it_camPose->second);
1488 vectorOfMissingCameraPoses.push_back(it_klt->first);
1492 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
1493 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
1494 it_img = mapOfImages.find(*it1);
1495 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1502 std::stringstream ss;
1503 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 1504 "set the pose for camera: " 1558 it->second->loadConfigFile(configFile);
1559 it->second->getCameraParameters(
m_cam);
1566 std::stringstream ss;
1586 bool firstCameraIsReference)
1589 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1590 it->second->loadConfigFile(configFile1);
1592 if (firstCameraIsReference) {
1593 it->second->getCameraParameters(
m_cam);
1602 it->second->loadConfigFile(configFile2);
1604 if (!firstCameraIsReference) {
1605 it->second->getCameraParameters(
m_cam);
1613 std::stringstream ss;
1614 ss <<
"Cannot loadConfigFile. Require two cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
1631 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
1633 std::map<std::string, std::string>::const_iterator it_config = mapOfConfigFiles.find(it_klt->first);
1634 if (it_config != mapOfConfigFiles.end()) {
1635 it_klt->second->loadConfigFile(it_config->second);
1637 std::stringstream ss;
1638 ss <<
"Missing configuration file for camera: " << it_klt->first <<
" !";
1646 it->second->getCameraParameters(
m_cam);
1653 std::stringstream ss;
1689 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1691 it->second->loadModel(modelFile, verbose, T);
1702 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1717 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1725 klt->
reinit(*mapOfImages[it->first]);
1765 std::stringstream ss;
1766 ss <<
"This method requires exactly one camera, there are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
1775 it_klt->second->reInitModel(I, cad_name, cMo, verbose, T);
1778 it_klt->second->getPose(
m_cMo);
1803 bool firstCameraIsReference)
1806 std::map<std::string, vpMbKltTracker *>::const_iterator it_edge =
m_mapOfKltTrackers.begin();
1808 it_edge->second->reInitModel(I1, cad_name, c1Mo, verbose);
1810 if (firstCameraIsReference) {
1812 it_edge->second->getPose(
m_cMo);
1817 it_edge->second->reInitModel(I2, cad_name, c2Mo, verbose);
1819 if (!firstCameraIsReference) {
1821 it_edge->second->getPose(
m_cMo);
1842 const std::string &cad_name,
1843 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
1847 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1849 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
1851 if (it_klt !=
m_mapOfKltTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1852 it_klt->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1856 it_klt->second->getPose(
m_cMo);
1864 std::vector<std::string> vectorOfMissingCameras;
1867 it_img = mapOfImages.find(it_klt->first);
1868 it_camPose = mapOfCameraPoses.find(it_klt->first);
1870 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1871 it_klt->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1873 vectorOfMissingCameras.push_back(it_klt->first);
1878 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameras.begin(); it != vectorOfMissingCameras.end();
1880 it_img = mapOfImages.find(*it);
1881 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1886 m_mapOfKltTrackers[*it]->reInitModel(*it_img->second, cad_name, cCurrentMo, verbose);
1901 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1903 it->second->resetTracker();
1926 #ifdef VISP_HAVE_OGRE 1944 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1946 it->second->setAngleAppear(a);
1963 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1965 it->second->setAngleDisappear(a);
1983 it->second->setCameraParameters(cam);
1988 std::stringstream ss;
2004 bool firstCameraIsReference)
2009 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2010 it->second->setCameraParameters(camera1);
2013 it->second->setCameraParameters(camera2);
2015 if (firstCameraIsReference) {
2021 std::stringstream ss;
2022 ss <<
"Require two cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
2035 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2037 it->second->setCameraParameters(cam);
2043 std::stringstream ss;
2044 ss <<
"The camera: " << cameraName <<
" does not exist !";
2056 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2058 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_klt->first);
2059 if (it_cam != mapOfCameraParameters.end()) {
2060 it_klt->second->setCameraParameters(it_cam->second);
2063 m_cam = it_cam->second;
2066 std::stringstream ss;
2067 ss <<
"Missing camera parameters for camera: " << it_klt->first <<
" !";
2086 it->second = cameraTransformationMatrix;
2088 std::stringstream ss;
2089 ss <<
"Cannot find camera: " << cameraName <<
" !";
2102 const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix)
2105 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2107 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2108 mapOfTransformationMatrix.find(it_klt->first);
2110 if (it_camTrans == mapOfTransformationMatrix.end()) {
2129 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2131 it->second->setClipping(flags);
2145 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2147 it->second->setClipping(flags);
2149 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2162 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2164 it->second->setCovarianceComputation(flag);
2175 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2177 it->second->setDisplayFeatures(displayF);
2192 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2194 it->second->setFarClippingDistance(dist);
2206 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2208 it->second->setFarClippingDistance(dist);
2210 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2214 #ifdef VISP_HAVE_OGRE 2226 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2228 it->second->setGoodNbRayCastingAttemptsRatio(ratio);
2243 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2245 it->second->setNbRayCastingAttemptsForVisibility(attempts);
2257 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2259 it_klt->second->setKltOpencv(t);
2270 for (std::map<std::string, vpKltOpencv>::const_iterator it_kltOpenCV = mapOfOpenCVTrackers.begin();
2271 it_kltOpenCV != mapOfOpenCVTrackers.end(); ++it_kltOpenCV) {
2272 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(it_kltOpenCV->first);
2274 it_klt->second->setKltOpencv(it_kltOpenCV->second);
2276 std::cerr <<
"The camera: " << it_kltOpenCV->first <<
" does not exist !" << std::endl;
2294 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2296 it->second->setLod(useLod, name);
2314 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(cameraName);
2317 it_klt->second->setLod(useLod, name);
2319 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2330 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2332 it->second->setKltMaskBorder(e);
2343 std::cerr <<
"Useless for KLT tracker !" << std::endl;
2356 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2358 it->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2373 const std::string &name)
2375 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(cameraName);
2378 it_klt->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2380 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2393 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2395 it->second->setNearClippingDistance(dist);
2411 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2413 it->second->setOgreShowConfigDialog(showConfigDialog);
2427 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2429 it->second->setOgreVisibilityTest(v);
2432 #ifdef VISP_HAVE_OGRE 2433 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2435 it->second->faces.getOgreContext()->setWindowName(
"Multi MBT Klt (" + it->first +
")");
2450 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2452 it->second->setNearClippingDistance(dist);
2454 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2465 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2467 it->second->setOptimizationMethod(opt);
2485 it->second->setPose(I, cMo);
2491 std::stringstream ss;
2496 std::stringstream ss;
2497 ss <<
"You are trying to set the pose with only one image and cMo " 2498 "but there are multiple cameras !";
2516 it->second->setPose(
m_I, cMo);
2522 std::stringstream ss;
2527 std::stringstream ss;
2528 ss <<
"You are trying to set the pose with only one image and cMo " 2529 "but there are multiple cameras !";
2547 bool firstCameraIsReference)
2550 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2551 it->second->setPose(I1, c1Mo);
2555 it->second->setPose(I2, c2Mo);
2557 if (firstCameraIsReference) {
2566 std::stringstream ss;
2567 ss <<
"This method requires 2 cameras but there are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
2585 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2588 if (it_img != mapOfImages.end()) {
2590 it_klt->second->setPose(*it_img->second, cMo);
2601 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2603 it_img = mapOfImages.find(it_klt->first);
2607 it_klt->second->setPose(*it_img->second, cCurrentMo);
2614 std::stringstream ss;
2619 std::stringstream ss;
2636 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
2640 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2642 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
2644 if (it_klt !=
m_mapOfKltTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2645 it_klt->second->setPose(*it_img->second, it_camPose->second);
2646 it_klt->second->getPose(
m_cMo);
2655 std::vector<std::string> vectorOfMissingCameraPoses;
2660 it_img = mapOfImages.find(it_klt->first);
2661 it_camPose = mapOfCameraPoses.find(it_klt->first);
2663 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2665 it_klt->second->setPose(*it_img->second, it_camPose->second);
2667 vectorOfMissingCameraPoses.push_back(it_klt->first);
2672 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
2673 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
2674 it_img = mapOfImages.find(*it1);
2675 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2682 std::stringstream ss;
2683 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 2684 "set the pose for camera: " 2698 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(referenceCameraName);
2702 std::stringstream ss;
2703 ss <<
"The reference camera: " << referenceCameraName <<
" does not exist !";
2718 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2720 it->second->setScanLineVisibilityTest(v);
2731 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2733 it->second->setKltThresholdAcceptation(th);
2748 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2750 it->second->setUseKltTracking(name, useKltTracking);
2768 it->second->track(I);
2769 it->second->getPose(
m_cMo);
2771 std::stringstream ss;
2782 std::cout <<
"Not supported interface, this class is deprecated." << std::endl;
2796 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2797 std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
2798 mapOfImages[it->first] = &I1;
2801 mapOfImages[it->first] = &I2;
2804 std::stringstream ss;
2805 ss <<
"Require two cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
2820 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2822 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.find(it_klt->first);
2824 if (it_img == mapOfImages.end()) {
2864 #elif !defined(VISP_BUILD_SHARED_LIBS) 2867 void dummy_vpMbKltMultiTracker(){}
2868 #endif // VISP_HAVE_OPENCV 2869 #elif !defined(VISP_BUILD_SHARED_LIBS) 2871 void dummy_vpMbKltMultiTracker(){}
2872 #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) 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)
vpCameraParameters m_cam
The camera parameters.
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
virtual void track(const vpImage< unsigned char > &I)
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)
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)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
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
virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name="")
std::vector< std::vector< double > > m_featuresToBeDisplayedKlt
Display features.
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
Class to define colors available for display functionnalities.
std::list< vpMbtDistanceKltCylinder * > kltCylinders
bool postTracking(const vpImage< unsigned char > &I, vpColVector &w)
virtual void setCameraTransformationMatrix(const std::string &cameraName, const vpHomogeneousMatrix &cameraTransformationMatrix)
error that can be emited by ViSP classes.
virtual void computeVVSInit()
virtual void computeVVSInteractionMatrixAndResidu()
unsigned int getRows() const
vpHomogeneousMatrix inverse() const
bool useOgre
Use Ogre3d for visibility tests.
virtual void init(const vpImage< unsigned char > &I)
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()
virtual void reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
Class that defines what is a point.
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.
vpMatrix oJo
The Degrees of Freedom to estimate.
virtual void addCircle(const vpPoint &P1, const vpPoint &P2, const vpPoint &P3, double r, const std::string &name="")
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 std::list< vpMbtDistanceCircle * > & getFeaturesCircle()
bool useScanLine
Use Scanline for visibility tests.
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
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 setMinLineLengthThresh(double minLineLengthThresh, const std::string &name="")
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 setOgreShowConfigDialog(bool showConfigDialog)
virtual void setCameraParameters(const vpCameraParameters &camera)
virtual void setOgreVisibilityTest(const bool &v)
vpColVector m_w_klt
Robust weights.
void resize(unsigned int i, bool flagNullify=true)
void setNbRayCastingAttemptsForVisibility(const unsigned int &attempts)
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)
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
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 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 setDisplayFeatures(bool displayF)
virtual void computeVVSWeights()
unsigned int clippingFlag
Flags specifying which clipping to used.
void insert(const vpMatrix &A, unsigned int r, unsigned int c)
virtual std::map< std::string, std::vector< cv::Point2f > > getKltPoints() const
virtual void setThresholdAcceptation(double th)
virtual void setKltThresholdAcceptation(double th)
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)
vpImage< unsigned char > m_I
Grayscale image buffer, used when passing color images.
virtual void setLod(bool useLod, const std::string &name="")
virtual std::vector< std::vector< double > > getFeaturesForDisplayKlt()
vpHomogeneousMatrix m_cMo
The current pose.
virtual void resetTracker()
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)
virtual void setNearClippingDistance(const double &dist)
vpMatrix m_L_klt
Interaction matrix.