44#include <visp3/core/vpConfig.h>
45#if defined(VISP_HAVE_SIMDLIB)
46#include <Simd/SimdLib.h>
49#include <visp3/core/vpColVector.h>
50#include <visp3/core/vpDebug.h>
51#include <visp3/core/vpDisplay.h>
52#include <visp3/core/vpMath.h>
53#include <visp3/core/vpMatrix.h>
54#include <visp3/core/vpPoint.h>
55#include <visp3/vision/vpPose.h>
56#ifdef VISP_HAVE_MODULE_GUI
57#include <visp3/gui/vpDisplayFactory.h>
59#include <visp3/core/vpCameraParameters.h>
60#include <visp3/core/vpColor.h>
61#include <visp3/core/vpException.h>
62#include <visp3/core/vpIoTools.h>
63#include <visp3/core/vpPixelMeterConversion.h>
64#ifdef VISP_HAVE_MODULE_IO
65#include <visp3/io/vpImageIo.h>
67#include <visp3/core/vpCPUFeatures.h>
68#include <visp3/core/vpIoTools.h>
69#include <visp3/core/vpMatrixException.h>
70#include <visp3/core/vpTrackingException.h>
71#include <visp3/mbt/vpMbTracker.h>
73#include <visp3/core/vpImageFilter.h>
74#include <visp3/mbt/vpMbtXmlGenericParser.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(VISP_HAVE_THREADS)
98#ifndef DOXYGEN_SHOULD_SKIP_THIS
101#if defined(VISP_HAVE_THREADS)
102std::mutex g_mutex_cout;
109 SegmentInfo() : extremities(), name(), useLod(false), minLineLengthThresh(0.) { }
111 std::vector<vpPoint> extremities;
114 double minLineLengthThresh;
121struct PolygonFaceInfo
123 PolygonFaceInfo(
double dist,
const vpPolygon &poly,
const std::vector<vpPoint> &corners)
124 : distanceToCamera(dist), polygon(poly), faceCorners(corners)
127 bool operator<(
const PolygonFaceInfo &pfi)
const {
return distanceToCamera < pfi.distanceToCamera; }
129 double distanceToCamera;
131 std::vector<vpPoint> faceCorners;
141std::istream &safeGetline(std::istream &is, std::string &t)
151 std::istream::sentry se(is,
true);
152 std::streambuf *sb = is.rdbuf();
155 int c = sb->sbumpc();
159 else if (c ==
'\r') {
160 if (sb->sgetc() ==
'\n')
164 else if (c == std::streambuf::traits_type::eof()) {
167 is.setstate(std::ios::eofbit);
171 t +=
static_cast<char>(c);
225 m_cam = tracker.m_cam;
226 m_cMo = tracker.m_cMo;
238 faces = tracker.faces;
310#if defined(VISP_HAVE_COIN3D) && (COIN_MAJOR_VERSION >= 2)
318#ifdef VISP_HAVE_MODULE_GUI
327 std::string ext =
".init";
328 std::string str_pose =
"";
329 size_t pos = initFile.rfind(ext);
332 std::fstream finitpos;
333 std::stringstream ss;
335 if (pos != std::string::npos)
336 str_pose = initFile.substr(0, pos) +
".0.pos";
338 str_pose = initFile +
".0.pos";
340 finitpos.open(str_pose.c_str(), std::ios::in);
347 if (finitpos.fail()) {
348 std::cout <<
"Cannot read " << ss.str() << std::endl <<
"cMo set to identity" << std::endl;
352 for (
unsigned int i = 0; i < 6; i += 1) {
353 finitpos >> init_pos[i];
359 std::cout <<
"Tracker initial pose read from " << ss.str() <<
": " << std::endl << last_cMo << std::endl;
374 std::cout <<
"No modification : left click " << std::endl;
375 std::cout <<
"Modify initial pose : right click " << std::endl;
388 vpDisplay::displayText(*I_color, 15*display_scaling, 10*display_scaling,
"Left click to validate, right click to modify initial pose",
417#ifdef VISP_HAVE_MODULE_IO
421 const std::string imgExtVec[] = {
".ppm",
".pgm",
".jpg",
".jpeg",
".png" };
423 bool foundHelpImg =
false;
424 if (pos != std::string::npos) {
425 for (
size_t i = 0; i < 5 && !foundHelpImg; i++) {
426 dispF = initFile.substr(0, pos) + imgExtVec[i];
431 for (
size_t i = 0; i < 5 && !foundHelpImg; i++) {
432 dispF = initFile + imgExtVec[i];
438 std::cout <<
"Load image to help initialization: " << dispF << std::endl;
444#if defined(VISP_HAVE_DISPLAY)
447 unsigned int width = I !=
nullptr ? I->getWidth() : I_color->
getWidth();
448 d_help->init(Iref, winXPos +
static_cast<int>(width) + 80, winYPos,
"Where to initialize...");
456 if (d_help !=
nullptr) {
466 ss.str(std::string());
472 if (pos != std::string::npos) {
480 std::vector<vpPoint> points_3D;
481 std::vector<std::string> vectorOfInitFilename;
483 loadInitFile(ss.str(), vectorOfInitFilename,
true, od_M_o, points_3D);
485 bool isWellInit =
false;
486 while (!isWellInit) {
487 std::vector<vpImagePoint> mem_ip;
488 for (
unsigned int i = 0;
i < points_3D.size();
i++) {
489 std::ostringstream text;
490 text <<
"Click on point " <<
i + 1;
495 for (
unsigned int k = 0; k < mem_ip.size(); k++) {
504 for (
unsigned int k = 0; k < mem_ip.size(); k++) {
510 std::cout <<
"Click on point " <<
i + 1 <<
" ";
514 mem_ip.push_back(ip);
519 mem_ip.push_back(ip);
523 points_3D[
i].set_x(x);
524 points_3D[
i].set_y(y);
526 std::cout <<
"with 2D coordinates: " << ip << std::endl;
565 vpDisplay::displayText(*I_color, 15*display_scaling, 10*display_scaling,
"Left click to validate, right click to re initialize object",
595 if (d_help !=
nullptr) {
601 std::cout <<
"cMo : " << std::endl <<
m_cMo << std::endl;
624 std::cout <<
"Load 3D points from: " << init_file << std::endl;
626#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
627 finit.open(init_file);
629 finit.open(init_file.c_str());
632 std::cout <<
"Cannot read init file: " << init_file << std::endl;
638 vectorOfInitFilename.push_back(init_file);
642 const std::string prefix_load =
"load";
648 while ((c ==
'l') || (c ==
'L')) {
649 getline(finit, line);
652 if (!line.compare(0, prefix_load.size(), prefix_load)) {
654 std::string paramsStr = line.substr(5);
656 paramsStr = paramsStr.substr(0, paramsStr.find_first_of(
")"));
660 for (
size_t i = 0; i < params.size(); i++) {
663 if (!params.empty()) {
665 std::string headerPathRead = params[0];
666 headerPathRead = headerPathRead.substr(1);
667 headerPathRead = headerPathRead.substr(0, headerPathRead.find_first_of(
"\""));
669 std::string headerPath = headerPathRead;
684 for (
size_t i = 1; i < params.size(); i++) {
685 std::string param = params[i];
687 const std::string prefix =
"t=[";
688 if (!param.compare(0, prefix.size(), prefix)) {
689 param = param.substr(prefix.size());
690 param = param.substr(0, param.find_first_of(
"]"));
693 if (values.size() == 3) {
694 t[0] = atof(values[0].c_str());
695 t[1] = atof(values[1].c_str());
696 t[2] = atof(values[2].c_str());
701 const std::string prefix =
"tu=[";
702 if (!param.compare(0, prefix.size(), prefix)) {
703 param = param.substr(prefix.size());
704 param = param.substr(0, param.find_first_of(
"]"));
707 if (values.size() == 3) {
709 for (
size_t j = 0; j < values.size(); j++) {
710 std::string value = values[j];
712 size_t unitPos = value.find(
"deg");
713 if (unitPos != std::string::npos) {
714 value = value.substr(0, unitPos);
718 unitPos = value.find(
"rad");
719 if (unitPos != std::string::npos) {
720 value = value.substr(0, unitPos);
722 tu[
static_cast<unsigned int>(j)] = !radian ?
vpMath::rad(atof(value.c_str())) : atof(value.c_str());
729 const std::string prefix =
"R=[";
730 if (!param.compare(0, prefix.size(), prefix)) {
731 param = param.substr(prefix.size());
732 param = param.substr(0, param.find_first_of(
"]"));
735 if (values.size() == 9) {
736 R[0][0] = atof(values[0].c_str());
737 R[0][1] = atof(values[1].c_str());
738 R[0][2] = atof(values[2].c_str());
739 R[1][0] = atof(values[3].c_str());
740 R[1][1] = atof(values[4].c_str());
741 R[1][2] = atof(values[5].c_str());
742 R[2][0] = atof(values[6].c_str());
743 R[2][1] = atof(values[7].c_str());
744 R[2][2] = atof(values[8].c_str());
751 for (std::vector<std::string>::const_iterator it = vectorOfInitFilename.begin();
752 it != vectorOfInitFilename.end() && !cyclic; ++it) {
753 if (headerPath == *it) {
761 loadInitFile(headerPath, vectorOfInitFilename,
false, od_M_o * o_M_o_from_init, points_3D);
769 std::cout <<
"WARNING Cyclic dependency detected with file " << headerPath <<
" declared in " << init_file
787 unsigned int nb_points = 0;
789 finit.ignore(std::numeric_limits<std::streamsize>::max(), finit.widen(
'\n'));
791 if (parent && !header) {
792#if defined(VISP_HAVE_THREADS)
793 std::lock_guard<std::mutex> lock(g_mutex_cout);
795 std::cout <<
"> " << nb_points <<
" init points" << std::endl;
798 std::cout <<
"Number of 3D points for interactive init: " << nb_points << std::endl;
806 if (nb_points == 0 && !header) {
811 for (
unsigned int i = 0; i < nb_points; i++) {
819 finit.ignore(256,
'\n');
822 std::cout <<
"Point " << i + 1 +
m_nbInitPoints <<
" with 3D coordinates: " << pt_3d_tf[0] <<
" " << pt_3d_tf[1] <<
" "
823 << pt_3d_tf[2] << std::endl;
827 points_3D.push_back(P);
867 initClick(&I,
nullptr, initFile, displayHelp, T);
904 initClick(
nullptr, &I_color, initFile, displayHelp, T);
908 const std::vector<vpPoint> &points3D_list,
const std::string &displayFile)
922 std::vector<vpPoint> P;
923 for (
unsigned int i = 0; i < points3D_list.size(); i++)
924 P.push_back(
vpPoint(points3D_list[i].get_oX(), points3D_list[i].get_oY(), points3D_list[i].get_oZ()));
926#ifdef VISP_HAVE_MODULE_IO
931 std::cout <<
"Load image to help initialization: " << displayFile << std::endl;
932#if defined(VISP_HAVE_X11)
934#elif defined(VISP_HAVE_GDI)
936#elif defined VISP_HAVE_OPENCV
941#if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)
943 d_help->init(Iref, I->
display->
getWindowXPosition() +
static_cast<int>(I->getWidth()) + 80, I->display->getWindowYPosition(),
944 "Where to initialize...");
955 if (d_help !=
nullptr) {
966 bool isWellInit =
false;
967 while (!isWellInit) {
968 for (
unsigned int i = 0; i < points3D_list.size(); i++) {
969 std::cout <<
"Click on point " << i + 1 << std::endl;
985 std::cout <<
"Click on point " << ip << std::endl;
1027 vpDisplay::displayText(*I_color, 15*display_scaling, 10*display_scaling,
"left click to validate, right click to re initialize object",
1054 if (d_help !=
nullptr) {
1079 const std::string &displayFile)
1081 initClick(&I,
nullptr, points3D_list, displayFile);
1096 const std::string &displayFile)
1098 initClick(
nullptr, &I_color, points3D_list, displayFile);
1103 const std::string &initFile)
1105 std::stringstream ss;
1108 std::string ext =
".init";
1109 size_t pos = initFile.rfind(ext);
1111 if (pos == initFile.size() - ext.size() && pos != 0) {
1119 std::cout <<
"Load 2D/3D points from: " << ss.str() << std::endl;
1120 finit.open(ss.str().c_str(), std::ios::in);
1122 std::cout <<
"cannot read " << ss.str() << std::endl;
1132 while (!finit.fail() && (c ==
'#')) {
1133 finit.ignore(256,
'\n');
1140 finit.ignore(256,
'\n');
1141 std::cout <<
"Number of 3D points " << n3d << std::endl;
1148 for (
unsigned int i = 0; i < n3d; i++) {
1151 while (!finit.fail() && (c ==
'#')) {
1152 finit.ignore(256,
'\n');
1160 finit.ignore(256,
'\n');
1162 std::cout <<
"Point " << i + 1 <<
" with 3D coordinates: " << X <<
" " << Y <<
" " << Z << std::endl;
1171 while (!finit.fail() && (c ==
'#')) {
1172 finit.ignore(256,
'\n');
1179 finit.ignore(256,
'\n');
1180 std::cout <<
"Number of 2D points " << n2d << std::endl;
1190 "In %s file, number of 2D points %d and number of 3D "
1191 "points %d are not equal",
1192 ss.str().c_str(), n2d, n3d);
1196 for (
unsigned int i = 0; i < n2d; i++) {
1199 while (!finit.fail() && (c ==
'#')) {
1200 finit.ignore(256,
'\n');
1204 double u, v, x = 0, y = 0;
1207 finit.ignore(256,
'\n');
1210 std::cout <<
"Point " << i + 1 <<
" with 2D coordinates: " << ip << std::endl;
1291 const std::vector<vpImagePoint> &points2D_list,
1292 const std::vector<vpPoint> &points3D_list)
1294 if (points2D_list.size() != points3D_list.size())
1295 vpERROR_TRACE(
"vpMbTracker::initFromPoints(), Number of 2D points "
1296 "different to the number of 3D points.");
1298 size_t size = points3D_list.size();
1299 std::vector<vpPoint> P;
1302 for (
size_t i = 0; i < size; i++) {
1303 P.push_back(
vpPoint(points3D_list[i].get_oX(), points3D_list[i].get_oY(), points3D_list[i].get_oZ()));
1304 double x = 0, y = 0;
1331 const std::vector<vpPoint> &points3D_list)
1345 const std::vector<vpPoint> &points3D_list)
1351 const std::string &initFile)
1353 std::stringstream ss;
1357 std::string ext =
".pos";
1358 size_t pos = initFile.rfind(ext);
1360 if (pos == initFile.size() - ext.size() && pos != 0) {
1368 finit.open(ss.str().c_str(), std::ios::in);
1370 std::cout <<
"Cannot read " << ss.str() << std::endl;
1374 for (
unsigned int i = 0; i < 6; i += 1) {
1375 finit >> init_pos[i];
1378 m_cMo.buildFrom(init_pos);
1493 std::fstream finitpos;
1494 finitpos.open(filename.c_str(), std::ios::out);
1497 finitpos << init_pos;
1502 bool useLod,
double minPolygonAreaThreshold,
double minLineLengthThreshold)
1504 std::vector<vpPoint> corners_without_duplicates;
1505 corners_without_duplicates.push_back(corners[0]);
1506 for (
unsigned int i = 0; i < corners.size() - 1; i++) {
1507 if (std::fabs(corners[i].get_oX() - corners[i + 1].get_oX()) >
1508 std::fabs(corners[i].get_oX()) * std::numeric_limits<double>::epsilon() ||
1509 std::fabs(corners[i].get_oY() - corners[i + 1].get_oY()) >
1510 std::fabs(corners[i].get_oY()) * std::numeric_limits<double>::epsilon() ||
1511 std::fabs(corners[i].get_oZ() - corners[i + 1].get_oZ()) >
1512 std::fabs(corners[i].get_oZ()) * std::numeric_limits<double>::epsilon()) {
1513 corners_without_duplicates.push_back(corners[i + 1]);
1518 polygon.
setNbPoint(
static_cast<unsigned int>(corners_without_duplicates.size()));
1519 polygon.
setIndex(
static_cast<int>(idFace));
1540 for (
unsigned int j = 0; j < corners_without_duplicates.size(); j++) {
1541 polygon.
addPoint(j, corners_without_duplicates[j]);
1544 faces.addPolygon(&polygon);
1557 const std::string &polygonName,
bool useLod,
double minPolygonAreaThreshold)
1590 y[0] = plane.
getA() / norm_Y;
1591 y[1] = plane.
getB() / norm_Y;
1592 y[2] = plane.
getC() / norm_Y;
1595 for (
unsigned int i = 0; i < 3; i++) {
1611 for (
unsigned int i = 0; i < 4; i++) {
1614 w_p = wMc * cMc_90 * c_p;
1624 faces.addPolygon(&polygon);
1637 bool useLod,
double minLineLengthThreshold)
1662 faces.addPolygon(&polygon);
1675 const std::string &polygonName,
bool useLod,
double minLineLengthThreshold)
1678 for (
unsigned int i = 0; i < listFaces.size(); i++) {
1680 polygon.
setNbPoint(
static_cast<unsigned int>(listFaces[i].size()));
1681 for (
unsigned int j = 0; j < listFaces[i].size(); j++)
1682 polygon.
addPoint(j, listFaces[i][j]);
1691 faces.addPolygon(&polygon);
1723 std::string::const_iterator it;
1726 it = modelFile.end();
1727 if ((*(it - 1) ==
'o' && *(it - 2) ==
'a' && *(it - 3) ==
'c' && *(it - 4) ==
'.') ||
1728 (*(it - 1) ==
'O' && *(it - 2) ==
'A' && *(it - 3) ==
'C' && *(it - 4) ==
'.')) {
1729 std::vector<std::string> vectorOfModelFilename;
1730 int startIdFace =
static_cast<int>(
faces.size());
1737 loadCAOModel(modelFile, vectorOfModelFilename, startIdFace, verbose,
true, od_M_o);
1739 else if ((*(it - 1) ==
'l' && *(it - 2) ==
'r' && *(it - 3) ==
'w' && *(it - 4) ==
'.') ||
1740 (*(it - 1) ==
'L' && *(it - 2) ==
'R' && *(it - 3) ==
'W' && *(it - 4) ==
'.')) {
1775#ifdef VISP_HAVE_COIN3D
1780 SbBool ok = in.openFile(modelFile.c_str());
1781 SoVRMLGroup *sceneGraphVRML2;
1788 if (!in.isFileVRML2()) {
1789 SoSeparator *sceneGraph = SoDB::readAll(&in);
1790 if (sceneGraph ==
nullptr) {
1794 SoToVRML2Action tovrml2;
1795 tovrml2.apply(sceneGraph);
1797 sceneGraphVRML2 = tovrml2.getVRML2SceneGraph();
1798 sceneGraphVRML2->ref();
1799 sceneGraph->unref();
1802 sceneGraphVRML2 = SoDB::readAllVRML(&in);
1803 if (sceneGraphVRML2 ==
nullptr) {
1805 sceneGraphVRML2->ref();
1811 int indexFace =
static_cast<int>(
faces.size());
1814 sceneGraphVRML2->unref();
1816 vpERROR_TRACE(
"coin not detected with ViSP, cannot load model : %s", modelFile.c_str());
1830 while (!fileId.fail() && ((c ==
'#') || (c ==
'\n') || (c ==
'\r'))) {
1832 fileId.ignore(std::numeric_limits<std::streamsize>::max(), fileId.widen(
'\n'));
1836 if (fileId.fail()) {
1844 std::map<std::string, std::string> mapOfParams;
1847 while (!endLine.empty() && !exit) {
1853 std::string param(it->first +
"=");
1856 if (endLine.compare(0, param.size(), param) == 0) {
1858 endLine = endLine.substr(param.size());
1860 bool parseQuote =
false;
1861 if (it->second ==
"string") {
1863 if (endLine.size() > 2 && endLine[0] ==
'"') {
1865 endLine = endLine.substr(1);
1866 size_t pos = endLine.find_first_of(
'"');
1868 if (pos != std::string::npos) {
1869 mapOfParams[it->first] = endLine.substr(0, pos);
1870 endLine = endLine.substr(pos + 1);
1881 size_t pos1 = endLine.find_first_of(
' ');
1882 size_t pos2 = endLine.find_first_of(
'\t');
1883 size_t pos = pos1 < pos2 ? pos1 : pos2;
1885 mapOfParams[it->first] = endLine.substr(0, pos);
1886 endLine = endLine.substr(pos + 1);
1946 const unsigned int maxDataCAO = 100000;
1948 std::ifstream fileId;
1949 fileId.exceptions(std::ifstream::failbit | std::ifstream::eofbit);
1950 fileId.open(modelFile.c_str(), std::ifstream::in);
1951 if (fileId.fail()) {
1952 std::cout <<
"Cannot open CAO model file: " << modelFile << std::endl;
1957 std::cout <<
"Model file : " << modelFile << std::endl;
1959 vectorOfModelFilename.push_back(modelFile);
1970 fileId >> caoVersion;
1971 fileId.ignore(std::numeric_limits<std::streamsize>::max(), fileId.widen(
'\n'));
1975 std::cout <<
"in vpMbTracker::loadCAOModel() -> Bad parameter header file : use V0, V1, ...";
1977 "header file : use V0, V1, ...");
1984 const std::string prefix_load =
"load";
1988 bool header =
false;
1989 while ((c ==
'l') || (c ==
'L')) {
1990 getline(fileId, line);
1993 if (!line.compare(0, prefix_load.size(), prefix_load)) {
1995 std::string paramsStr = line.substr(5);
1997 paramsStr = paramsStr.substr(0, paramsStr.find_first_of(
")"));
2001 for (
size_t i = 0; i < params.size(); i++) {
2005 if (!params.empty()) {
2007 std::string headerPathRead = params[0];
2008 headerPathRead = headerPathRead.substr(1);
2009 headerPathRead = headerPathRead.substr(0, headerPathRead.find_first_of(
"\""));
2011 std::string headerPath = headerPathRead;
2026 for (
size_t i = 1; i < params.size(); i++) {
2027 std::string param = params[i];
2029 const std::string prefix =
"t=[";
2030 if (!param.compare(0, prefix.size(), prefix)) {
2031 param = param.substr(prefix.size());
2032 param = param.substr(0, param.find_first_of(
"]"));
2035 if (values.size() == 3) {
2036 t[0] = atof(values[0].c_str());
2037 t[1] = atof(values[1].c_str());
2038 t[2] = atof(values[2].c_str());
2043 const std::string prefix =
"tu=[";
2044 if (!param.compare(0, prefix.size(), prefix)) {
2045 param = param.substr(prefix.size());
2046 param = param.substr(0, param.find_first_of(
"]"));
2049 if (values.size() == 3) {
2051 for (
size_t j = 0; j < values.size(); j++) {
2052 std::string value = values[j];
2054 size_t unitPos = value.find(
"deg");
2055 if (unitPos != std::string::npos) {
2056 value = value.substr(0, unitPos);
2060 unitPos = value.find(
"rad");
2061 if (unitPos != std::string::npos) {
2062 value = value.substr(0, unitPos);
2064 tu[
static_cast<unsigned int>(j)] = !radian ?
vpMath::rad(atof(value.c_str())) : atof(value.c_str());
2071 const std::string prefix =
"R=[";
2072 if (!param.compare(0, prefix.size(), prefix)) {
2073 param = param.substr(prefix.size());
2074 param = param.substr(0, param.find_first_of(
"]"));
2077 if (values.size() == 9) {
2078 R[0][0] = atof(values[0].c_str());
2079 R[0][1] = atof(values[1].c_str());
2080 R[0][2] = atof(values[2].c_str());
2081 R[1][0] = atof(values[3].c_str());
2082 R[1][1] = atof(values[4].c_str());
2083 R[1][2] = atof(values[5].c_str());
2084 R[2][0] = atof(values[6].c_str());
2085 R[2][1] = atof(values[7].c_str());
2086 R[2][2] = atof(values[8].c_str());
2092 bool cyclic =
false;
2093 for (std::vector<std::string>::const_iterator it = vectorOfModelFilename.begin();
2094 it != vectorOfModelFilename.end() && !cyclic; ++it) {
2095 if (headerPath == *it) {
2103 loadCAOModel(headerPath, vectorOfModelFilename, startIdFace, verbose,
false, od_M_o * o_M_o_from_cao);
2111 std::cout <<
"WARNING Cyclic dependency detected with file " << headerPath <<
" declared in " << modelFile
2132 unsigned int caoNbrPoint;
2133 fileId >> caoNbrPoint;
2134 fileId.ignore(std::numeric_limits<std::streamsize>::max(), fileId.widen(
'\n'));
2137 if (verbose || (parent && !header)) {
2138#if defined(VISP_HAVE_THREADS)
2139 std::lock_guard<std::mutex> lock(g_mutex_cout);
2141 std::cout <<
"> " << caoNbrPoint <<
" points" << std::endl;
2144 if (caoNbrPoint > maxDataCAO) {
2149 if (caoNbrPoint == 0 && !header) {
2153 std::vector<vpPoint> caoPoints(caoNbrPoint);
2155 for (
unsigned int k = 0; k < caoNbrPoint; k++) {
2163 if (caoVersion == 2) {
2170 fileId.ignore(std::numeric_limits<std::streamsize>::max(), fileId.widen(
'\n'));
2173 caoPoints[k].setWorldCoordinates(pt_3d_tf[0], pt_3d_tf[1], pt_3d_tf[2]);
2180 std::map<std::pair<unsigned int, unsigned int>, SegmentInfo> segmentTemporaryMap;
2181 unsigned int caoNbrLine;
2182 fileId >> caoNbrLine;
2183 fileId.ignore(std::numeric_limits<std::streamsize>::max(), fileId.widen(
'\n'));
2186 std::vector<unsigned int> caoLinePoints;
2187 if (verbose || (parent && !header)) {
2188#if defined(VISP_HAVE_THREADS)
2189 std::lock_guard<std::mutex> lock(g_mutex_cout);
2191 std::cout <<
"> " << caoNbrLine <<
" lines" << std::endl;
2194 if (caoNbrLine > maxDataCAO) {
2200 caoLinePoints.resize(2 * caoNbrLine);
2202 unsigned int index1, index2;
2205 int idFace = startIdFace;
2207 for (
unsigned int k = 0; k < caoNbrLine; k++) {
2215 std::string endLine =
"";
2216 if (safeGetline(fileId, endLine).good()) {
2217 std::map<std::string, std::string> mapOfParams =
parseParameters(endLine);
2219 std::string segmentName =
"";
2222 if (mapOfParams.find(
"name") != mapOfParams.end()) {
2223 segmentName = mapOfParams[
"name"];
2225 if (mapOfParams.find(
"minLineLengthThreshold") != mapOfParams.end()) {
2226 minLineLengthThresh = std::atof(mapOfParams[
"minLineLengthThreshold"].c_str());
2228 if (mapOfParams.find(
"useLod") != mapOfParams.end()) {
2232 SegmentInfo segmentInfo;
2233 segmentInfo.name = segmentName;
2234 segmentInfo.useLod = useLod;
2235 segmentInfo.minLineLengthThresh = minLineLengthThresh;
2237 caoLinePoints[2 * k] = index1;
2238 caoLinePoints[2 * k + 1] = index2;
2240 if (index1 < caoNbrPoint && index2 < caoNbrPoint) {
2241 std::vector<vpPoint> extremities;
2242 extremities.push_back(caoPoints[index1]);
2243 extremities.push_back(caoPoints[index2]);
2244 segmentInfo.extremities = extremities;
2246 std::pair<unsigned int, unsigned int> key(index1, index2);
2248 segmentTemporaryMap[key] = segmentInfo;
2251 vpTRACE(
" line %d has wrong coordinates.", k);
2263 std::vector<std::pair<unsigned int, unsigned int> > faceSegmentKeyVector;
2264 unsigned int caoNbrPolygonLine;
2265 fileId >> caoNbrPolygonLine;
2266 fileId.ignore(std::numeric_limits<std::streamsize>::max(), fileId.widen(
'\n'));
2269 if (verbose || (parent && !header)) {
2270#if defined(VISP_HAVE_THREADS)
2271 std::lock_guard<std::mutex> lock(g_mutex_cout);
2273 std::cout <<
"> " << caoNbrPolygonLine <<
" polygon lines" << std::endl;
2276 if (caoNbrPolygonLine > maxDataCAO) {
2282 for (
unsigned int k = 0; k < caoNbrPolygonLine; k++) {
2285 unsigned int nbLinePol;
2286 fileId >> nbLinePol;
2287 std::vector<vpPoint> corners;
2288 if (nbLinePol > maxDataCAO) {
2293 for (
unsigned int n = 0; n < nbLinePol; n++) {
2296 if (index >= caoNbrLine) {
2300 corners.push_back(caoPoints[caoLinePoints[2 * index]]);
2301 corners.push_back(caoPoints[caoLinePoints[2 * index + 1]]);
2303 std::pair<unsigned int, unsigned int> key(caoLinePoints[2 * index], caoLinePoints[2 * index + 1]);
2304 faceSegmentKeyVector.push_back(key);
2309 std::string endLine =
"";
2310 if (safeGetline(fileId, endLine).good()) {
2311 std::map<std::string, std::string> mapOfParams =
parseParameters(endLine);
2313 std::string polygonName =
"";
2316 if (mapOfParams.find(
"name") != mapOfParams.end()) {
2317 polygonName = mapOfParams[
"name"];
2319 if (mapOfParams.find(
"minPolygonAreaThreshold") != mapOfParams.end()) {
2320 minPolygonAreaThreshold = std::atof(mapOfParams[
"minPolygonAreaThreshold"].c_str());
2322 if (mapOfParams.find(
"useLod") != mapOfParams.end()) {
2336 for (std::map<std::pair<unsigned int, unsigned int>, SegmentInfo>::const_iterator it = segmentTemporaryMap.begin();
2337 it != segmentTemporaryMap.end(); ++it) {
2338 if (std::find(faceSegmentKeyVector.begin(), faceSegmentKeyVector.end(), it->first) ==
2339 faceSegmentKeyVector.end()) {
2341 it->second.minLineLengthThresh);
2354 unsigned int caoNbrPolygonPoint;
2355 fileId >> caoNbrPolygonPoint;
2356 fileId.ignore(std::numeric_limits<std::streamsize>::max(), fileId.widen(
'\n'));
2359 if (verbose || (parent && !header)) {
2360#if defined(VISP_HAVE_THREADS)
2361 std::lock_guard<std::mutex> lock(g_mutex_cout);
2363 std::cout <<
"> " << caoNbrPolygonPoint <<
" polygon points" << std::endl;
2366 if (caoNbrPolygonPoint > maxDataCAO) {
2371 for (
unsigned int k = 0; k < caoNbrPolygonPoint; k++) {
2374 unsigned int nbPointPol;
2375 fileId >> nbPointPol;
2376 if (nbPointPol > maxDataCAO) {
2380 std::vector<vpPoint> corners;
2381 for (
unsigned int n = 0; n < nbPointPol; n++) {
2383 if (index > caoNbrPoint - 1) {
2387 corners.push_back(caoPoints[index]);
2392 std::string endLine =
"";
2393 if (safeGetline(fileId, endLine).good()) {
2394 std::map<std::string, std::string> mapOfParams =
parseParameters(endLine);
2396 std::string polygonName =
"";
2399 if (mapOfParams.find(
"name") != mapOfParams.end()) {
2400 polygonName = mapOfParams[
"name"];
2402 if (mapOfParams.find(
"minPolygonAreaThreshold") != mapOfParams.end()) {
2403 minPolygonAreaThreshold = std::atof(mapOfParams[
"minPolygonAreaThreshold"].c_str());
2405 if (mapOfParams.find(
"useLod") != mapOfParams.end()) {
2419 unsigned int caoNbCylinder;
2428 fileId >> caoNbCylinder;
2429 fileId.ignore(std::numeric_limits<std::streamsize>::max(), fileId.widen(
'\n'));
2432 if (verbose || (parent && !header)) {
2433#if defined(VISP_HAVE_THREADS)
2434 std::lock_guard<std::mutex> lock(g_mutex_cout);
2436 std::cout <<
"> " << caoNbCylinder <<
" cylinders" << std::endl;
2439 if (caoNbCylinder > maxDataCAO) {
2444 for (
unsigned int k = 0; k < caoNbCylinder; ++k) {
2448 unsigned int indexP1, indexP2;
2455 std::string endLine =
"";
2456 if (safeGetline(fileId, endLine).good()) {
2457 std::map<std::string, std::string> mapOfParams =
parseParameters(endLine);
2459 std::string polygonName =
"";
2462 if (mapOfParams.find(
"name") != mapOfParams.end()) {
2463 polygonName = mapOfParams[
"name"];
2465 if (mapOfParams.find(
"minLineLengthThreshold") != mapOfParams.end()) {
2466 minLineLengthThreshold = std::atof(mapOfParams[
"minLineLengthThreshold"].c_str());
2468 if (mapOfParams.find(
"useLod") != mapOfParams.end()) {
2472 int idRevolutionAxis = idFace;
2473 addPolygon(caoPoints[indexP1], caoPoints[indexP2], idFace, polygonName, useLod, minLineLengthThreshold);
2476 minLineLengthThreshold);
2478 std::vector<std::vector<vpPoint> > listFaces;
2480 addPolygon(listFaces, idFace, polygonName, useLod, minLineLengthThreshold);
2482 initCylinder(caoPoints[indexP1], caoPoints[indexP2], radius, idRevolutionAxis, polygonName);
2492 catch (
const std::exception &e) {
2493 std::cerr <<
"Cannot get the number of cylinders. Defaulting to zero." << std::endl;
2494 std::cerr <<
"Exception: " << e.what() << std::endl;
2499 unsigned int caoNbCircle;
2513 fileId.get(c_circle);
2514 int nb_circles = c_circle -
'0';
2515 if (nb_circles > 0) {
2519 fileId >> caoNbCircle;
2520 fileId.ignore(std::numeric_limits<std::streamsize>::max(), fileId.widen(
'\n'));
2523 if (verbose || (parent && !header)) {
2524#if defined(VISP_HAVE_THREADS)
2525 std::lock_guard<std::mutex> lock(g_mutex_cout);
2527 std::cout <<
"> " << caoNbCircle <<
" circles" << std::endl;
2530 if (caoNbCircle > maxDataCAO) {
2535 for (
unsigned int k = 0; k < caoNbCircle; ++k) {
2539 unsigned int indexP1, indexP2, indexP3;
2547 std::string endLine =
"";
2548 if (safeGetline(fileId, endLine).good()) {
2549 std::map<std::string, std::string> mapOfParams =
parseParameters(endLine);
2551 std::string polygonName =
"";
2554 if (mapOfParams.find(
"name") != mapOfParams.end()) {
2555 polygonName = mapOfParams[
"name"];
2557 if (mapOfParams.find(
"minPolygonAreaThreshold") != mapOfParams.end()) {
2558 minPolygonAreaThreshold = std::atof(mapOfParams[
"minPolygonAreaThreshold"].c_str());
2560 if (mapOfParams.find(
"useLod") != mapOfParams.end()) {
2564 addPolygon(caoPoints[indexP1], caoPoints[indexP2], caoPoints[indexP3], radius, idFace, polygonName, useLod,
2565 minPolygonAreaThreshold);
2567 initCircle(caoPoints[indexP1], caoPoints[indexP2], caoPoints[indexP3], radius, idFace, polygonName);
2570 polygonName, useLod, minPolygonAreaThreshold);
2577 catch (
const std::exception &e) {
2578 std::cerr <<
"Cannot get the number of circles. Defaulting to zero." << std::endl;
2579 std::cerr <<
"Exception: " << e.what() << std::endl;
2583 startIdFace = idFace;
2585 if (header && parent) {
2587#if defined(VISP_HAVE_THREADS)
2588 std::lock_guard<std::mutex> lock(g_mutex_cout);
2590 std::cout <<
"Global information for " <<
vpIoTools::getName(modelFile) <<
" :" << std::endl;
2591 std::cout <<
"Total nb of points : " <<
nbPoints << std::endl;
2592 std::cout <<
"Total nb of lines : " <<
nbLines << std::endl;
2593 std::cout <<
"Total nb of polygon lines : " <<
nbPolygonLines << std::endl;
2594 std::cout <<
"Total nb of polygon points : " <<
nbPolygonPoints << std::endl;
2595 std::cout <<
"Total nb of cylinders : " <<
nbCylinders << std::endl;
2596 std::cout <<
"Total nb of circles : " <<
nbCircles << std::endl;
2599#if defined(VISP_HAVE_THREADS)
2600 std::lock_guard<std::mutex> lock(g_mutex_cout);
2602 std::cout <<
"> " <<
nbPoints <<
" points" << std::endl;
2603 std::cout <<
"> " <<
nbLines <<
" lines" << std::endl;
2604 std::cout <<
"> " <<
nbPolygonLines <<
" polygon lines" << std::endl;
2605 std::cout <<
"> " <<
nbPolygonPoints <<
" polygon points" << std::endl;
2606 std::cout <<
"> " <<
nbCylinders <<
" cylinders" << std::endl;
2607 std::cout <<
"> " <<
nbCircles <<
" circles" << std::endl;
2612 vectorOfModelFilename.pop_back();
2616 catch (
const std::exception &e) {
2618 std::cerr <<
"Cannot read line!" << std::endl;
2619 std::cerr <<
"Exception: " << e.what() << std::endl;
2624#ifdef VISP_HAVE_COIN3D
2635 SoVRMLTransform *sceneGraphVRML2Trasnform =
dynamic_cast<SoVRMLTransform *
>(sceneGraphVRML2);
2636 if (sceneGraphVRML2Trasnform) {
2637 float rx, ry, rz, rw;
2638 sceneGraphVRML2Trasnform->rotation.getValue().getValue(rx, ry, rz, rw);
2644 tx = sceneGraphVRML2Trasnform->translation.getValue()[0];
2645 ty = sceneGraphVRML2Trasnform->translation.getValue()[1];
2646 tz = sceneGraphVRML2Trasnform->translation.getValue()[2];
2652 sx = sceneGraphVRML2Trasnform->scale.getValue()[0];
2653 sy = sceneGraphVRML2Trasnform->scale.getValue()[1];
2654 sz = sceneGraphVRML2Trasnform->scale.getValue()[2];
2658 for (
unsigned int i = 0; i < 3; i++)
2660 for (
unsigned int i = 0; i < 3; i++)
2662 for (
unsigned int i = 0; i < 3; i++)
2666 transform = transform * transformCur;
2669 int nbShapes = sceneGraphVRML2->getNumChildren();
2676 for (
int i = 0; i < nbShapes; i++) {
2678 child = sceneGraphVRML2->getChild(i);
2680 if (child->getTypeId() == SoVRMLGroup::getClassTypeId()) {
2681 extractGroup((SoVRMLGroup *)child, transform_recursive, idFace);
2684 if (child->getTypeId() == SoVRMLTransform::getClassTypeId()) {
2685 extractGroup((SoVRMLTransform *)child, transform_recursive, idFace);
2688 if (child->getTypeId() == SoVRMLShape::getClassTypeId()) {
2689 SoChildList *child2list = child->getChildren();
2690 std::string name = child->getName().getString();
2692 for (
int j = 0; j < child2list->getLength(); j++) {
2693 if (((SoNode *)child2list->get(j))->getTypeId() == SoVRMLIndexedFaceSet::getClassTypeId()) {
2694 SoVRMLIndexedFaceSet *face_set;
2695 face_set = (SoVRMLIndexedFaceSet *)child2list->get(j);
2696 if (!strncmp(face_set->getName().getString(),
"cyl", 3)) {
2703 if (((SoNode *)child2list->get(j))->getTypeId() == SoVRMLIndexedLineSet::getClassTypeId()) {
2704 SoVRMLIndexedLineSet *line_set;
2705 line_set = (SoVRMLIndexedLineSet *)child2list->get(j);
2723 const std::string &polygonName)
2725 std::vector<vpPoint> corners;
2729 int indexListSize = face_set->coordIndex.getNum();
2733 SoVRMLCoordinate *coord;
2735 for (
int i = 0; i < indexListSize; i++) {
2736 if (face_set->coordIndex[i] == -1) {
2737 if (corners.size() > 1) {
2747 coord = (SoVRMLCoordinate *)(face_set->coord.getValue());
2748 int index = face_set->coordIndex[i];
2749 pointTransformed[0] = coord->point[index].getValue()[0];
2750 pointTransformed[1] = coord->point[index].getValue()[1];
2751 pointTransformed[2] = coord->point[index].getValue()[2];
2752 pointTransformed[3] = 1.0;
2754 pointTransformed = transform * pointTransformed;
2757 corners.push_back(pt);
2777 const std::string &polygonName)
2779 std::vector<vpPoint> corners_c1, corners_c2;
2782 SoVRMLCoordinate *coords = (SoVRMLCoordinate *)face_set->coord.getValue();
2784 unsigned int indexListSize =
static_cast<unsigned int>(coords->point.getNum());
2786 if (indexListSize % 2 == 1) {
2787 std::cout <<
"Not an even number of points when extracting a cylinder." << std::endl;
2790 corners_c1.resize(indexListSize / 2);
2791 corners_c2.resize(indexListSize / 2);
2797 for (
int i = 0; i < coords->point.getNum(); ++i) {
2798 pointTransformed[0] = coords->point[i].getValue()[0];
2799 pointTransformed[1] = coords->point[i].getValue()[1];
2800 pointTransformed[2] = coords->point[i].getValue()[2];
2801 pointTransformed[3] = 1.0;
2803 pointTransformed = transform * pointTransformed;
2807 if (i <
static_cast<int>(corners_c1.size())) {
2808 corners_c1[
static_cast<unsigned int>(i)] = pt;
2811 corners_c2[
static_cast<unsigned int>(i) - corners_c1.size()] = pt;
2819 dist[0] = p1.
get_oX() - corners_c1[0].get_oX();
2820 dist[1] = p1.
get_oY() - corners_c1[0].get_oY();
2821 dist[2] = p1.
get_oZ() - corners_c1[0].get_oZ();
2822 double radius_c1 = sqrt(dist.
sumSquare());
2823 dist[0] = p2.
get_oX() - corners_c2[0].get_oX();
2824 dist[1] = p2.
get_oY() - corners_c2[0].get_oY();
2825 dist[2] = p2.
get_oZ() - corners_c2[0].get_oZ();
2826 double radius_c2 = sqrt(dist.
sumSquare());
2828 if (std::fabs(radius_c1 - radius_c2) >
2829 (std::numeric_limits<double>::epsilon() *
vpMath::maximum(radius_c1, radius_c2))) {
2830 std::cout <<
"Radius from the two circles of the cylinders are different." << std::endl;
2837 int idRevolutionAxis = idFace;
2842 std::vector<std::vector<vpPoint> > listFaces;
2846 initCylinder(p1, p2, radius_c1, idRevolutionAxis, polygonName);
2864 std::vector<vpPoint> corners;
2867 int indexListSize = line_set->coordIndex.getNum();
2869 SbVec3f point(0, 0, 0);
2871 SoVRMLCoordinate *coord;
2873 for (
int i = 0; i < indexListSize; i++) {
2874 if (line_set->coordIndex[i] == -1) {
2875 if (corners.size() > 1) {
2885 coord = (SoVRMLCoordinate *)(line_set->coord.getValue());
2886 int index = line_set->coordIndex[i];
2887 point[0] = coord->point[index].getValue()[0];
2888 point[1] = coord->point[index].getValue()[1];
2889 point[2] = coord->point[index].getValue()[2];
2892 corners.push_back(pt);
2911 std::cout <<
"Cannot extract center of gravity of empty set." << std::endl;
2919 for (
unsigned int i = 0; i < pts.size(); ++i) {
2920 oX += pts[i].get_oX();
2921 oY += pts[i].get_oY();
2922 oZ += pts[i].get_oZ();
2941std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > >
2945 std::vector<vpPolygon> polygonsTmp;
2946 std::vector<std::vector<vpPoint> > roisPtTmp;
2949 std::pair<std::vector<vpPolygon>, std::vector<std::vector<vpPoint> > > pairOfPolygonFaces;
2951 for (
unsigned int i = 0; i <
faces.getPolygon().size(); i++) {
2953 if (
faces.getPolygon()[i]->nbpt > 2) {
2954 if ((useVisibility &&
faces.getPolygon()[i]->isvisible) || !useVisibility) {
2955 std::vector<vpImagePoint> roiPts;
2964 if (roiPts.size() <= 2) {
2968 polygonsTmp.push_back(
vpPolygon(roiPts));
2970 std::vector<vpPoint> polyPts;
2972 faces.getPolygon()[i]->getPolygonClipped(polyPts);
2975 for (
unsigned int j = 0; j <
faces.getPolygon()[i]->nbpt; j++) {
2976 polyPts.push_back(
faces.getPolygon()[i]->p[j]);
2979 roisPtTmp.push_back(polyPts);
2984 if (orderPolygons) {
2986 std::vector<PolygonFaceInfo> listOfPolygonFaces;
2987 for (
unsigned int i = 0; i < polygonsTmp.size(); i++) {
2988 double x_centroid = 0.0, y_centroid = 0.0, z_centroid = 0.0;
2989 for (
unsigned int j = 0; j < roisPtTmp[i].size(); j++) {
2990 x_centroid += roisPtTmp[i][j].get_X();
2991 y_centroid += roisPtTmp[i][j].get_Y();
2992 z_centroid += roisPtTmp[i][j].get_Z();
2995 x_centroid /= roisPtTmp[i].size();
2996 y_centroid /= roisPtTmp[i].size();
2997 z_centroid /= roisPtTmp[i].size();
2999 double squared_dist = x_centroid * x_centroid + y_centroid * y_centroid + z_centroid * z_centroid;
3000 listOfPolygonFaces.push_back(PolygonFaceInfo(squared_dist, polygonsTmp[i], roisPtTmp[i]));
3004 std::sort(listOfPolygonFaces.begin(), listOfPolygonFaces.end());
3006 polygonsTmp.resize(listOfPolygonFaces.size());
3007 roisPtTmp.resize(listOfPolygonFaces.size());
3010 for (std::vector<PolygonFaceInfo>::const_iterator it = listOfPolygonFaces.begin(); it != listOfPolygonFaces.end();
3012 polygonsTmp[cpt] = it->polygon;
3013 roisPtTmp[cpt] = it->faceCorners;
3016 pairOfPolygonFaces.first = polygonsTmp;
3017 pairOfPolygonFaces.second = roisPtTmp;
3020 pairOfPolygonFaces.first = polygonsTmp;
3021 pairOfPolygonFaces.second = roisPtTmp;
3024 return pairOfPolygonFaces;
3038#ifndef VISP_HAVE_OGRE
3040 std::cout <<
"WARNING: ViSP doesn't have Ogre3D, basic visibility test "
3041 "will be used. setOgreVisibilityTest() set to false."
3055 vpTRACE(
"Far clipping value cannot be inferior than near clipping value. "
3056 "Far clipping won't be considered.");
3058 vpTRACE(
"Far clipping value cannot be inferior than 0. Far clipping "
3059 "won't be considered.");
3063 for (
unsigned int i = 0; i <
faces.size(); i++) {
3066#ifdef VISP_HAVE_OGRE
3084 for (
unsigned int i = 0; i <
faces.size(); i++) {
3085 if (name.empty() ||
faces[i]->name == name) {
3086 faces[i]->setLod(useLod);
3102 for (
unsigned int i = 0; i <
faces.size(); i++) {
3103 if (name.empty() ||
faces[i]->name == name) {
3104 faces[i]->setMinLineLengthThresh(minLineLengthThresh);
3119 for (
unsigned int i = 0; i <
faces.size(); i++) {
3120 if (name.empty() ||
faces[i]->name == name) {
3121 faces[i]->setMinPolygonAreaThresh(minPolygonAreaThresh);
3134 vpTRACE(
"Near clipping value cannot be superior than far clipping value. "
3135 "Near clipping won't be considered.");
3137 vpTRACE(
"Near clipping value cannot be inferior than 0. Near clipping "
3138 "won't be considered.");
3142 for (
unsigned int i = 0; i <
faces.size(); i++) {
3145#ifdef VISP_HAVE_OGRE
3161 for (
unsigned int i = 0; i <
faces.size(); i++)
3175 if (isoJoIdentity) {
3198 if (interaction.
getRows() != error.getRows() || interaction.
getCols() != 6) {
3203#if defined(VISP_HAVE_SIMDLIB)
3204 SimdComputeJtR(interaction.
data, interaction.
getRows(), error.data, JTR.
data);
3206 const unsigned int N = interaction.
getRows();
3208 for (
unsigned int i = 0; i < 6; i += 1) {
3210 for (
unsigned int j = 0; j < N; j += 1) {
3211 ssum += interaction[j][i] * error[j];
3220 double &mu,
bool &reStartFromLastIncrement,
vpColVector *
const w,
3224 if (error.sumSquare() /
static_cast<double>(error.getRows()) > m_error_prev.
sumSquare() /
static_cast<double>(m_error_prev.
getRows())) {
3231 error = m_error_prev;
3232 if (w !=
nullptr && m_w_prev !=
nullptr) {
3235 reStartFromLastIncrement =
true;
3245 if (isoJoIdentity) {
3253 vpMatrix LTLmuI = LTL + (LMA * mu);
3260 if (w !=
nullptr && m_w_prev !=
nullptr)
3283 vpMatrix LTLmuI = LVJTLVJ + (LMA * mu);
3291 if (w !=
nullptr && m_w_prev !=
nullptr)
3306 if (error.getRows() > 0)
3324 for (
unsigned int i = 0; i < 6; i++)
3346 if (v.getRows() == 6) {
3348 for (
unsigned int i = 0; i < 6; i++) {
3350 if (std::fabs(v[i]) > std::numeric_limits<double>::epsilon()) {
3362 std::vector<std::vector<vpPoint> > &listFaces)
3384 if (axisOrtho.
frobeniusNorm() < std::numeric_limits<double>::epsilon()) {
3388 if (axisOrtho.
frobeniusNorm() < std::numeric_limits<double>::epsilon()) {
3392 if (axisOrtho.
frobeniusNorm() < std::numeric_limits<double>::epsilon())
3422 std::vector<vpPoint> pointsFace;
3423 pointsFace.push_back(
vpPoint(fc1[0], fc1[1], fc1[2]));
3424 pointsFace.push_back(
vpPoint(sc1[0], sc1[1], sc1[2]));
3425 pointsFace.push_back(
vpPoint(sc2[0], sc2[1], sc2[2]));
3426 pointsFace.push_back(
vpPoint(fc2[0], fc2[1], fc2[2]));
3427 listFaces.push_back(pointsFace);
3430 pointsFace.push_back(
vpPoint(fc2[0], fc2[1], fc2[2]));
3431 pointsFace.push_back(
vpPoint(sc2[0], sc2[1], sc2[2]));
3432 pointsFace.push_back(
vpPoint(sc3[0], sc3[1], sc3[2]));
3433 pointsFace.push_back(
vpPoint(fc3[0], fc3[1], fc3[2]));
3434 listFaces.push_back(pointsFace);
3437 pointsFace.push_back(
vpPoint(fc3[0], fc3[1], fc3[2]));
3438 pointsFace.push_back(
vpPoint(sc3[0], sc3[1], sc3[2]));
3439 pointsFace.push_back(
vpPoint(sc4[0], sc4[1], sc4[2]));
3440 pointsFace.push_back(
vpPoint(fc4[0], fc4[1], fc4[2]));
3441 listFaces.push_back(pointsFace);
3444 pointsFace.push_back(
vpPoint(fc4[0], fc4[1], fc4[2]));
3445 pointsFace.push_back(
vpPoint(sc4[0], sc4[1], sc4[2]));
3446 pointsFace.push_back(
vpPoint(sc1[0], sc1[1], sc1[2]));
3447 pointsFace.push_back(
vpPoint(fc1[0], fc1[1], fc1[2]));
3448 listFaces.push_back(pointsFace);
3466 if (dx <= std::numeric_limits<double>::epsilon() && dy <= std::numeric_limits<double>::epsilon() &&
3467 dz <= std::numeric_limits<double>::epsilon())
3474 const std::string &polygonName,
bool useLod,
double minPolygonAreaThreshold,
3475 double minLineLengthThreshold)
3477 std::vector<vpPoint> corners_without_duplicates;
3478 corners_without_duplicates.push_back(corners[0]);
3479 for (
unsigned int i = 0; i < corners.size() - 1; i++) {
3480 if (std::fabs(corners[i].get_oX() - corners[i + 1].get_oX()) >
3481 std::fabs(corners[i].get_oX()) * std::numeric_limits<double>::epsilon() ||
3482 std::fabs(corners[i].get_oY() - corners[i + 1].get_oY()) >
3483 std::fabs(corners[i].get_oY()) * std::numeric_limits<double>::epsilon() ||
3484 std::fabs(corners[i].get_oZ() - corners[i + 1].get_oZ()) >
3485 std::fabs(corners[i].get_oZ()) * std::numeric_limits<double>::epsilon()) {
3486 corners_without_duplicates.push_back(corners[i + 1]);
3491 polygon.
setNbPoint(
static_cast<unsigned int>(corners_without_duplicates.size()));
3492 polygon.
setIndex(
static_cast<int>(idFace));
3499 for (
unsigned int j = 0; j < corners_without_duplicates.size(); j++) {
3500 polygon.
addPoint(j, corners_without_duplicates[j]);
3516 int idFace,
const std::string &polygonName,
bool useLod,
3517 double minPolygonAreaThreshold)
3544 y[0] = plane.
getA() / norm_Y;
3545 y[1] = plane.
getB() / norm_Y;
3546 y[2] = plane.
getC() / norm_Y;
3549 for (
unsigned int i = 0; i < 3; i++) {
3565 for (
unsigned int i = 0; i < 4; i++) {
3568 w_p = wMc * cMc_90 * c_p;
3591 const std::string &polygonName,
bool useLod,
double minLineLengthThreshold)
3623 const std::string &polygonName,
bool useLod,
double minLineLengthThreshold)
3626 for (
unsigned int i = 0; i < listFaces.size(); i++) {
3628 polygon.
setNbPoint(
static_cast<unsigned int>(listFaces[i].size()));
3629 for (
unsigned int j = 0; j < listFaces[i].size(); j++)
3630 polygon.
addPoint(j, listFaces[i][j]);
3657 bool already_here =
false;
3664 already_here =
true;
3670 if (!already_here) {
3697 int idFace,
const std::string &name)
3699 bool already_here =
false;
3712 if (!already_here) {
3728 const std::string &name)
3730 bool already_here =
false;
3743 if (!already_here) {
3758 int idFace,
const std::string &name)
3764 const std::string &name)
3773 for (
unsigned int i = 0; i < nbpt - 1; i++)
3783 for (
unsigned int i = 0; i < nbpt - 1; i++)
3812 unsigned int nbFeatures = 0;
3815 if (nbFeatures > 0) {
3816 return vpMath::deg(totalProjectionError /
static_cast<double>(nbFeatures));
3848#ifdef VISP_HAVE_OGRE
3879 double totalProjectionError = 0.0;
3884 for (
size_t a = 0; a < l->
meline.size(); a++) {
3885 if (l->
meline[a] !=
nullptr) {
3886 double lineNormGradient;
3887 unsigned int lineNbFeatures;
3891 totalProjectionError += lineNormGradient;
3892 nbFeatures += lineNbFeatures;
3903 double cylinderNormGradient = 0;
3904 unsigned int cylinderNbFeatures = 0;
3908 totalProjectionError += cylinderNormGradient;
3909 nbFeatures += cylinderNbFeatures;
3913 double cylinderNormGradient = 0;
3914 unsigned int cylinderNbFeatures = 0;
3918 totalProjectionError += cylinderNormGradient;
3919 nbFeatures += cylinderNbFeatures;
3928 double circleNormGradient = 0;
3929 unsigned int circleNbFeatures = 0;
3933 totalProjectionError += circleNormGradient;
3934 nbFeatures += circleNbFeatures;
3938 return totalProjectionError;
3943 bool changed =
false;
3950#ifdef VISP_HAVE_OGRE
3964 for (
size_t a = 0; a < (*it)->meline.size(); a++) {
3965 if ((*it)->meline[a] !=
nullptr) {
3966 delete (*it)->meline[a];
3967 (*it)->meline[a] =
nullptr;
3971 (*it)->meline.clear();
3972 (*it)->nbFeature.clear();
3973 (*it)->nbFeatureTotal = 0;
3978 if ((*it)->meline1 !=
nullptr) {
3979 delete (*it)->meline1;
3980 (*it)->meline1 =
nullptr;
3982 if ((*it)->meline2 !=
nullptr) {
3983 delete (*it)->meline2;
3984 (*it)->meline2 =
nullptr;
3987 (*it)->nbFeature = 0;
3988 (*it)->nbFeaturel1 = 0;
3989 (*it)->nbFeaturel2 = 0;
3994 if ((*it)->meEllipse !=
nullptr) {
3995 delete (*it)->meEllipse;
3996 (*it)->meEllipse =
nullptr;
3998 (*it)->nbFeature = 0;
4004 const bool doNotTrack =
true;
4009 bool isvisible =
false;
4013 int index = *itindex;
4034 for (
size_t a = 0; a < l->
meline.size(); a++) {
4035 if (l->
meline[a] !=
nullptr)
4037 if (a < l->nbFeature.size())
4050 bool isvisible =
false;
4085 bool isvisible =
false;
4114#if defined(VISP_HAVE_PUGIXML)
4122 std::cout <<
" *********** Parsing XML for ME projection error ************ " << std::endl;
4124 xmlp.
parse(configFile);
4179 m_SobelX.resize(size * 2 + 1, size * 2 + 1,
false,
false);
4182 m_SobelY.resize(size * 2 + 1, size * 2 + 1,
false,
false);
unsigned int getCols() const
Type * data
Address of the first element of the data array.
unsigned int getRows() const
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
vpColVector & normalize()
static vpColVector crossProd(const vpColVector &a, const vpColVector &b)
double frobeniusNorm() const
void resize(unsigned int i, bool flagNullify=true)
static const vpColor green
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Class that defines generic functionalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
int getWindowXPosition() const
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), const std::string &frameName="", const vpColor &textColor=vpColor::black, const vpImagePoint &textOffset=vpImagePoint(15, 15))
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
int getWindowYPosition() const
static void flush(const vpImage< unsigned char > &I)
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
unsigned int getDownScalingFactor()
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
@ dimensionError
Bad dimension.
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix & buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static FilterType getSobelKernelX(FilterType *filter, unsigned int size)
static FilterType getSobelKernelY(FilterType *filter, unsigned int size)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
unsigned int getWidth() const
Provides simple mathematics computation tools that are not available in the C mathematics library (ma...
static double rad(double deg)
static Type maximum(const Type &a, const Type &b)
static double sqr(double x)
static double deg(double rad)
error that can be emitted by the vpMatrix class and its derivatives
@ incorrectMatrixSizeError
Incorrect matrix size.
Implementation of a matrix and operations on matrices.
void diag(const double &val=1.0)
static vpMatrix computeCovarianceMatrixVVS(const vpHomogeneousMatrix &cMo, const vpColVector &deltaS, const vpMatrix &Ls, const vpMatrix &W)
vpMatrix pseudoInverse(double svThreshold=1e-6) const
bool isVisible(unsigned int i)
std::map< std::string, std::string > parseParameters(std::string &endLine)
virtual double computeCurrentProjectionError(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo, const vpCameraParameters &_cam)
double m_lambda
Gain of the virtual visual servoing stage.
virtual vpColVector getEstimatedDoF() const
double computeProjectionErrorImpl(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo, const vpCameraParameters &_cam, unsigned int &nbFeatures)
virtual void setEstimatedDoF(const vpColVector &v)
void addProjectionErrorLine(vpPoint &p1, vpPoint &p2, int polygon=-1, std::string name="")
vpCameraParameters m_projectionErrorCam
Camera parameters used for projection error computation.
unsigned int nbPolygonPoints
Number of polygon points in CAO model.
virtual void extractFaces(SoVRMLIndexedFaceSet *face_set, vpHomogeneousMatrix &transform, int &idFace, const std::string &polygonName="")
double minLineLengthThresholdGeneral
Minimum line length threshold for LOD mode (general setting).
bool m_projectionErrorDisplay
Display gradient and model orientation for projection error computation.
void projectionErrorResetMovingEdges()
void initProjectionErrorCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace=0, const std::string &name="")
@ LEVENBERG_MARQUARDT_OPT
virtual void extractCylinders(SoVRMLIndexedFaceSet *face_set, vpHomogeneousMatrix &transform, int &idFace, const std::string &polygonName="")
virtual void setMinLineLengthThresh(double minLineLengthThresh, const std::string &name="")
vpImage< unsigned char > m_I
Grayscale image buffer, used when passing color images.
unsigned int m_projectionErrorDisplayLength
Length of the arrows used to show the gradient and model orientation.
std::vector< vpMbtDistanceCylinder * > m_projectionErrorCylinders
Distance cylinder primitives for projection error.
virtual void loadCAOModel(const std::string &modelFile, std::vector< std::string > &vectorOfModelFilename, int &startIdFace, bool verbose=false, bool parent=true, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
virtual void init(const vpImage< unsigned char > &I)=0
virtual void initFromPoints(const vpImage< unsigned char > &I, const std::string &initFile)
bool samePoint(const vpPoint &P1, const vpPoint &P2) const
bool useLodGeneral
True if LOD mode is enabled.
double minPolygonAreaThresholdGeneral
Minimum polygon area threshold for LOD mode (general setting).
std::map< std::string, std::string > mapOfParameterNames
bool m_computeInteraction
vpMatrix oJo
The Degrees of Freedom to estimate.
virtual void loadVRMLModel(const std::string &modelFile)
unsigned int nbLines
Number of lines in CAO model.
virtual void setMinPolygonAreaThresh(double minPolygonAreaThresh, const std::string &name="")
virtual void initFaceFromLines(vpMbtPolygon &polygon)=0
void savePose(const std::string &filename) const
void addPolygon(const std::vector< vpPoint > &corners, int idFace=-1, const std::string &polygonName="", bool useLod=false, double minPolygonAreaThreshold=2500.0, double minLineLengthThreshold=50.0)
vpUniRand m_rand
Random number generator used in vpMbtDistanceLine::buildFrom().
vpMatrix covarianceMatrix
Covariance matrix.
double m_initialMu
Initial Mu for Levenberg Marquardt optimization loop.
vpHomogeneousMatrix m_cMo
The current pose.
virtual void initCircle(const vpPoint &p1, const vpPoint &p2, const vpPoint &p3, double radius, int idFace=0, const std::string &name="")=0
vpMatrix m_SobelX
Sobel kernel in X.
virtual void initCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="")=0
virtual void computeVVSCheckLevenbergMarquardt(unsigned int iter, vpColVector &error, const vpColVector &m_error_prev, const vpHomogeneousMatrix &cMoPrev, double &mu, bool &reStartFromLastIncrement, vpColVector *const w=nullptr, const vpColVector *const m_w_prev=nullptr)
unsigned int nbPoints
Number of points in CAO model.
vpCameraParameters m_cam
The camera parameters.
double m_stopCriteriaEpsilon
Epsilon threshold to stop the VVS optimization loop.
std::string modelFileName
bool useOgre
Use Ogre3d for global visibility tests.
virtual void computeVVSWeights(vpRobust &robust, const vpColVector &error, vpColVector &w)
vpMbHiddenFaces< vpMbtPolygon > faces
Set of faces describing the object.
void projectionErrorInitMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &_cMo)
std::vector< vpMbtDistanceCircle * > m_projectionErrorCircles
Distance circle primitive for projection error.
virtual void setOgreVisibilityTest(const bool &v)
std::string poseSavingFilename
void setProjectionErrorKernelSize(const unsigned int &size)
void loadInitFile(const std::string &initFile, std::vector< std::string > &vectorOfInitFilename, bool parent, const vpHomogeneousMatrix &T, std::vector< vpPoint > &P)
void initProjectionErrorCylinder(const vpPoint &p1, const vpPoint &p2, double radius, int idFace=0, const std::string &name="")
virtual void initClick(const vpImage< unsigned char > &I, const std::string &initFile, bool displayHelp=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())
unsigned int nbPolygonLines
Number of polygon lines in CAO model.
virtual void setLod(bool useLod, const std::string &name="")
unsigned int m_projectionErrorDisplayThickness
Thickness of the arrows used to show the gradient and model orientation.
virtual void computeCovarianceMatrixVVS(const bool isoJoIdentity, const vpColVector &w_true, const vpHomogeneousMatrix &cMoPrev, const vpMatrix &L_true, const vpMatrix &LVJ_true, const vpColVector &error)
vpMbtOptimizationMethod m_optimizationMethod
Optimization method used.
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=nullptr, vpColVector *const m_w_prev=nullptr)
bool displayFeatures
If true, the features are displayed.
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &od_M_o=vpHomogeneousMatrix())
double angleDisappears
Angle used to detect a face disappearance.
virtual void setNearClippingDistance(const double &dist)
void setProjectionErrorMovingEdge(const vpMe &me)
bool applyLodSettingInConfig
virtual void setFarClippingDistance(const double &dist)
double distFarClip
Distance for near clipping.
bool m_isoJoIdentity
Boolean to know if oJo is identity (for fast computation).
void projectionErrorVisibleFace(unsigned int width, unsigned int height, const vpHomogeneousMatrix &_cMo)
unsigned int m_maxInitPoints
Max allowed number of points in init file.
void removeCommentsAndEmptyLines(std::ifstream &fileId)
bool useScanLine
Use Scanline for global visibility tests.
void computeJTR(const vpMatrix &J, const vpColVector &R, vpColVector &JTR) const
void addProjectionErrorCylinder(const vpPoint &P1, const vpPoint &P2, double r, int idFace=-1, const std::string &name="")
vpMatrix m_SobelY
Sobel kernel in Y.
virtual void setClipping(const unsigned int &flags)
double angleAppears
Angle used to detect a face appearance.
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)=0
bool m_projectionErrorOgreShowConfigDialog
void initProjectionErrorFaceFromCorners(vpMbtPolygon &polygon)
virtual void extractGroup(SoVRMLGroup *sceneGraphVRML2, vpHomogeneousMatrix &transform, int &idFace)
const vpImage< bool > * m_mask
Mask used to disable tracking on a part of image.
virtual void initFromPose(const vpImage< unsigned char > &I, const std::string &initFile)
void addProjectionErrorPolygon(const std::vector< vpPoint > &corners, int idFace=-1, const std::string &polygonName="", bool useLod=false, double minPolygonAreaThreshold=2500.0, const double minLineLengthThreshold=50.0)
unsigned int m_nbInitPoints
Number of points in init file.
bool computeCovariance
Flag used to specify if the covariance matrix has to be computed or not.
void initProjectionErrorFaceFromLines(vpMbtPolygon &polygon)
virtual void extractLines(SoVRMLIndexedLineSet *line_set, int &idFace, const std::string &polygonName="")
virtual std::pair< std::vector< vpPolygon >, std::vector< std::vector< vpPoint > > > getPolygonFaces(bool orderPolygons=true, bool useVisibility=true, bool clipPolygon=false)
std::vector< vpMbtDistanceLine * > m_projectionErrorLines
Distance line primitives for projection error.
double distNearClip
Distance for near clipping.
bool m_sodb_init_called
Flag that indicates that SoDB::init(); was called.
unsigned int m_maxIter
Maximum number of iterations of the virtual visual servoing stage.
bool ogreShowConfigDialog
vpMbTracker & operator=(const vpMbTracker &tracker)
void addProjectionErrorCircle(const vpPoint &P1, const vpPoint &P2, const vpPoint &P3, double r, int idFace=-1, const std::string &name="")
unsigned int nbCylinders
Number of cylinders in CAO model.
unsigned int clippingFlag
Flags specifying which clipping to used.
unsigned int m_projectionErrorKernelSize
Kernel size used to compute the gradient orientation.
unsigned int nbCircles
Number of circles in CAO model.
vpPoint getGravityCenter(const std::vector< vpPoint > &_pts) const
vpMe m_projectionErrorMe
Moving-Edges parameters for projection error.
vpMbHiddenFaces< vpMbtPolygon > m_projectionErrorFaces
Set of faces describing the object, used for projection error.
virtual void initFaceFromCorners(vpMbtPolygon &polygon)=0
void createCylinderBBox(const vpPoint &p1, const vpPoint &p2, const double &radius, std::vector< std::vector< vpPoint > > &listFaces)
virtual void loadConfigFile(const std::string &configFile, bool verbose=true)
Manage a circle used in the model-based tracker.
void setVisible(bool _isvisible)
void setMovingEdge(vpMe *Me)
void setCameraParameters(const vpCameraParameters &camera)
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
vpPoint * p1
The center of the circle.
unsigned int nbFeature
The number of moving edges.
void setIndex(unsigned int i)
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, const vpPoint &_p3, double r)
vpPoint * p2
A point on the plane containing the circle.
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, bool doNotTrack, const vpImage< bool > *mask=nullptr, const int &initRange=1U)
double radius
The radius of the circle.
int index_polygon
Index of the faces which contain the line.
vpPoint * p3
An other point on the plane containing the circle.
vpMbtMeEllipse * meEllipse
The moving edge containers.
void setName(const std::string &circle_name)
Manage a cylinder used in the model-based tracker.
void buildFrom(const vpPoint &_p1, const vpPoint &_p2, double r)
void setCameraParameters(const vpCameraParameters &camera)
void setName(const std::string &cyl_name)
vpMbtMeLine * meline2
The moving edge containers (second line of the cylinder).
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, bool doNotTrack, const vpImage< bool > *mask=nullptr, const int &initRange=0)
void setVisible(bool _isvisible)
unsigned int nbFeaturel2
The number of moving edges on line 2.
vpPoint * p2
The second extremity on the axe.
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void setMovingEdge(vpMe *Me)
double radius
The radius of the cylinder.
unsigned int nbFeaturel1
The number of moving edges on line 1.
unsigned int nbFeature
The number of moving edges.
int index_polygon
Index of the face which contains the cylinder.
void setIndex(unsigned int i)
vpPoint * p1
The first extremity on the axe.
vpMbtMeLine * meline1
The moving edge containers (first line of the cylinder).
Manage the line of a polygon used in the model-based tracker.
void setMovingEdge(vpMe *Me)
std::vector< unsigned int > nbFeature
The number of moving edges.
bool initMovingEdge(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, bool doNotTrack, const vpImage< bool > *mask=nullptr, const int &initRange=0)
void setIndex(unsigned int i)
vpPoint * p2
The second extremity.
std::list< int > Lindex_polygon
Index of the faces which contain the line.
void buildFrom(vpPoint &_p1, vpPoint &_p2, vpUniRand &rand_gen)
unsigned int nbFeatureTotal
The number of moving edges.
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
vpMbtPolygon & getPolygon()
bool useScanLine
Use scanline rendering.
vpPoint * p1
The first extremity.
std::vector< vpMbtMeLine * > meline
The moving edge container.
void setCameraParameters(const vpCameraParameters &camera)
void setName(const std::string &line_name)
void setVisible(bool _isvisible)
void addPolygon(const int &index)
Implementation of a polygon of the model used by the model-based tracker.
void setMinPolygonAreaThresh(double min_polygon_area)
std::string getName() const
void setName(const std::string &face_name)
void setLod(bool use_lod)
virtual void setIndex(int i)
void setMinLineLengthThresh(double min_line_length)
void setIsPolygonOriented(const bool &oriented)
Parse an Xml file to extract configuration parameters of a mbtConfig object.
void setProjectionErrorMe(const vpMe &me)
unsigned int getProjectionErrorKernelSize() const
void setProjectionErrorKernelSize(const unsigned int &size)
@ PROJECTION_ERROR_PARSER
void parse(const std::string &filename)
void getProjectionErrorMe(vpMe &me) const
void setVerbose(bool verbose)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
This class defines the container for a plane geometrical structure.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
double get_oX() const
Get the point oX coordinate in the object frame.
void set_x(double x)
Set the point x coordinate in the image plane.
double get_oZ() const
Get the point oZ coordinate in the object frame.
double get_oY() const
Get the point oY coordinate in the object frame.
void setWorldCoordinates(double oX, double oY, double oZ)
void set_y(double y)
Set the point y coordinate in the image plane.
Implements a 3D polygon with render functionalities like clipping.
void setFarClippingDistance(const double &dist)
unsigned int getNbPoint() const
void setNearClippingDistance(const double &dist)
vpPoint * p
corners in the object frame
virtual void setNbPoint(unsigned int nb)
void setClipping(const unsigned int &flags)
void addPoint(unsigned int n, const vpPoint &P)
Defines a generic 2D polygon.
Implementation of a pose vector and operations on poses.
vpPoseVector & buildFrom(const double &tx, const double &ty, const double &tz, const double &tux, const double &tuy, const double &tuz)
Class used for pose computation from N points (pose from point only). Some of the algorithms implemen...
void addPoint(const vpPoint &P)
@ DEMENTHON_LAGRANGE_VIRTUAL_VS
bool computePose(vpPoseMethodType method, vpHomogeneousMatrix &cMo, FuncCheckValidityPose func=nullptr)
Implementation of a rotation vector as quaternion angle minimal representation.
Contains an M-estimator and various influence function.
@ TUKEY
Tukey influence function.
void MEstimator(const vpRobustEstimatorType method, const vpColVector &residues, vpColVector &weights)
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of a rotation vector as axis-angle minimal representation.
Error that can be emitted by the vpTracker class and its derivatives.
@ fatalError
Tracker fatal error.
Class that consider the case of a translation vector.
vpVelocityTwistMatrix & buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.