51 #include <visp3/core/vpColVector.h> 52 #include <visp3/core/vpDisplay.h> 53 #include <visp3/core/vpMath.h> 54 #include <visp3/core/vpMatrix.h> 55 #include <visp3/core/vpPoint.h> 56 #include <visp3/vision/vpPose.h> 57 #ifdef VISP_HAVE_MODULE_GUI 58 #include <visp3/gui/vpDisplayGDI.h> 59 #include <visp3/gui/vpDisplayOpenCV.h> 60 #include <visp3/gui/vpDisplayX.h> 62 #include <visp3/core/vpCameraParameters.h> 63 #include <visp3/core/vpColor.h> 64 #include <visp3/core/vpException.h> 65 #include <visp3/core/vpIoTools.h> 66 #include <visp3/core/vpPixelMeterConversion.h> 67 #ifdef VISP_HAVE_MODULE_IO 68 #include <visp3/io/vpImageIo.h> 70 #include <visp3/core/vpCPUFeatures.h> 71 #include <visp3/core/vpIoTools.h> 72 #include <visp3/core/vpMatrixException.h> 73 #include <visp3/core/vpTrackingException.h> 74 #include <visp3/mbt/vpMbTracker.h> 76 #ifdef VISP_HAVE_COIN3D 78 #include <Inventor/VRMLnodes/SoVRMLCoordinate.h> 79 #include <Inventor/VRMLnodes/SoVRMLGroup.h> 80 #include <Inventor/VRMLnodes/SoVRMLIndexedFaceSet.h> 81 #include <Inventor/VRMLnodes/SoVRMLIndexedLineSet.h> 82 #include <Inventor/VRMLnodes/SoVRMLShape.h> 83 #include <Inventor/VRMLnodes/SoVRMLTransform.h> 84 #include <Inventor/actions/SoGetMatrixAction.h> 85 #include <Inventor/actions/SoGetPrimitiveCountAction.h> 86 #include <Inventor/actions/SoSearchAction.h> 87 #include <Inventor/actions/SoToVRML2Action.h> 88 #include <Inventor/actions/SoWriteAction.h> 89 #include <Inventor/misc/SoChildList.h> 90 #include <Inventor/nodes/SoSeparator.h> 93 #if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2) 94 #include <emmintrin.h> 95 #define VISP_HAVE_SSE2 1 98 #ifndef DOXYGEN_SHOULD_SKIP_THIS 106 SegmentInfo() : extremities(), name(), useLod(false), minLineLengthThresh(0.) {}
108 std::vector<vpPoint> extremities;
111 double minLineLengthThresh;
118 struct PolygonFaceInfo {
119 PolygonFaceInfo(
const double dist,
const vpPolygon &poly,
const std::vector<vpPoint> &corners)
120 : distanceToCamera(dist), polygon(poly), faceCorners(corners)
124 bool operator<(
const PolygonFaceInfo &pfi)
const {
return distanceToCamera < pfi.distanceToCamera; }
126 double distanceToCamera;
128 std::vector<vpPoint> faceCorners;
131 #endif // DOXYGEN_SHOULD_SKIP_THIS 139 : cam(), cMo(), oJo(6, 6), isoJoIdentity(true), modelFileName(), modelInitialised(false), poseSavingFilename(),
140 computeCovariance(false), covarianceMatrix(), computeProjError(false), projectionError(90.0),
141 displayFeatures(false), m_optimizationMethod(
vpMbTracker::GAUSS_NEWTON_OPT), faces(), angleAppears(
vpMath::rad(89)),
142 angleDisappears(
vpMath::rad(89)), distNearClip(0.001), distFarClip(100), clippingFlag(
vpPolygon3D::NO_CLIPPING),
143 useOgre(false), ogreShowConfigDialog(false), useScanLine(false), nbPoints(0), nbLines(0), nbPolygonLines(0),
144 nbPolygonPoints(0), nbCylinders(0), nbCircles(0), useLodGeneral(false), applyLodSettingInConfig(false),
145 minLineLengthThresholdGeneral(50.0), minPolygonAreaThresholdGeneral(2500.0), mapOfParameterNames(),
146 m_computeInteraction(true), m_lambda(1.0), m_maxIter(30), m_stopCriteriaEpsilon(1e-8), m_initialMu(0.01)
162 #ifdef VISP_HAVE_MODULE_GUI 200 std::string ext =
".init";
201 std::string str_pose =
"";
202 size_t pos = (
unsigned int)initFile.rfind(ext);
205 std::fstream finitpos;
207 char s[FILENAME_MAX];
209 if (pos == initFile.size() - ext.size() && pos != 0)
210 str_pose = initFile.substr(0, pos) +
".0.pos";
212 str_pose = initFile +
".0.pos";
214 finitpos.open(str_pose.c_str(), std::ios::in);
215 sprintf(s,
"%s", str_pose.c_str());
220 if (finitpos.fail()) {
221 std::cout <<
"cannot read " << s << std::endl <<
"cMo set to identity" << std::endl;
224 for (
unsigned int i = 0; i < 6; i += 1) {
225 finitpos >> init_pos[i];
231 std::cout <<
"last_cMo : " << std::endl << last_cMo << std::endl;
238 std::cout <<
"No modification : left click " << std::endl;
239 std::cout <<
"Modify initial pose : right click " << std::endl;
265 if (pos == initFile.size() - ext.size() && pos != 0)
266 sprintf(s,
"%s", initFile.c_str());
268 sprintf(s,
"%s.init", initFile.c_str());
270 std::cout <<
"Load 3D points from: " << s << std::endl;
271 finit.open(s, std::ios::in);
273 std::cout <<
"cannot read " << s << std::endl;
277 #ifdef VISP_HAVE_MODULE_IO 282 if (pos == initFile.size() - ext.size() && pos != 0)
283 dispF = initFile.substr(0, pos) +
".ppm";
285 dispF = initFile +
".ppm";
288 std::cout <<
"Load image to help initialization: " << dispF << std::endl;
289 #if defined VISP_HAVE_X11 291 #elif defined VISP_HAVE_GDI 293 #elif defined VISP_HAVE_OPENCV 299 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV) 301 "Where to initialize...");
308 if (d_help != NULL) {
313 #else //#ifdef VISP_HAVE_MODULE_IO 315 #endif //#ifdef VISP_HAVE_MODULE_IO 319 while (!finit.fail() && (c ==
'#')) {
320 finit.ignore(256,
'\n');
327 finit.ignore(256,
'\n');
328 std::cout <<
"Number of 3D points " << n3d << std::endl;
334 for (
unsigned int i = 0; i < n3d; i++) {
337 while (!finit.fail() && (c ==
'#')) {
338 finit.ignore(256,
'\n');
347 finit.ignore(256,
'\n');
349 std::cout <<
"Point " << i + 1 <<
" with 3D coordinates: " << X <<
" " << Y <<
" " << Z << std::endl;
355 bool isWellInit =
false;
356 while (!isWellInit) {
357 std::vector<vpImagePoint> mem_ip;
358 for (
unsigned int i = 0; i < n3d; i++) {
359 std::ostringstream text;
360 text <<
"Click on point " << i + 1;
363 for (
unsigned int k = 0; k < mem_ip.size(); k++) {
368 std::cout <<
"Click on point " << i + 1 <<
" ";
371 mem_ip.push_back(ip);
377 std::cout <<
"with 2D coordinates: " << ip << std::endl;
424 if (d_help != NULL) {
430 std::cout <<
"cMo : " << std::endl <<
cMo << std::endl;
446 const std::string &displayFile)
453 std::vector<vpPoint> P;
454 for (
unsigned int i = 0; i < points3D_list.size(); i++)
455 P.push_back(
vpPoint(points3D_list[i].get_oX(), points3D_list[i].get_oY(), points3D_list[i].get_oZ()));
457 #ifdef VISP_HAVE_MODULE_IO 462 std::cout <<
"Load image to help initialization: " << displayFile << std::endl;
463 #if defined VISP_HAVE_X11 465 #elif defined VISP_HAVE_GDI 467 #elif defined VISP_HAVE_OPENCV 472 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV) 474 "Where to initialize...");
479 if (d_help != NULL) {
485 #else //#ifdef VISP_HAVE_MODULE_IO 487 #endif //#ifdef VISP_HAVE_MODULE_IO 490 bool isWellInit =
false;
491 while (!isWellInit) {
492 for (
unsigned int i = 0; i < points3D_list.size(); i++) {
493 std::cout <<
"Click on point " << i + 1 << std::endl;
502 std::cout <<
"Click on point " << ip << std::endl;
542 if (d_help != NULL) {
549 #endif //#ifdef VISP_HAVE_MODULE_GUI 577 char s[FILENAME_MAX];
580 std::string ext =
".init";
581 size_t pos = initFile.rfind(ext);
583 if (pos == initFile.size() - ext.size() && pos != 0)
584 sprintf(s,
"%s", initFile.c_str());
586 sprintf(s,
"%s.init", initFile.c_str());
588 std::cout <<
"Load 2D/3D points from: " << s << std::endl;
589 finit.open(s, std::ios::in);
591 std::cout <<
"cannot read " << s << std::endl;
601 while (!finit.fail() && (c ==
'#')) {
602 finit.ignore(256,
'\n');
609 finit.ignore(256,
'\n');
610 std::cout <<
"Number of 3D points " << n3d << std::endl;
616 for (
unsigned int i = 0; i < n3d; i++) {
619 while (!finit.fail() && (c ==
'#')) {
620 finit.ignore(256,
'\n');
628 finit.ignore(256,
'\n');
630 std::cout <<
"Point " << i + 1 <<
" with 3D coordinates: " << X <<
" " << Y <<
" " << Z << std::endl;
639 while (!finit.fail() && (c ==
'#')) {
640 finit.ignore(256,
'\n');
647 finit.ignore(256,
'\n');
648 std::cout <<
"Number of 2D points " << n2d << std::endl;
657 "In %s file, number of 2D points %d and number of 3D " 658 "points %d are not equal",
663 for (
unsigned int i = 0; i < n2d; i++) {
666 while (!finit.fail() && (c ==
'#')) {
667 finit.ignore(256,
'\n');
671 double u, v, x = 0, y = 0;
674 finit.ignore(256,
'\n');
677 std::cout <<
"Point " << i + 1 <<
" with 2D coordinates: " << ip << std::endl;
713 const std::vector<vpPoint> &points3D_list)
715 if (points2D_list.size() != points3D_list.size())
716 vpERROR_TRACE(
"vpMbTracker::initFromPoints(), Number of 2D points " 717 "different to the number of 3D points.");
719 size_t size = points3D_list.size();
720 std::vector<vpPoint> P;
723 for (
size_t i = 0; i < size; i++) {
724 P.push_back(
vpPoint(points3D_list[i].get_oX(), points3D_list[i].get_oY(), points3D_list[i].get_oZ()));
767 char s[FILENAME_MAX];
771 std::string ext =
".pos";
772 size_t pos = initFile.rfind(ext);
774 if (pos == initFile.size() - ext.size() && pos != 0)
775 sprintf(s,
"%s", initFile.c_str());
777 sprintf(s,
"%s.pos", initFile.c_str());
779 finit.open(s, std::ios::in);
781 std::cout <<
"cannot read " << s << std::endl;
785 for (
unsigned int i = 0; i < 6; i += 1) {
786 finit >> init_pos[i];
826 std::fstream finitpos;
827 char s[FILENAME_MAX];
829 sprintf(s,
"%s", filename.c_str());
830 finitpos.open(s, std::ios::out);
833 finitpos << init_pos;
838 const bool useLod,
const double minPolygonAreaThreshold,
839 const double minLineLengthThreshold)
841 std::vector<vpPoint> corners_without_duplicates;
842 corners_without_duplicates.push_back(corners[0]);
843 for (
unsigned int i = 0; i < corners.size() - 1; i++) {
844 if (std::fabs(corners[i].get_oX() - corners[i + 1].get_oX()) >
845 std::fabs(corners[i].get_oX()) * std::numeric_limits<double>::epsilon() ||
846 std::fabs(corners[i].get_oY() - corners[i + 1].get_oY()) >
847 std::fabs(corners[i].get_oY()) * std::numeric_limits<double>::epsilon() ||
848 std::fabs(corners[i].get_oZ() - corners[i + 1].get_oZ()) >
849 std::fabs(corners[i].get_oZ()) * std::numeric_limits<double>::epsilon()) {
850 corners_without_duplicates.push_back(corners[i + 1]);
855 polygon.
setNbPoint((
unsigned int)corners_without_duplicates.size());
877 for (
unsigned int j = 0; j < corners_without_duplicates.size(); j++) {
878 polygon.
addPoint(j, corners_without_duplicates[j]);
894 const int idFace,
const std::string &polygonName,
const bool useLod,
895 const double minPolygonAreaThreshold)
928 y[0] = plane.
getA() / norm_Y;
929 y[1] = plane.
getB() / norm_Y;
930 y[2] = plane.
getC() / norm_Y;
933 for (
unsigned int i = 0; i < 3; i++) {
949 for (
unsigned int i = 0; i < 4; i++) {
952 w_p = wMc * cMc_90 * c_p;
975 const bool useLod,
const double minLineLengthThreshold)
1013 const std::string &polygonName,
const bool useLod,
const double minLineLengthThreshold)
1016 for (
unsigned int i = 0; i < listFaces.size(); i++) {
1018 polygon.
setNbPoint((
unsigned int)listFaces[i].size());
1019 for (
unsigned int j = 0; j < listFaces[i].size(); j++)
1020 polygon.
addPoint(j, listFaces[i][j]);
1098 std::string::const_iterator it;
1101 it = modelFile.end();
1102 if ((*(it - 1) ==
'o' && *(it - 2) ==
'a' && *(it - 3) ==
'c' && *(it - 4) ==
'.') ||
1103 (*(it - 1) ==
'O' && *(it - 2) ==
'A' && *(it - 3) ==
'C' && *(it - 4) ==
'.')) {
1104 std::vector<std::string> vectorOfModelFilename;
1112 loadCAOModel(modelFile, vectorOfModelFilename, startIdFace, verbose,
true);
1113 }
else if ((*(it - 1) ==
'l' && *(it - 2) ==
'r' && *(it - 3) ==
'w' && *(it - 4) ==
'.') ||
1114 (*(it - 1) ==
'L' && *(it - 2) ==
'R' && *(it - 3) ==
'W' && *(it - 4) ==
'.')) {
1159 #ifdef VISP_HAVE_COIN3D 1163 SbBool ok = in.openFile(modelFile.c_str());
1164 SoVRMLGroup *sceneGraphVRML2;
1171 if (!in.isFileVRML2()) {
1172 SoSeparator *sceneGraph = SoDB::readAll(&in);
1173 if (sceneGraph == NULL) {
1177 SoToVRML2Action tovrml2;
1178 tovrml2.apply(sceneGraph);
1180 sceneGraphVRML2 = tovrml2.getVRML2SceneGraph();
1181 sceneGraphVRML2->ref();
1182 sceneGraph->unref();
1184 sceneGraphVRML2 = SoDB::readAllVRML(&in);
1185 if (sceneGraphVRML2 == NULL) {
1187 sceneGraphVRML2->ref();
1196 sceneGraphVRML2->unref();
1198 vpERROR_TRACE(
"coin not detected with ViSP, cannot load model : %s", modelFile.c_str());
1208 while (!fileId.fail() && (c ==
'#')) {
1209 fileId.ignore(256,
'\n');
1212 if (fileId.fail()) {
1220 std::map<std::string, std::string> mapOfParams;
1223 while (!endLine.empty() && !exit) {
1228 endLine =
trim(endLine);
1230 std::string param(it->first +
"=");
1233 if (endLine.compare(0, param.size(), param) == 0) {
1235 endLine = endLine.substr(param.size());
1237 bool parseQuote =
false;
1238 if (it->second ==
"string") {
1240 if (endLine.size() > 2 && endLine[0] ==
'"') {
1242 endLine = endLine.substr(1);
1243 size_t pos = endLine.find_first_of(
'"');
1245 if (pos != std::string::npos) {
1246 mapOfParams[it->first] = endLine.substr(0, pos);
1247 endLine = endLine.substr(pos + 1);
1257 size_t pos1 = endLine.find_first_of(
' ');
1258 size_t pos2 = endLine.find_first_of(
'\t');
1259 size_t pos = pos1 < pos2 ? pos1 : pos2;
1261 mapOfParams[it->first] = endLine.substr(0, pos);
1262 endLine = endLine.substr(pos + 1);
1319 int &startIdFace,
const bool verbose,
const bool parent)
1321 std::ifstream fileId;
1322 fileId.exceptions(std::ifstream::failbit | std::ifstream::eofbit);
1323 fileId.open(modelFile.c_str(), std::ifstream::in);
1324 if (fileId.fail()) {
1325 std::cout <<
"cannot read CAO model file: " << modelFile << std::endl;
1330 std::cout <<
"Model file : " << modelFile << std::endl;
1332 vectorOfModelFilename.push_back(modelFile);
1346 fileId >> caoVersion;
1347 fileId.ignore(256,
'\n');
1349 std::cout <<
"in vpMbTracker::loadCAOModel() -> Bad parameter header " 1350 "file : use V0, V1, ...";
1352 "header file : use V0, V1, ...");
1360 std::string prefix =
"load";
1364 bool header =
false;
1365 while (c ==
'l' || c ==
'L') {
1368 getline(fileId, line);
1369 if (!line.compare(0, prefix.size(), prefix)) {
1372 std::string headerPathRead = line.substr(6);
1373 size_t firstIndex = headerPathRead.find_first_of(
"\")");
1374 headerPathRead = headerPathRead.substr(0, firstIndex);
1376 std::string headerPath = headerPathRead;
1388 bool cyclic =
false;
1389 for (std::vector<std::string>::const_iterator it = vectorOfModelFilename.begin();
1390 it != vectorOfModelFilename.end() && !cyclic; ++it) {
1391 if (headerPath == *it) {
1398 loadCAOModel(headerPath, vectorOfModelFilename, startIdFace, verbose,
false);
1403 std::cout <<
"WARNING Cyclic dependency detected with file " << headerPath <<
" declared in " << modelFile
1417 unsigned int caoNbrPoint;
1418 fileId >> caoNbrPoint;
1419 fileId.ignore(256,
'\n');
1422 if (verbose || vectorOfModelFilename.size() == 1) {
1423 std::cout <<
"> " << caoNbrPoint <<
" points" << std::endl;
1426 if (caoNbrPoint > 100000) {
1430 if (caoNbrPoint == 0 && !header) {
1442 for (
unsigned int k = 0; k < caoNbrPoint; k++) {
1449 if (caoVersion == 2) {
1454 fileId.ignore(256,
'\n');
1464 std::map<std::pair<unsigned int, unsigned int>, SegmentInfo> segmentTemporaryMap;
1465 unsigned int caoNbrLine;
1466 fileId >> caoNbrLine;
1467 fileId.ignore(256,
'\n');
1470 unsigned int *caoLinePoints = NULL;
1471 if (verbose || vectorOfModelFilename.size() == 1) {
1472 std::cout <<
"> " << caoNbrLine <<
" lines" << std::endl;
1475 if (caoNbrLine > 100000) {
1481 caoLinePoints =
new unsigned int[2 * caoNbrLine];
1483 unsigned int index1, index2;
1486 int idFace = startIdFace;
1488 for (
unsigned int k = 0; k < caoNbrLine; k++) {
1498 fileId.getline(buffer, 256);
1499 std::string endLine(buffer);
1500 std::map<std::string, std::string> mapOfParams =
parseParameters(endLine);
1502 std::string segmentName =
"";
1505 if (mapOfParams.find(
"name") != mapOfParams.end()) {
1506 segmentName = mapOfParams[
"name"];
1508 if (mapOfParams.find(
"minLineLengthThreshold") != mapOfParams.end()) {
1509 minLineLengthThresh = std::atof(mapOfParams[
"minLineLengthThreshold"].c_str());
1511 if (mapOfParams.find(
"useLod") != mapOfParams.end()) {
1515 SegmentInfo segmentInfo;
1516 segmentInfo.name = segmentName;
1517 segmentInfo.useLod = useLod;
1518 segmentInfo.minLineLengthThresh = minLineLengthThresh;
1520 caoLinePoints[2 * k] = index1;
1521 caoLinePoints[2 * k + 1] = index2;
1523 if (index1 < caoNbrPoint && index2 < caoNbrPoint) {
1524 std::vector<vpPoint> extremities;
1525 extremities.push_back(caoPoints[index1]);
1526 extremities.push_back(caoPoints[index2]);
1527 segmentInfo.extremities = extremities;
1529 std::pair<unsigned int, unsigned int> key(index1, index2);
1531 segmentTemporaryMap[key] = segmentInfo;
1533 vpTRACE(
" line %d has wrong coordinates.", k);
1545 std::vector<std::pair<unsigned int, unsigned int> > faceSegmentKeyVector;
1546 unsigned int caoNbrPolygonLine;
1547 fileId >> caoNbrPolygonLine;
1548 fileId.ignore(256,
'\n');
1551 if (verbose || vectorOfModelFilename.size() == 1) {
1552 std::cout <<
"> " << caoNbrPolygonLine <<
" polygon lines" << std::endl;
1555 if (caoNbrPolygonLine > 100000) {
1557 delete[] caoLinePoints;
1562 for (
unsigned int k = 0; k < caoNbrPolygonLine; k++) {
1565 unsigned int nbLinePol;
1566 fileId >> nbLinePol;
1567 std::vector<vpPoint> corners;
1568 if (nbLinePol > 100000) {
1572 for (
unsigned int n = 0; n < nbLinePol; n++) {
1575 if (index >= caoNbrLine) {
1578 corners.push_back(caoPoints[caoLinePoints[2 * index]]);
1579 corners.push_back(caoPoints[caoLinePoints[2 * index + 1]]);
1581 std::pair<unsigned int, unsigned int> key(caoLinePoints[2 * index], caoLinePoints[2 * index + 1]);
1582 faceSegmentKeyVector.push_back(key);
1589 fileId.getline(buffer, 256);
1590 std::string endLine(buffer);
1591 std::map<std::string, std::string> mapOfParams =
parseParameters(endLine);
1593 std::string polygonName =
"";
1596 if (mapOfParams.find(
"name") != mapOfParams.end()) {
1597 polygonName = mapOfParams[
"name"];
1599 if (mapOfParams.find(
"minPolygonAreaThreshold") != mapOfParams.end()) {
1600 minPolygonAreaThreshold = std::atof(mapOfParams[
"minPolygonAreaThreshold"].c_str());
1602 if (mapOfParams.find(
"useLod") != mapOfParams.end()) {
1611 for (std::map<std::pair<unsigned int, unsigned int>, SegmentInfo>::const_iterator it = segmentTemporaryMap.begin();
1612 it != segmentTemporaryMap.end(); ++it) {
1613 if (std::find(faceSegmentKeyVector.begin(), faceSegmentKeyVector.end(), it->first) ==
1614 faceSegmentKeyVector.end()) {
1616 it->second.minLineLengthThresh);
1626 unsigned int caoNbrPolygonPoint;
1627 fileId >> caoNbrPolygonPoint;
1628 fileId.ignore(256,
'\n');
1631 if (verbose || vectorOfModelFilename.size() == 1) {
1632 std::cout <<
"> " << caoNbrPolygonPoint <<
" polygon points" << std::endl;
1635 if (caoNbrPolygonPoint > 100000) {
1639 for (
unsigned int k = 0; k < caoNbrPolygonPoint; k++) {
1642 unsigned int nbPointPol;
1643 fileId >> nbPointPol;
1644 if (nbPointPol > 100000) {
1647 std::vector<vpPoint> corners;
1648 for (
unsigned int n = 0; n < nbPointPol; n++) {
1650 if (index > caoNbrPoint - 1) {
1653 corners.push_back(caoPoints[index]);
1660 fileId.getline(buffer, 256);
1661 std::string endLine(buffer);
1662 std::map<std::string, std::string> mapOfParams =
parseParameters(endLine);
1664 std::string polygonName =
"";
1667 if (mapOfParams.find(
"name") != mapOfParams.end()) {
1668 polygonName = mapOfParams[
"name"];
1670 if (mapOfParams.find(
"minPolygonAreaThreshold") != mapOfParams.end()) {
1671 minPolygonAreaThreshold = std::atof(mapOfParams[
"minPolygonAreaThreshold"].c_str());
1673 if (mapOfParams.find(
"useLod") != mapOfParams.end()) {
1683 unsigned int caoNbCylinder;
1690 delete[] caoLinePoints;
1695 fileId >> caoNbCylinder;
1696 fileId.ignore(256,
'\n');
1699 if (verbose || vectorOfModelFilename.size() == 1) {
1700 std::cout <<
"> " << caoNbCylinder <<
" cylinders" << std::endl;
1703 if (caoNbCylinder > 100000) {
1707 for (
unsigned int k = 0; k < caoNbCylinder; ++k) {
1711 unsigned int indexP1, indexP2;
1720 fileId.getline(buffer, 256);
1721 std::string endLine(buffer);
1722 std::map<std::string, std::string> mapOfParams =
parseParameters(endLine);
1724 std::string polygonName =
"";
1727 if (mapOfParams.find(
"name") != mapOfParams.end()) {
1728 polygonName = mapOfParams[
"name"];
1730 if (mapOfParams.find(
"minLineLengthThreshold") != mapOfParams.end()) {
1731 minLineLengthThreshold = std::atof(mapOfParams[
"minLineLengthThreshold"].c_str());
1733 if (mapOfParams.find(
"useLod") != mapOfParams.end()) {
1737 int idRevolutionAxis = idFace;
1738 addPolygon(caoPoints[indexP1], caoPoints[indexP2], idFace++, polygonName, useLod, minLineLengthThreshold);
1740 std::vector<std::vector<vpPoint> > listFaces;
1742 addPolygon(listFaces, idFace, polygonName, useLod, minLineLengthThreshold);
1745 initCylinder(caoPoints[indexP1], caoPoints[indexP2], radius, idRevolutionAxis, polygonName);
1749 std::cerr <<
"Cannot get the number of cylinders. Defaulting to zero." << std::endl;
1755 unsigned int caoNbCircle;
1762 delete[] caoLinePoints;
1767 fileId >> caoNbCircle;
1768 fileId.ignore(256,
'\n');
1771 if (verbose || vectorOfModelFilename.size() == 1) {
1772 std::cout <<
"> " << caoNbCircle <<
" circles" << std::endl;
1775 if (caoNbCircle > 100000) {
1779 for (
unsigned int k = 0; k < caoNbCircle; ++k) {
1783 unsigned int indexP1, indexP2, indexP3;
1793 fileId.getline(buffer, 256);
1794 std::string endLine(buffer);
1795 std::map<std::string, std::string> mapOfParams =
parseParameters(endLine);
1797 std::string polygonName =
"";
1800 if (mapOfParams.find(
"name") != mapOfParams.end()) {
1801 polygonName = mapOfParams[
"name"];
1803 if (mapOfParams.find(
"minPolygonAreaThreshold") != mapOfParams.end()) {
1804 minPolygonAreaThreshold = std::atof(mapOfParams[
"minPolygonAreaThreshold"].c_str());
1806 if (mapOfParams.find(
"useLod") != mapOfParams.end()) {
1810 addPolygon(caoPoints[indexP1], caoPoints[indexP2], caoPoints[indexP3], radius, idFace, polygonName, useLod,
1811 minPolygonAreaThreshold);
1813 initCircle(caoPoints[indexP1], caoPoints[indexP2], caoPoints[indexP3], radius, idFace++, polygonName);
1817 std::cerr <<
"Cannot get the number of circles. Defaulting to zero." << std::endl;
1821 startIdFace = idFace;
1824 delete[] caoLinePoints;
1826 if (vectorOfModelFilename.size() > 1 && parent) {
1828 std::cout <<
"Global information for " <<
vpIoTools::getName(modelFile) <<
" :" << std::endl;
1829 std::cout <<
"Total nb of points : " <<
nbPoints << std::endl;
1830 std::cout <<
"Total nb of lines : " <<
nbLines << std::endl;
1831 std::cout <<
"Total nb of polygon lines : " <<
nbPolygonLines << std::endl;
1832 std::cout <<
"Total nb of polygon points : " <<
nbPolygonPoints << std::endl;
1833 std::cout <<
"Total nb of cylinders : " <<
nbCylinders << std::endl;
1834 std::cout <<
"Total nb of circles : " <<
nbCircles << std::endl;
1836 std::cout <<
"> " <<
nbPoints <<
" points" << std::endl;
1837 std::cout <<
"> " <<
nbLines <<
" lines" << std::endl;
1838 std::cout <<
"> " <<
nbPolygonLines <<
" polygon lines" << std::endl;
1839 std::cout <<
"> " <<
nbPolygonPoints <<
" polygon points" << std::endl;
1840 std::cout <<
"> " <<
nbCylinders <<
" cylinders" << std::endl;
1841 std::cout <<
"> " <<
nbCircles <<
" circles" << std::endl;
1845 std::cerr <<
"Cannot read line!" << std::endl;
1850 #ifdef VISP_HAVE_COIN3D 1861 SoVRMLTransform *sceneGraphVRML2Trasnform =
dynamic_cast<SoVRMLTransform *
>(sceneGraphVRML2);
1862 if (sceneGraphVRML2Trasnform) {
1863 float rx, ry, rz, rw;
1864 sceneGraphVRML2Trasnform->rotation.getValue().getValue(rx, ry, rz, rw);
1870 tx = sceneGraphVRML2Trasnform->translation.getValue()[0];
1871 ty = sceneGraphVRML2Trasnform->translation.getValue()[1];
1872 tz = sceneGraphVRML2Trasnform->translation.getValue()[2];
1878 sx = sceneGraphVRML2Trasnform->scale.getValue()[0];
1879 sy = sceneGraphVRML2Trasnform->scale.getValue()[1];
1880 sz = sceneGraphVRML2Trasnform->scale.getValue()[2];
1884 for (
unsigned int i = 0; i < 3; i++)
1886 for (
unsigned int i = 0; i < 3; i++)
1888 for (
unsigned int i = 0; i < 3; i++)
1892 transform = transform * transformCur;
1895 int nbShapes = sceneGraphVRML2->getNumChildren();
1902 for (
int i = 0; i < nbShapes; i++) {
1904 child = sceneGraphVRML2->getChild(i);
1906 if (child->getTypeId() == SoVRMLGroup::getClassTypeId()) {
1907 extractGroup((SoVRMLGroup *)child, transform_recursive, idFace);
1910 if (child->getTypeId() == SoVRMLTransform::getClassTypeId()) {
1911 extractGroup((SoVRMLTransform *)child, transform_recursive, idFace);
1914 if (child->getTypeId() == SoVRMLShape::getClassTypeId()) {
1915 SoChildList *child2list = child->getChildren();
1916 std::string name = child->getName().getString();
1918 for (
int j = 0; j < child2list->getLength(); j++) {
1919 if (((SoNode *)child2list->get(j))->getTypeId() == SoVRMLIndexedFaceSet::getClassTypeId()) {
1920 SoVRMLIndexedFaceSet *face_set;
1921 face_set = (SoVRMLIndexedFaceSet *)child2list->get(j);
1922 if (!strncmp(face_set->getName().getString(),
"cyl", 3)) {
1928 if (((SoNode *)child2list->get(j))->getTypeId() == SoVRMLIndexedLineSet::getClassTypeId()) {
1929 SoVRMLIndexedLineSet *line_set;
1930 line_set = (SoVRMLIndexedLineSet *)child2list->get(j);
1948 const std::string &polygonName)
1950 std::vector<vpPoint> corners;
1955 int indexListSize = face_set->coordIndex.getNum();
1959 SoVRMLCoordinate *coord;
1961 for (
int i = 0; i < indexListSize; i++) {
1962 if (face_set->coordIndex[i] == -1) {
1963 if (corners.size() > 1) {
1969 coord = (SoVRMLCoordinate *)(face_set->coord.getValue());
1970 int index = face_set->coordIndex[i];
1971 pointTransformed[0] = coord->point[index].getValue()[0];
1972 pointTransformed[1] = coord->point[index].getValue()[1];
1973 pointTransformed[2] = coord->point[index].getValue()[2];
1974 pointTransformed[3] = 1.0;
1976 pointTransformed = transform * pointTransformed;
1979 corners.push_back(pt);
1999 const std::string &polygonName)
2001 std::vector<vpPoint> corners_c1, corners_c2;
2004 SoVRMLCoordinate *coords = (SoVRMLCoordinate *)face_set->coord.getValue();
2006 unsigned int indexListSize = (
unsigned int)coords->point.getNum();
2008 if (indexListSize % 2 == 1) {
2009 std::cout <<
"Not an even number of points when extracting a cylinder." << std::endl;
2012 corners_c1.resize(indexListSize / 2);
2013 corners_c2.resize(indexListSize / 2);
2019 for (
int i = 0; i < coords->point.getNum(); ++i) {
2020 pointTransformed[0] = coords->point[i].getValue()[0];
2021 pointTransformed[1] = coords->point[i].getValue()[1];
2022 pointTransformed[2] = coords->point[i].getValue()[2];
2023 pointTransformed[3] = 1.0;
2025 pointTransformed = transform * pointTransformed;
2029 if (i < (
int)corners_c1.size()) {
2030 corners_c1[(
unsigned int)i] = pt;
2032 corners_c2[(
unsigned int)i - corners_c1.size()] = pt;
2040 dist[0] = p1.
get_oX() - corners_c1[0].get_oX();
2041 dist[1] = p1.
get_oY() - corners_c1[0].get_oY();
2042 dist[2] = p1.
get_oZ() - corners_c1[0].get_oZ();
2043 double radius_c1 = sqrt(dist.
sumSquare());
2044 dist[0] = p2.
get_oX() - corners_c2[0].get_oX();
2045 dist[1] = p2.
get_oY() - corners_c2[0].get_oY();
2046 dist[2] = p2.
get_oZ() - corners_c2[0].get_oZ();
2047 double radius_c2 = sqrt(dist.sumSquare());
2049 if (std::fabs(radius_c1 - radius_c2) >
2050 (std::numeric_limits<double>::epsilon() *
vpMath::maximum(radius_c1, radius_c2))) {
2051 std::cout <<
"Radius from the two circles of the cylinders are different." << std::endl;
2058 int idRevolutionAxis = idFace;
2061 std::vector<std::vector<vpPoint> > listFaces;
2066 initCylinder(p1, p2, radius_c1, idRevolutionAxis, polygonName);
2079 std::vector<vpPoint> corners;
2082 int indexListSize = line_set->coordIndex.getNum();
2084 SbVec3f point(0, 0, 0);
2086 SoVRMLCoordinate *coord;
2088 for (
int i = 0; i < indexListSize; i++) {
2089 if (line_set->coordIndex[i] == -1) {
2090 if (corners.size() > 1) {
2096 coord = (SoVRMLCoordinate *)(line_set->coord.getValue());
2097 int index = line_set->coordIndex[i];
2098 point[0] = coord->point[index].getValue()[0];
2099 point[1] = coord->point[index].getValue()[1];
2100 point[2] = coord->point[index].getValue()[2];
2103 corners.push_back(pt);
2108 #endif // VISP_HAVE_COIN3D 2122 std::cout <<
"Cannot extract center of gravity of empty set." << std::endl;
2130 for (
unsigned int i = 0; i < pts.size(); ++i) {
2132 oY += pts[i].get_oY();
2133 oZ += pts[i].get_oZ();
2152 std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
2156 std::vector<vpPolygon> polygonsTmp;
2157 std::vector<std::vector<vpPoint> > roisPtTmp;
2160 std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > > pairOfPolygonFaces;
2165 if ((useVisibility &&
faces.
getPolygon()[i]->isvisible) || !useVisibility) {
2166 std::vector<vpImagePoint> roiPts;
2174 if (roiPts.size() <= 2) {
2178 polygonsTmp.push_back(
vpPolygon(roiPts));
2180 std::vector<vpPoint> polyPts;
2188 roisPtTmp.push_back(polyPts);
2193 if (orderPolygons) {
2195 std::vector<PolygonFaceInfo> listOfPolygonFaces;
2196 for (
unsigned int i = 0; i < polygonsTmp.size(); i++) {
2197 double x_centroid = 0.0, y_centroid = 0.0, z_centroid = 0.0;
2198 for (
unsigned int j = 0; j < roisPtTmp[i].size(); j++) {
2199 x_centroid += roisPtTmp[i][j].get_X();
2200 y_centroid += roisPtTmp[i][j].get_Y();
2201 z_centroid += roisPtTmp[i][j].get_Z();
2204 x_centroid /= roisPtTmp[i].size();
2205 y_centroid /= roisPtTmp[i].size();
2206 z_centroid /= roisPtTmp[i].size();
2208 double squared_dist = x_centroid * x_centroid + y_centroid * y_centroid + z_centroid * z_centroid;
2209 listOfPolygonFaces.push_back(PolygonFaceInfo(squared_dist, polygonsTmp[i], roisPtTmp[i]));
2213 std::sort(listOfPolygonFaces.begin(), listOfPolygonFaces.end());
2215 polygonsTmp.resize(listOfPolygonFaces.size());
2216 roisPtTmp.resize(listOfPolygonFaces.size());
2219 for (std::vector<PolygonFaceInfo>::const_iterator it = listOfPolygonFaces.begin(); it != listOfPolygonFaces.end();
2221 polygonsTmp[cpt] = it->polygon;
2222 roisPtTmp[cpt] = it->faceCorners;
2225 pairOfPolygonFaces.first = polygonsTmp;
2226 pairOfPolygonFaces.second = roisPtTmp;
2228 pairOfPolygonFaces.first = polygonsTmp;
2229 pairOfPolygonFaces.second = roisPtTmp;
2232 return pairOfPolygonFaces;
2247 #ifndef VISP_HAVE_OGRE 2249 std::cout <<
"WARNING: ViSP doesn't have Ogre3D, basic visibility test " 2250 "will be used. setOgreVisibilityTest() set to false." 2264 vpTRACE(
"Far clipping value cannot be inferior than near clipping value. " 2265 "Far clipping won't be considered.");
2267 vpTRACE(
"Far clipping value cannot be inferior than 0. Far clipping " 2268 "won't be considered.");
2272 for (
unsigned int i = 0; i <
faces.
size(); i++) {
2275 #ifdef VISP_HAVE_OGRE 2293 for (
unsigned int i = 0; i <
faces.
size(); i++) {
2294 if (name.empty() ||
faces[i]->name == name) {
2295 faces[i]->setLod(useLod);
2311 for (
unsigned int i = 0; i <
faces.
size(); i++) {
2312 if (name.empty() ||
faces[i]->name == name) {
2313 faces[i]->setMinLineLengthThresh(minLineLengthThresh);
2328 for (
unsigned int i = 0; i <
faces.
size(); i++) {
2329 if (name.empty() ||
faces[i]->name == name) {
2330 faces[i]->setMinPolygonAreaThresh(minPolygonAreaThresh);
2343 vpTRACE(
"Near clipping value cannot be superior than far clipping value. " 2344 "Near clipping won't be considered.");
2346 vpTRACE(
"Near clipping value cannot be inferior than 0. Near clipping " 2347 "won't be considered.");
2351 for (
unsigned int i = 0; i <
faces.
size(); i++) {
2354 #ifdef VISP_HAVE_OGRE 2370 for (
unsigned int i = 0; i <
faces.
size(); i++)
2384 if (isoJoIdentity_) {
2420 __m128d v_JTR_0_1 = _mm_setzero_pd();
2421 __m128d v_JTR_2_3 = _mm_setzero_pd();
2422 __m128d v_JTR_4_5 = _mm_setzero_pd();
2424 for (
unsigned int i = 0; i < interaction.
getRows(); i++) {
2425 const __m128d v_error = _mm_set1_pd(error[i]);
2427 __m128d v_interaction = _mm_loadu_pd(&interaction[i][0]);
2428 v_JTR_0_1 = _mm_add_pd(v_JTR_0_1, _mm_mul_pd(v_interaction, v_error));
2430 v_interaction = _mm_loadu_pd(&interaction[i][2]);
2431 v_JTR_2_3 = _mm_add_pd(v_JTR_2_3, _mm_mul_pd(v_interaction, v_error));
2433 v_interaction = _mm_loadu_pd(&interaction[i][4]);
2434 v_JTR_4_5 = _mm_add_pd(v_JTR_4_5, _mm_mul_pd(v_interaction, v_error));
2437 _mm_storeu_pd(JTR.
data, v_JTR_0_1);
2438 _mm_storeu_pd(JTR.
data + 2, v_JTR_2_3);
2439 _mm_storeu_pd(JTR.
data + 4, v_JTR_4_5);
2442 const unsigned int N = interaction.
getRows();
2444 for (
unsigned int i = 0; i < 6; i += 1) {
2446 for (
unsigned int j = 0; j < N; j += 1) {
2447 ssum += interaction[j][i] * error[j];
2456 double &mu,
bool &reStartFromLastIncrement,
vpColVector *
const w,
2467 error = m_error_prev;
2468 if (w != NULL && m_w_prev != NULL) {
2471 reStartFromLastIncrement =
true;
2481 if (isoJoIdentity_) {
2489 vpMatrix LTLmuI = LTL + (LMA * mu);
2496 if (w != NULL && m_w_prev != NULL)
2518 vpMatrix LTLmuI = LVJTLVJ + (LMA * mu);
2526 if (w != NULL && m_w_prev != NULL)
2559 for (
unsigned int i = 0; i < 6; i++)
2583 for (
unsigned int i = 0; i < 6; i++) {
2585 if (std::fabs(v[i]) > std::numeric_limits<double>::epsilon()) {
2596 std::vector<std::vector<vpPoint> > &listFaces)
2618 if (axisOrtho.
euclideanNorm() < std::numeric_limits<double>::epsilon()) {
2622 if (axisOrtho.
euclideanNorm() < std::numeric_limits<double>::epsilon()) {
2626 if (axisOrtho.
euclideanNorm() < std::numeric_limits<double>::epsilon())
2656 std::vector<vpPoint> pointsFace;
2657 pointsFace.push_back(
vpPoint(fc1[0], fc1[1], fc1[2]));
2658 pointsFace.push_back(
vpPoint(sc1[0], sc1[1], sc1[2]));
2659 pointsFace.push_back(
vpPoint(sc2[0], sc2[1], sc2[2]));
2660 pointsFace.push_back(
vpPoint(fc2[0], fc2[1], fc2[2]));
2661 listFaces.push_back(pointsFace);
2664 pointsFace.push_back(
vpPoint(fc2[0], fc2[1], fc2[2]));
2665 pointsFace.push_back(
vpPoint(sc2[0], sc2[1], sc2[2]));
2666 pointsFace.push_back(
vpPoint(sc3[0], sc3[1], sc3[2]));
2667 pointsFace.push_back(
vpPoint(fc3[0], fc3[1], fc3[2]));
2668 listFaces.push_back(pointsFace);
2671 pointsFace.push_back(
vpPoint(fc3[0], fc3[1], fc3[2]));
2672 pointsFace.push_back(
vpPoint(sc3[0], sc3[1], sc3[2]));
2673 pointsFace.push_back(
vpPoint(sc4[0], sc4[1], sc4[2]));
2674 pointsFace.push_back(
vpPoint(fc4[0], fc4[1], fc4[2]));
2675 listFaces.push_back(pointsFace);
2678 pointsFace.push_back(
vpPoint(fc4[0], fc4[1], fc4[2]));
2679 pointsFace.push_back(
vpPoint(sc4[0], sc4[1], sc4[2]));
2680 pointsFace.push_back(
vpPoint(sc1[0], sc1[1], sc1[2]));
2681 pointsFace.push_back(
vpPoint(fc1[0], fc1[1], fc1[2]));
2682 listFaces.push_back(pointsFace);
double euclideanNorm() const
Implementation of a matrix and operations on matrices.
vpMatrix pseudoInverse(double svThreshold=1e-6) const
vpMatrix covarianceMatrix
Covariance matrix.
bool parseBoolean(std::string &input)
double get_oY() const
Get the point Y coordinate in the object frame.
Implements a 3D polygon with render functionnalities like clipping.
Class that defines generic functionnalities for display.
virtual void setNbPoint(const unsigned int nb)
static vpMatrix computeCovarianceMatrixVVS(const vpHomogeneousMatrix &cMo, const vpColVector &deltaS, const vpMatrix &Ls, const vpMatrix &W)
unsigned int nbLines
Number of lines in CAO model.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
virtual void extractCylinders(SoVRMLIndexedFaceSet *face_set, vpHomogeneousMatrix &transform, int &idFace, const std::string &polygonName="")
void MEstimator(const vpRobustEstimatorType method, const vpColVector &residues, vpColVector &weights)
Compute the weights according a residue vector and a PsiFunction.
unsigned int size() const
std::map< std::string, std::string > parseParameters(std::string &endLine)
unsigned int nbCircles
Number of circles in CAO model.
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
void setNearClippingDistance(const double &dist)
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual void extractGroup(SoVRMLGroup *sceneGraphVRML2, vpHomogeneousMatrix &transform, int &idFace)
std::map< std::string, std::string > mapOfParameterNames
unsigned int nbCylinders
Number of cylinders in CAO model.
unsigned int nbPoints
Number of points in CAO model.
Display for windows using GDI (available on any windows 32 platform).
vpHomogeneousMatrix cMo
The current pose.
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, const double radius, const int idFace=0, const std::string &name="")=0
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void setMinPolygonAreaThresh(const double min_polygon_area)
error that can be emited by ViSP classes.
void set_x(const double x)
Set the point x coordinate in the image plane.
virtual void loadCAOModel(const std::string &modelFile, std::vector< std::string > &vectorOfModelFilename, int &startIdFace, const bool verbose=false, const bool parent=true)
unsigned int getRows() const
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Point coordinates conversion from pixel coordinates to normalized coordinates in meter...
void setName(const std::string &face_name)
Type * data
Address of the first element of the data array.
Provides simple mathematics computation tools that are not available in the C mathematics library (ma...
bool useOgre
Use Ogre3d for visibility tests.
std::string modelFileName
virtual void setEstimatedDoF(const vpColVector &v)
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
double get_oX() const
Get the point X coordinate in the object frame.
void setFarClippingDistance(const double &dist)
virtual void extractLines(SoVRMLIndexedLineSet *line_set, int &idFace, const std::string &polygonName="")
Class that defines what is a point.
vpCameraParameters cam
The camera parameters.
static Type maximum(const Type &a, const Type &b)
Implementation of a rotation matrix and operations on such kind of matrices.
virtual void init(const vpImage< unsigned char > &I)=0
unsigned int getCols() const
double distFarClip
Distance for near clipping.
vpAROgre * getOgreContext()
Defines a generic 2D polygon.
virtual void setMinPolygonAreaThresh(const double minPolygonAreaThresh, const std::string &name="")
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)=0
vpColVector & normalize()
vpMatrix oJo
The Degrees of Freedom to estimate.
Error that can be emited by the vpTracker class and its derivates.
Implementation of a polygon of the model used by the model-based tracker.
void diag(const double &val=1.0)
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static double sqr(double x)
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting)
VISP_EXPORT bool checkSSE2()
static void display(const vpImage< unsigned char > &I)
void createCylinderBBox(const vpPoint &p1, const vpPoint &p2, const double &radius, std::vector< std::vector< vpPoint > > &listFaces)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void addPoint(const unsigned int n, const vpPoint &P)
Class used for pose computation from N points (pose from point only). Some of the algorithms implemen...
virtual void initFaceFromCorners(vpMbtPolygon &polygon)=0
void set_y(const double y)
Set the point y coordinate in the image plane.
Main methods for a model-based tracker.
std::vector< PolygonType * > & getPolygon()
std::string & trim(std::string &s) const
bool computePose(vpPoseMethodType method, vpHomogeneousMatrix &cMo, bool(*func)(vpHomogeneousMatrix *)=NULL)
double get_oZ() const
Get the point Z coordinate in the object frame.
virtual void loadVRMLModel(const std::string &modelFile)
Implementation of a rotation vector as quaternion angle minimal representation.
double m_lambda
Gain of the virtual visual servoing stage.
void setIsPolygonOriented(const bool &oriented)
virtual void computeVVSWeights(vpRobust &robust, const vpColVector &error, vpColVector &w)
unsigned int nbPolygonLines
Number of polygon lines in CAO model.
vpPoint getGravityCenter(const std::vector< vpPoint > &_pts) const
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
void addPolygon(PolygonType *p)
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, const bool displayHelp=false)
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static double rad(double deg)
virtual void setMinLineLengthThresh(const double minLineLengthThresh, const std::string &name="")
std::string poseSavingFilename
int getWindowXPosition() const
int getWindowYPosition() const
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
unsigned int nbPolygonPoints
Number of polygon points in CAO model.
double minPolygonAreaThresholdGeneral
Minimum polygon area threshold for LOD mode (general setting)
virtual void setOgreVisibilityTest(const bool &v)
void setWorldCoordinates(const double oX, const double oY, const double oZ)
virtual void loadModel(const char *modelFile, const bool verbose=false)
static void read(vpImage< unsigned char > &I, const std::string &filename)
bool applyLodSettingInConfig
Implementation of column vector and the associated operations.
static void displayFrame(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color=vpColor::none, unsigned int thickness=1, const vpImagePoint &offset=vpImagePoint(0, 0))
void setLod(const bool use_lod)
virtual void initFaceFromLines(vpMbtPolygon &polygon)=0
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.
virtual void computeCovarianceMatrixVVS(const bool isoJoIdentity_, const vpColVector &w_true, const vpHomogeneousMatrix &cMoPrev, const vpMatrix &L_true, const vpMatrix &LVJ_true, const vpColVector &error)
Contains an M-Estimator and various influence function.
error that can be emited by the vpMatrix class and its derivates
virtual vpColVector getEstimatedDoF() const
vpPoseVector buildFrom(const double tx, const double ty, const double tz, const double tux, const double tuy, const double tuz)
virtual void setClipping(const unsigned int &flags)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void addPolygon(const std::vector< vpPoint > &corners, const int idFace=-1, const std::string &polygonName="", const bool useLod=false, const double minPolygonAreaThreshold=2500.0, const double minLineLengthThreshold=50.0)
static vpColVector crossProd(const vpColVector &a, const vpColVector &b)
This class defines the container for a plane geometrical structure.
unsigned int clippingFlag
Flags specifying which clipping to used.
virtual void initFromPoints(const vpImage< unsigned char > &I, const std::string &initFile)
double computeResidual(const vpHomogeneousMatrix &cMo) const
Compute and return the residual expressed in meter for the pose matrix 'cMo'.
virtual void setFarClippingDistance(const double &dist)
void addPoint(const vpPoint &P)
void savePose(const std::string &filename) const
unsigned int getWidth() const
void computeJTR(const vpMatrix &J, const vpColVector &R, vpColVector &JTR) const
double distNearClip
Distance for near clipping.
bool useLodGeneral
True if LOD mode is enabled.
virtual void extractFaces(SoVRMLIndexedFaceSet *face_set, vpHomogeneousMatrix &transform, int &idFace, const std::string &polygonName="")
Class that consider the case of a translation vector.
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)
bool isoJoIdentity
Boolean to know if oJo is identity (for fast computation)
virtual std::pair< std::vector< vpPolygon >, std::vector< std::vector< vpPoint > > > getPolygonFaces(const bool orderPolygons=true, const bool useVisibility=true, const bool clipPolygon=false)
void removeComment(std::ifstream &fileId)
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, const double radius, const int idFace=0, const std::string &name="")=0
void setMinLineLengthThresh(const double min_line_length)
void resize(const unsigned int i, const bool flagNullify=true)
virtual void setIndex(const int i)
virtual void setLod(const bool useLod, const std::string &name="")
virtual void setNearClippingDistance(const double &dist)