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 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;
1016 it->second->initClick(I, initFile, displayHelp, T);
1017 it->second->getPose(
cMo);
1023 std::stringstream ss;
1068 const std::string &initFile1,
const std::string &initFile2,
const bool displayHelp,
1069 const 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(
cMo);
1080 it->second->getCameraParameters(this->
cam);
1089 it->second->initClick(I2, initFile2, displayHelp);
1091 if (!firstCameraIsReference) {
1093 it->second->getPose(
cMo);
1096 it->second->getCameraParameters(this->
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,
const 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(
cMo);
1159 it_img = mapOfImages.find(it_klt->first);
1160 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1165 it_klt->second->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,
const 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(
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,
cMo);
1352 it_ref->second->initFromPose(I,
cMo);
1379 const 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(
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: " 1563 it->second->loadConfigFile(configFile);
1564 it->second->getCameraParameters(
cam);
1571 std::stringstream ss;
1594 const bool firstCameraIsReference)
1597 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1598 it->second->loadConfigFile(configFile1);
1600 if (firstCameraIsReference) {
1601 it->second->getCameraParameters(
cam);
1610 it->second->loadConfigFile(configFile2);
1612 if (!firstCameraIsReference) {
1613 it->second->getCameraParameters(
cam);
1621 std::stringstream ss;
1622 ss <<
"Cannot loadConfigFile. Require two cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
1642 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
1644 std::map<std::string, std::string>::const_iterator it_config = mapOfConfigFiles.find(it_klt->first);
1645 if (it_config != mapOfConfigFiles.end()) {
1646 it_klt->second->loadConfigFile(it_config->second);
1648 std::stringstream ss;
1649 ss <<
"Missing configuration file for camera: " << it_klt->first <<
" !";
1657 it->second->getCameraParameters(
cam);
1664 std::stringstream ss;
1700 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1702 it->second->loadModel(modelFile, verbose, T);
1713 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1729 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1737 klt->
reinit(*mapOfImages[it->first]);
1773 std::stringstream ss;
1774 ss <<
"This method requires exactly one camera, there are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
1783 it_klt->second->reInitModel(I, cad_name, cMo_, verbose, T);
1786 it_klt->second->getPose(
cMo);
1811 const bool firstCameraIsReference)
1814 std::map<std::string, vpMbKltTracker *>::const_iterator it_edge =
m_mapOfKltTrackers.begin();
1816 it_edge->second->reInitModel(I1, cad_name, c1Mo, verbose);
1818 if (firstCameraIsReference) {
1820 it_edge->second->getPose(
cMo);
1825 it_edge->second->reInitModel(I2, cad_name, c2Mo, verbose);
1827 if (!firstCameraIsReference) {
1829 it_edge->second->getPose(
cMo);
1850 const std::string &cad_name,
1851 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses,
1855 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
1857 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
1859 if (it_klt !=
m_mapOfKltTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1860 it_klt->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1864 it_klt->second->getPose(
cMo);
1872 std::vector<std::string> vectorOfMissingCameras;
1875 it_img = mapOfImages.find(it_klt->first);
1876 it_camPose = mapOfCameraPoses.find(it_klt->first);
1878 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
1879 it_klt->second->reInitModel(*it_img->second, cad_name, it_camPose->second, verbose);
1881 vectorOfMissingCameras.push_back(it_klt->first);
1886 for (std::vector<std::string>::const_iterator it = vectorOfMissingCameras.begin(); it != vectorOfMissingCameras.end();
1888 it_img = mapOfImages.find(*it);
1889 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
1894 m_mapOfKltTrackers[*it]->reInitModel(*it_img->second, cad_name, cCurrentMo, verbose);
1909 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1911 it->second->resetTracker();
1934 #ifdef VISP_HAVE_OGRE 1952 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1954 it->second->setAngleAppear(a);
1971 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
1973 it->second->setAngleDisappear(a);
1991 it->second->setCameraParameters(camera);
1996 std::stringstream ss;
2012 const bool firstCameraIsReference)
2017 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2018 it->second->setCameraParameters(camera1);
2021 it->second->setCameraParameters(camera2);
2023 if (firstCameraIsReference) {
2024 this->
cam = camera1;
2026 this->
cam = camera2;
2029 std::stringstream ss;
2030 ss <<
"Require two cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
2043 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2045 it->second->setCameraParameters(camera);
2051 std::stringstream ss;
2052 ss <<
"The camera: " << cameraName <<
" does not exist !";
2064 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2066 std::map<std::string, vpCameraParameters>::const_iterator it_cam = mapOfCameraParameters.find(it_klt->first);
2067 if (it_cam != mapOfCameraParameters.end()) {
2068 it_klt->second->setCameraParameters(it_cam->second);
2071 this->
cam = it_cam->second;
2074 std::stringstream ss;
2075 ss <<
"Missing camera parameters for camera: " << it_klt->first <<
" !";
2094 it->second = cameraTransformationMatrix;
2096 std::stringstream ss;
2097 ss <<
"Cannot find camera: " << cameraName <<
" !";
2110 const std::map<std::string, vpHomogeneousMatrix> &mapOfTransformationMatrix)
2113 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2115 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2116 mapOfTransformationMatrix.find(it_klt->first);
2118 if (it_camTrans == mapOfTransformationMatrix.end()) {
2137 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2139 it->second->setClipping(flags);
2153 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2155 it->second->setClipping(flags);
2157 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2170 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2172 it->second->setCovarianceComputation(flag);
2183 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2185 it->second->setDisplayFeatures(displayF);
2200 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2202 it->second->setFarClippingDistance(dist);
2214 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2216 it->second->setFarClippingDistance(dist);
2218 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2222 #ifdef VISP_HAVE_OGRE 2234 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2236 it->second->setGoodNbRayCastingAttemptsRatio(ratio);
2251 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2253 it->second->setNbRayCastingAttemptsForVisibility(attempts);
2265 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2267 it_klt->second->setKltOpencv(t);
2278 for (std::map<std::string, vpKltOpencv>::const_iterator it_kltOpenCV = mapOfOpenCVTrackers.begin();
2279 it_kltOpenCV != mapOfOpenCVTrackers.end(); ++it_kltOpenCV) {
2280 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(it_kltOpenCV->first);
2282 it_klt->second->setKltOpencv(it_kltOpenCV->second);
2284 std::cerr <<
"The camera: " << it_kltOpenCV->first <<
" does not exist !" << std::endl;
2302 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2304 it->second->setLod(useLod, name);
2322 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(cameraName);
2325 it_klt->second->setLod(useLod, name);
2327 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2338 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2340 it->second->setKltMaskBorder(e);
2351 std::cerr <<
"Useless for KLT tracker !" << std::endl;
2364 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2366 it->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2381 const std::string &name)
2383 std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.find(cameraName);
2386 it_klt->second->setMinPolygonAreaThresh(minPolygonAreaThresh, name);
2388 std::cerr <<
"The camera: " << cameraName <<
" cannot be found !" << std::endl;
2401 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2403 it->second->setNearClippingDistance(dist);
2419 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2421 it->second->setOgreShowConfigDialog(showConfigDialog);
2435 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2437 it->second->setOgreVisibilityTest(v);
2440 #ifdef VISP_HAVE_OGRE 2441 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2443 it->second->faces.getOgreContext()->setWindowName(
"Multi MBT Klt (" + it->first +
")");
2458 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(cameraName);
2460 it->second->setNearClippingDistance(dist);
2462 std::cerr <<
"Camera: " << cameraName <<
" does not exist !" << std::endl;
2473 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2475 it->second->setOptimizationMethod(opt);
2493 it->second->setPose(I, cMo_);
2499 std::stringstream ss;
2504 std::stringstream ss;
2505 ss <<
"You are trying to set the pose with only one image and cMo " 2506 "but there are multiple cameras !";
2524 const bool firstCameraIsReference)
2527 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2528 it->second->setPose(I1, c1Mo);
2532 it->second->setPose(I2, c2Mo);
2534 if (firstCameraIsReference) {
2543 std::stringstream ss;
2544 ss <<
"This method requires 2 cameras but there are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
2562 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2565 if (it_img != mapOfImages.end()) {
2567 it_klt->second->setPose(*it_img->second, cMo_);
2578 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2580 it_img = mapOfImages.find(it_klt->first);
2584 it_klt->second->setPose(*it_img->second, cCurrentMo);
2591 std::stringstream ss;
2596 std::stringstream ss;
2613 const std::map<std::string, vpHomogeneousMatrix> &mapOfCameraPoses)
2617 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img =
2619 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camPose = mapOfCameraPoses.find(
m_referenceCameraName);
2621 if (it_klt !=
m_mapOfKltTrackers.end() && it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2622 it_klt->second->setPose(*it_img->second, it_camPose->second);
2623 it_klt->second->getPose(
cMo);
2632 std::vector<std::string> vectorOfMissingCameraPoses;
2637 it_img = mapOfImages.find(it_klt->first);
2638 it_camPose = mapOfCameraPoses.find(it_klt->first);
2640 if (it_img != mapOfImages.end() && it_camPose != mapOfCameraPoses.end()) {
2642 it_klt->second->setPose(*it_img->second, it_camPose->second);
2644 vectorOfMissingCameraPoses.push_back(it_klt->first);
2649 for (std::vector<std::string>::const_iterator it1 = vectorOfMissingCameraPoses.begin();
2650 it1 != vectorOfMissingCameraPoses.end(); ++it1) {
2651 it_img = mapOfImages.find(*it1);
2652 std::map<std::string, vpHomogeneousMatrix>::const_iterator it_camTrans =
2659 std::stringstream ss;
2660 ss <<
"Missing image or missing camera transformation matrix ! Cannot " 2661 "set the pose for camera: " 2675 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.find(referenceCameraName);
2679 std::stringstream ss;
2680 ss <<
"The reference camera: " << referenceCameraName <<
" does not exist !";
2695 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2697 it->second->setScanLineVisibilityTest(v);
2708 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2710 it->second->setKltThresholdAcceptation(th);
2725 for (std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2727 it->second->setUseKltTracking(name, useKltTracking);
2745 it->second->track(I);
2746 it->second->getPose(
cMo);
2748 std::stringstream ss;
2765 std::map<std::string, vpMbKltTracker *>::const_iterator it =
m_mapOfKltTrackers.begin();
2766 std::map<std::string, const vpImage<unsigned char> *> mapOfImages;
2767 mapOfImages[it->first] = &I1;
2770 mapOfImages[it->first] = &I2;
2773 std::stringstream ss;
2774 ss <<
"Require two cameras ! There are " <<
m_mapOfKltTrackers.size() <<
" cameras !";
2789 for (std::map<std::string, vpMbKltTracker *>::const_iterator it_klt =
m_mapOfKltTrackers.begin();
2791 std::map<std::string, const vpImage<unsigned char> *>::const_iterator it_img = mapOfImages.find(it_klt->first);
2793 if (it_img == mapOfImages.end()) {
2833 #elif !defined(VISP_BUILD_SHARED_LIBS) 2836 void dummy_vpMbKltMultiTracker(){}
2837 #endif // VISP_HAVE_OPENCV 2838 #elif !defined(VISP_BUILD_SHARED_LIBS) 2840 void dummy_vpMbKltMultiTracker(){}
2841 #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) bool m_computeInteraction
virtual unsigned int getNbPolygon() const
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 void getCameraParameters(vpCameraParameters &camera) const
vpMatrix m_L_kltMulti
Interaction matrix.
virtual std::list< vpMbtDistanceKltCylinder * > & getFeaturesKltCylinder()
virtual void setFarClippingDistance(const double &dist)
virtual std::map< std::string, int > getKltNbPoints() const
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 unsigned int getClipping() const
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 std::map< std::string, int > getNbKltPoints() const
virtual void setAngleDisappear(const double &a)
virtual void loadConfigFile(const std::string &configFile)
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual std::list< vpMbtDistanceKltPoints * > & getFeaturesKlt()
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()
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 std::map< std::string, vpKltOpencv > getKltOpencv() const
virtual void loadModel(const std::string &modelFile, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual std::map< std::string, std::vector< vpImagePoint > > getKltImagePoints() const
virtual void setKltMaskBorder(const unsigned int &e)
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 vpHomogeneousMatrix getPose() const
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 reInitModel(const vpImage< unsigned char > &I, const std::string &cad_name, const vpHomogeneousMatrix &cMo_, const bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual std::map< std::string, std::vector< cv::Point2f > > getKltPoints() const
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
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 preTracking(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages)
virtual void setAngleAppear(const double &a)
virtual void setAngleAppear(const double &a)
Model based tracker using only KLT.
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
unsigned int getRows() const
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)
static double rad(double deg)
vpColVector m_w_kltMulti
Robust weights.
virtual void setKltOpencv(const vpKltOpencv &t)
virtual std::map< std::string, std::map< int, vpImagePoint > > getKltImagePointsWithId() const
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 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 ...
vpHomogeneousMatrix inverse() const
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 postTracking(std::map< std::string, const vpImage< unsigned char > * > &mapOfImages)
virtual void setScanLineVisibilityTest(const bool &v)
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.
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 std::map< std::string, unsigned int > getMultiNbPolygon() const
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.