27 #include <mrpt/otherlibs/do_opencv_includes.h>
44 CFaceDetection::CFaceDetection() : m_end_threads(false)
78 cfg.
read_int(
"FaceDetection",
"confidenceThreshold", 240);
81 cfg.
read_bool(
"FaceDetection",
"useCovFilter",
true);
83 cfg.
read_bool(
"FaceDetection",
"useRegionsFilter",
true);
85 cfg.
read_bool(
"FaceDetection",
"useSizeDistanceRelationFilter",
true);
87 cfg.
read_bool(
"FaceDetection",
"useDiagonalDistanceFilter",
true);
90 cfg.
read_double(
"FaceDetection",
"planeThreshold", 50);
92 cfg.
read_double(
"FaceDetection",
"planeTest_eigenVal_top", 0.011);
94 cfg.
read_double(
"FaceDetection",
"planeTest_eigenVal_bottom", 0.0002);
96 "FaceDetection",
"regionsTest_sumDistThreshold_top", 0.5);
98 "FaceDetection",
"regionsTest_sumDistThreshold_bottom", 0.04);
102 cfg.
read_bool(
"FaceDetection",
"takeMeasures",
false);
104 cfg.
read_bool(
"FaceDetection",
"saveMeasurementsToFile",
false);
168 vector<size_t> deleteDetected;
172 for (
unsigned int i = 0; i < localDetected.size(); i++)
175 std::dynamic_pointer_cast<CDetectable2D>(localDetected[i]);
178 unsigned int r1 = rec->m_y;
179 unsigned int r2 = rec->m_y + rec->m_height;
180 unsigned int c1 = rec->m_x;
181 unsigned int c2 = rec->m_x + rec->m_width;
215 deleteDetected.push_back(i);
247 deleteDetected.push_back(i);
254 deleteDetected.push_back(i);
262 deleteDetected.push_back(i);
286 for (
unsigned int i = deleteDetected.size(); i > 0; i--)
288 localDetected.begin() + deleteDetected[i - 1]);
292 for (
unsigned int i = 0; i < localDetected.size(); i++)
296 std::dynamic_pointer_cast<CDetectable2D>(
298 detected.push_back(object3d);
308 detected = localDetected;
327 size_t N =
face->points3D_x.size();
331 for (
size_t i = 0; i < N; i++)
333 face->points3D_x.at(i),
face->points3D_y.at(i),
334 face->points3D_z.at(i));
354 obj->thread_checkIfFacePlaneCov();
386 const unsigned int faceWidth =
face->intensityImage.getWidth();
387 const unsigned int faceHeight =
face->intensityImage.getHeight();
390 const bool confidence =
face->hasConfidenceImage;
393 vector<CArrayDouble<3>> pointsVector;
398 for (
unsigned int j = 0; j < faceHeight; j++)
400 for (
unsigned int k = 0; k < faceWidth; k++)
407 (*(
face->confidenceImage.get_unsafe(k, j, 0)) >
409 (*(
face->intensityImage.get_unsafe(k, j)) >
412 int position = faceWidth * j + k;
413 aux[0] =
face->points3D_x[position];
414 aux[1] =
face->points3D_y[position];
415 aux[2] =
face->points3D_z[position];
416 pointsVector.push_back(aux);
422 if (pointsVector.empty())
return false;
433 cov.eigenValues(eVals);
435 cov.eigenVectors(eVects, m_eVals);
451 cout << eVals[0] <<
" " << eVals[1] <<
" " << eVals[2] <<
" > ";
452 cout << eVals[0] / eVals[2] << endl;
463 if (eVals[0] / eVals[2] > 0.06)
482 obj->thread_checkIfFaceRegions();
514 const unsigned int faceWidth =
face->intensityImage.getWidth();
515 const unsigned int faceHeight =
face->intensityImage.getHeight();
518 unsigned int sectionVSize = faceHeight / 3.0;
538 int numPoints[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
540 vector<TPoint3D> regions2[9];
571 if (
end == 0)
end = faceWidth - 1;
572 if (
end < 3 * (faceWidth / 4))
573 end = 3 * (faceWidth / 4);
575 if (
start > faceWidth / 4)
start = faceWidth / 4;
580 unsigned int utilWidth = faceWidth -
start - (faceWidth -
end);
581 unsigned int c1 = ceil(utilWidth / 3.0 +
start);
582 unsigned int c2 = ceil(2 * (utilWidth / 3.0) +
start);
592 face->intensityImage,
start, 0,
end, ceil(faceHeight * 0.1), hist);
594 size_t countHist = 0;
595 for (
size_t i = 0; i < 60; i++)
601 size_t downLimit = faceHeight - 1;
605 upLimit = floor(faceHeight * 0.1);
606 downLimit = floor(faceHeight * 0.9);
617 unsigned int cont = 0;
619 for (
unsigned int r = 0;
r < faceHeight;
r++)
621 for (
unsigned int c = 0;
c < faceWidth;
c++, cont++)
623 if ((
r >= upLimit) && (
r <= downLimit) &&
625 (*(
face->confidenceImage.get_unsafe(
c,
r, 0)) >
627 (*(
face->intensityImage.get_unsafe(
c,
r)) > 50))
629 unsigned int row, col;
630 if (
r < sectionVSize + upLimit * 0.3)
632 else if (
r < sectionVSize * 2 - upLimit * 0.15)
645 face->points3D_x[cont],
face->points3D_y[cont],
646 face->points3D_z[cont]);
647 meanPos[
row][col] = meanPos[
row][col] + point;
649 ++numPoints[
row][col];
651 if (
row == 0 && col == 0)
652 regions2[0].push_back(
654 face->points3D_x[cont],
face->points3D_y[cont],
655 face->points3D_z[cont]));
656 else if (
row == 0 && col == 1)
657 regions2[1].push_back(
659 face->points3D_x[cont],
face->points3D_y[cont],
660 face->points3D_z[cont]));
661 else if (
row == 0 && col == 2)
662 regions2[2].push_back(
664 face->points3D_x[cont],
face->points3D_y[cont],
665 face->points3D_z[cont]));
666 else if (
row == 1 && col == 0)
667 regions2[3].push_back(
669 face->points3D_x[cont],
face->points3D_y[cont],
670 face->points3D_z[cont]));
671 else if (
row == 1 && col == 1)
672 regions2[4].push_back(
674 face->points3D_x[cont],
face->points3D_y[cont],
675 face->points3D_z[cont]));
676 else if (
row == 1 && col == 2)
677 regions2[5].push_back(
679 face->points3D_x[cont],
face->points3D_y[cont],
680 face->points3D_z[cont]));
681 else if (
row == 2 && col == 0)
682 regions2[6].push_back(
684 face->points3D_x[cont],
face->points3D_y[cont],
685 face->points3D_z[cont]));
686 else if (
row == 2 && col == 1)
687 regions2[7].push_back(
689 face->points3D_x[cont],
face->points3D_y[cont],
690 face->points3D_z[cont]));
692 regions2[8].push_back(
694 face->points3D_x[cont],
face->points3D_y[cont],
695 face->points3D_z[cont]));
704 vector<double> oldPointsX1;
709 if (regions2[0].
size() > 0)
711 for (
size_t i = 0; i < regions2[0].size(); i++)
712 oldPointsX1.push_back(regions2[0][i].x);
714 middle1 = floor((
double)oldPointsX1.size() / 2);
716 oldPointsX1.begin(), oldPointsX1.begin() + middle1,
720 vector<double> oldPointsX2;
722 if (regions2[2].
size() > 0)
724 for (
size_t i = 0; i < regions2[2].size(); i++)
725 oldPointsX2.push_back(regions2[2][i].x);
727 middle2 = floor((
double)oldPointsX2.size() / 2);
729 oldPointsX2.begin(), oldPointsX2.begin() + middle2,
733 for (
size_t i = 0; i < 3; i++)
734 for (
size_t j = 0; j < 3; j++)
735 if (!numPoints[i][j])
738 meanPos[i][j] = meanPos[i][j] / numPoints[i][j];
740 if (regions2[0].
size() > 0) meanPos[0][0].
x = oldPointsX1.at(middle1);
742 if (regions2[2].
size() > 0) meanPos[0][2].
x = oldPointsX2.at(middle2);
747 vector<double> dist(5);
749 meanPos[1][0], meanPos[1][2], meanPos[1][1], dist[0]);
751 meanPos[2][0], meanPos[2][2], meanPos[2][1], dist[1]);
753 meanPos[0][0], meanPos[0][2], meanPos[0][1], dist[2]);
755 meanPos[0][0], meanPos[2][2], meanPos[1][1], dist[3]);
757 meanPos[2][0], meanPos[0][2], meanPos[1][1], dist[4]);
760 f.open(
"dist.txt", ofstream::app);
761 f <<
sum(dist) << endl;
767 else if ((
res = 1) && (
sum(dist) > 0.04))
770 f.open(
"tam.txt", ofstream::app);
771 f << meanPos[0][1].
distanceTo(meanPos[2][1]) << endl;
821 double yIdeal = y1 + (((
x - x1) * (y2 - y1)) / (x2 - x1));
843 obj->thread_checkIfDiagonalSurface();
879 const unsigned int faceWidth =
face->intensityImage.getWidth();
880 const unsigned int faceHeight =
face->intensityImage.getHeight();
884 unsigned int x1 = ceil(faceWidth * 0.25);
885 unsigned int x2 = floor(faceWidth * 0.75);
886 unsigned int y1 = ceil(faceHeight * 0.15);
887 unsigned int y2 = floor(faceHeight * 0.85);
890 unsigned int cont = (y1 == 0 ? 0 : faceHeight * (y1 - 1));
893 valids.
setSize(faceHeight, faceWidth);
898 for (
unsigned int i = y1; i <= y2; i++)
902 for (
unsigned int j = x1; j <= x2; j++, cont++)
904 if (*(
face->confidenceImage.get_unsafe(j, i, 0)) >
907 sumDepth +=
face->points3D_x[cont];
911 face->points3D_x[cont],
face->points3D_y[cont],
912 face->points3D_z[cont]));
915 cont += faceWidth - x2 - 1;
918 double meanDepth = sumDepth / total;
929 double maxFaceDistance = 0.5 + 1000 / (pow(faceWidth, 1.9));
946 if (maxFaceDistance < meanDepth)
969 f.open(
"relaciones2.txt", ofstream::app);
970 f << meanDepth << endl;
979 cont = (y1 == 1 ? 0 : faceHeight * (y1 - 1));
981 for (
unsigned int i = y1; i <= y2; i++)
985 for (
unsigned int j = x1; j <= x2; j++, cont++)
987 if ((*(
face->confidenceImage.get_unsafe(j, i, 0)) >
995 face->points3D_x[cont],
face->points3D_y[cont],
996 face->points3D_z[cont]));
1001 cont += faceWidth - x2 - 1;
1010 double sumDistances = 0;
1016 for (
unsigned int i = y1; i <= y2; i++)
1020 for (
unsigned int j = x1; j <= x2; j++, cont++)
1028 if ((i + 1 <= y2) && (j + 1 <= x2))
1033 face->points3D_x[cont],
face->points3D_y[cont],
1034 face->points3D_z[cont]);
1035 offsetIndex = cont + faceWidth + 1;
1038 face->points3D_x[offsetIndex],
1039 face->points3D_y[offsetIndex],
1040 face->points3D_z[offsetIndex]));
1044 bool validOffset =
true;
1054 face->points3D_x[cont],
1055 face->points3D_y[cont],
1056 face->points3D_z[cont]);
1057 offsetIndex = cont + faceWidth +
offset;
1060 face->points3D_x[offsetIndex],
1061 face->points3D_y[offsetIndex],
1062 face->points3D_z[offsetIndex]));
1068 validOffset =
false;
1076 cont += faceWidth - x2 - 1;
1085 f.open(
"distances.txt", ofstream::app);
1087 f << sumDistances << endl;
1090 f.open(
"distances2.txt", ofstream::app);
1097 double yMax = 3 + 6 / (pow(meanDepth, 2));
1098 double yMin = 1 + 3.8 / (pow(meanDepth + 1.2, 2));
1106 if (((sumDistances <= yMax) && (sumDistances >= yMin)) && (
res))
1150 const unsigned int faceWidth =
face->intensityImage.getWidth();
1151 const unsigned int faceHeight =
face->intensityImage.getHeight();
1162 for (
unsigned int row = 0;
row < faceHeight;
row++)
1164 for (
unsigned int col = 0; col < faceWidth; col++, cont++)
1167 (*(
face->confidenceImage.get_unsafe(col,
row, 0)) >
1170 sumDepth +=
face->points3D_x[cont];
1174 face->points3D_x[cont],
face->points3D_y[cont],
1175 face->points3D_z[cont]));
1180 double meanDepth = sumDepth / total;
1186 double maxFaceDistance = 0.5 + 1000 / (pow(faceWidth, 1.9));
1203 if (maxFaceDistance < meanDepth)
1226 f.open(
"relaciones2.txt", ofstream::app);
1227 f << meanDepth << endl;
1242 double sumDistances = 0;
1244 size_t offsetIndex = 0;
1248 for (
unsigned int i = 0; i < faceHeight; i++)
1250 for (
unsigned int j = 0; j < faceWidth; j++, cont++)
1255 if ((i + 1 < faceHeight) && (j + 1 < faceWidth))
1260 face->points3D_x[cont],
face->points3D_y[cont],
1261 face->points3D_z[cont]);
1262 offsetIndex = cont + faceWidth + 1;
1265 face->points3D_x[offsetIndex],
1266 face->points3D_y[offsetIndex],
1267 face->points3D_z[offsetIndex]));
1271 bool validOffset =
true;
1276 if ((i +
offset < faceHeight) &&
1277 (j +
offset < faceWidth))
1282 face->points3D_x[cont],
1283 face->points3D_y[cont],
1284 face->points3D_z[cont]);
1285 offsetIndex = cont + faceWidth +
offset;
1288 face->points3D_x[offsetIndex],
1289 face->points3D_y[offsetIndex],
1290 face->points3D_z[offsetIndex]));
1296 validOffset =
false;
1312 f.open(
"distances.txt", ofstream::app);
1314 f << sumDistances << endl;
1324 double yMax = 3 + 11.8 / (pow(meanDepth, 0.9));
1325 double yMin = 1 + 3.8 / (pow(meanDepth + 7, 6));
1333 if (((sumDistances <= yMax) && (sumDistances >= yMin)) && (
res))
1367 vector<float> xs, ys, zs;
1369 unsigned int N =
face.points3D_x.size();
1375 for (
unsigned int i = 0; i < N; i++)
1377 xs[i] =
face.points3D_x[i];
1378 ys[i] =
face.points3D_y[i];
1379 zs[i] =
face.points3D_z[i];
1390 const vector<TPoint3D>&
points)
1392 vector<float> xs, ys, zs;
1394 unsigned int N =
points.size();
1400 for (
unsigned int i = 0; i < N; i++)
1415 const vector<float>& xs,
const vector<float>& ys,
const vector<float>& zs)
1429 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
1430 gl_points->setPointSize(4.5);
1434 scene->insert(gl_points);
1435 scene->insert(mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
1441 gl_points->loadFromPointsMap(&pntsMap);
1488 vector<float> xs, ys, zs;
1490 const size_t size = pointsVector.size();
1496 for (
size_t i = 0; i <
size; i++)
1498 xs[i] = pointsVector[i][0];
1499 ys[i] = pointsVector[i][1];
1500 zs[i] = pointsVector[i][2];
1517 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
1518 gl_points->setPointSize(4.5);
1522 CSphere::Ptr sphere = mrpt::make_aligned_shared<CSphere>(0.005f);
1523 sphere->setLocation(center);
1524 sphere->setColor(
TColorf(0, 1, 0));
1525 scene->insert(sphere);
1535 eigenVect.get_unsafe(0, 0), eigenVect.get_unsafe(0, 1),
1536 eigenVect.get_unsafe(0, 2));
1538 eigenVect.get_unsafe(1, 0), eigenVect.get_unsafe(1, 1),
1539 eigenVect.get_unsafe(1, 2));
1541 eigenVect.get_unsafe(2, 0), eigenVect.get_unsafe(2, 1),
1542 eigenVect.get_unsafe(2, 2));
1546 TPoint3D p1(center + E1 * eigenVal[0] * 100);
1547 TPoint3D p2(center + E2 * eigenVal[1] * 100);
1548 TPoint3D p3(center + E3 * eigenVal[2] * 100);
1550 CArrow::Ptr arrow1 = mrpt::make_aligned_shared<CArrow>(
1551 center.
x, center.
y, center.
z, p1.
x, p1.
y, p1.
z);
1552 CArrow::Ptr arrow2 = mrpt::make_aligned_shared<CArrow>(
1553 center.
x, center.
y, center.
z, p2.
x, p2.
y, p2.
z);
1554 CArrow::Ptr arrow3 = mrpt::make_aligned_shared<CArrow>(
1555 center.
x, center.
y, center.
z, p3.
x, p3.
y, p3.
z);
1557 arrow1->setColor(
TColorf(0, 1, 0));
1558 arrow2->setColor(
TColorf(1, 0, 0));
1559 arrow3->setColor(
TColorf(0, 0, 1));
1561 scene->insert(arrow1);
1562 scene->insert(arrow2);
1563 scene->insert(arrow3);
1575 scene->insert(gl_points);
1576 scene->insert(mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
1582 gl_points->loadFromPointsMap(&pntsMap);
1595 const vector<TPoint3D> regions[9],
const TPoint3D meanPos[3][3])
1609 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
1610 gl_points->setPointSize(6);
1614 if (meanPos !=
nullptr)
1616 for (
size_t i = 0; i < 3; i++)
1617 for (
size_t j = 0; j < 3; j++)
1620 mrpt::make_aligned_shared<CSphere>(0.005f);
1621 sphere->setLocation(meanPos[i][j]);
1622 sphere->setColor(
TColorf(0, 1, 0));
1623 scene->insert(sphere);
1627 vector<TSegment3D> sgms;
1628 sgms.push_back(
TSegment3D(meanPos[0][0], meanPos[0][1]));
1629 sgms.push_back(
TSegment3D(meanPos[0][1], meanPos[0][2]));
1630 sgms.push_back(
TSegment3D(meanPos[1][0], meanPos[1][1]));
1631 sgms.push_back(
TSegment3D(meanPos[1][1], meanPos[1][2]));
1632 sgms.push_back(
TSegment3D(meanPos[2][0], meanPos[2][1]));
1633 sgms.push_back(
TSegment3D(meanPos[2][1], meanPos[2][2]));
1634 sgms.push_back(
TSegment3D(meanPos[0][0], meanPos[1][1]));
1635 sgms.push_back(
TSegment3D(meanPos[1][1], meanPos[2][2]));
1636 sgms.push_back(
TSegment3D(meanPos[2][0], meanPos[1][1]));
1637 sgms.push_back(
TSegment3D(meanPos[1][1], meanPos[0][2]));
1639 mrpt::make_aligned_shared<mrpt::opengl::CSetOfLines>(sgms);
1640 lines->setColor(0, 0, 1, 1);
1641 lines->setLineWidth(10);
1643 scene->insert(lines);
1645 scene->insert(gl_points);
1646 scene->insert(mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
1648 mrpt::make_aligned_shared<mrpt::opengl::CAxis>(
1649 -5, -5, -5, 5, 5, 5, 2.5, 3,
true));
1653 vector<float> xs, ys, zs;
1655 for (
size_t i = 0; i < 9; i++)
1656 for (
unsigned int j = 0; j < regions[i].size(); j++)
1658 xs.push_back(regions[i][j].
x);
1659 ys.push_back(regions[i][j].
y);
1660 zs.push_back(regions[i][j].
z);
1666 float colors[9][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1},
1667 {1, 1, 0}, {1, 0, 1}, {0, 1, 1},
1668 {0.5f, 0.25f, 0}, {0.5f, 0, 0.25f}, {0, 0.35f, 0.5f}};
1669 for (
size_t i = 0; i < 9; i++)
1671 float R = colors[i][0];
1672 float G = colors[i][1];
1673 float B = colors[i][2];
1675 for (
unsigned int j = 0; j < regions[i].size(); j++, cont++)
1679 gl_points->loadFromPointsMap(&pntsMap);
1695 const unsigned int faceWidth =
face.intensityImage.getWidth();
1696 const unsigned int faceHeight =
face.intensityImage.getHeight();
1698 region.
setSize(faceWidth, faceHeight,
true);
1700 unsigned int x1 = ceil(faceWidth * 0.4);
1701 unsigned int x2 = floor(faceWidth * 0.6);
1702 unsigned int y1 = ceil(faceHeight * 0.4);
1703 unsigned int y2 = floor(faceHeight * 0.6);
1705 region.
setSize(faceHeight, faceWidth);
1707 toExpand.
setSize(faceHeight, faceWidth,
true);
1709 unsigned int cont = (y1 <= 1 ? 0 : faceHeight * (y1 - 1));
1717 range2D *= 1.0f / 5;
1718 img.setFromMatrix(range2D);
1721 for (
unsigned int i = y1; i <= y2; i++)
1725 for (
unsigned int j = x1; j <= x2; j++, cont++)
1727 if (*(
face.confidenceImage.get_unsafe(j, i, 0)) >
1737 cont += faceWidth - x2;
1766 bool newExpanded =
true;
1770 newExpanded =
false;
1772 for (
size_t row = 0;
row < faceHeight;
row++)
1774 for (
size_t col = 0; col < faceWidth; col++)
1782 unsigned char*
c =
img.get_unsafe(col,
row);
1787 unsigned char*
c =
img.get_unsafe(col,
row - 1);
1788 int value2 = (int)*
c;
1789 if (abs(
value - value2) < 2)
1796 if ((
row < faceWidth - 1) &&
1799 unsigned char*
c =
img.get_unsafe(col,
row + 1);
1800 int value2 = (int)*
c;
1801 if (abs(
value - value2) < 2)
1810 unsigned char*
c =
img.get_unsafe(col - 1,
row);
1811 int value2 = (int)*
c;
1812 if (abs(
value - value2) < 2)
1819 if ((col < faceHeight - 1) &&
1822 unsigned char*
c =
img.get_unsafe(col + 1,
row);
1823 int value2 = (int)*
c;
1824 if (abs(
value - value2) < 2)
1837 for (
unsigned int row = 0;
row < faceHeight;
row++)
1839 for (
unsigned int col = 0; col < faceWidth; col++)
1843 img.setPixel(col,
row, 0);
1863 const CImage&
face,
const size_t& c1,
const size_t& r1,
const size_t& c2,
1869 for (
size_t col = c1; col <= c2; col++)
1871 unsigned char*
c =
face.get_unsafe(col,
row);
1872 size_t value = (size_t)*
c;
1889 f.open(
"statistics.txt", ofstream::app);
1893 double meanEigenVal, stdEigenVal;
1894 double minEigenVal = *min_element(
1896 double maxEigenVal = *max_element(
1902 <<
"Statistical data about eigen values calculated of regions "
1905 cout <<
"Min eigenVal: " << minEigenVal << endl;
1906 cout <<
"Max eigenVal: " << maxEigenVal << endl;
1907 cout <<
"Mean eigenVal: " << meanEigenVal << endl;
1908 cout <<
"Standard Desv: " << stdEigenVal << endl;
1913 <<
"Statistical data about eigen values calculated of regions "
1916 f <<
"Min eigenVal: " << minEigenVal << endl;
1917 f <<
"Max eigenVal: " << maxEigenVal << endl;
1918 f <<
"Mean eigenVal: " << meanEigenVal << endl;
1919 f <<
"Standard Desv: " << stdEigenVal << endl;
1925 double meanSumDist, stdSumDist;
1926 double minSumDist = *min_element(
1928 double maxSumDist = *max_element(
1933 cout << endl <<
"Statistical data about sum of distances" << endl;
1934 cout <<
"Min sumDistances: " << minSumDist << endl;
1935 cout <<
"Max sumDistances: " << maxSumDist << endl;
1936 cout <<
"Mean sumDistances: " << meanSumDist << endl;
1937 cout <<
"Standard Desv: " << stdSumDist << endl;
1941 f << endl <<
"Statistical data about sum of distances" << endl;
1942 f <<
"Min sumDistances: " << minSumDist << endl;
1943 f <<
"Max sumDistances: " << maxSumDist << endl;
1944 f <<
"Mean sumDistances: " << meanSumDist << endl;
1945 f <<
"Standard Desv: " << stdSumDist << endl;
1951 double meanEstimationErr, stdEstimationErr;
1952 double minEstimationErr = *min_element(
1955 double maxEstimationErr = *max_element(
1963 <<
"Statistical data about estimation error adjusting a plane of "
1964 "regions detected as faces"
1966 cout <<
"Min estimation: " << minEstimationErr << endl;
1967 cout <<
"Max estimation: " << maxEstimationErr << endl;
1968 cout <<
"Mean estimation: " << meanEstimationErr << endl;
1969 cout <<
"Standard Desv: " << stdEstimationErr << endl;
1974 <<
"Statistical data about estimation error adjusting a plane of "
1975 "regions detected as faces"
1977 f <<
"Min estimation: " << minEstimationErr << endl;
1978 f <<
"Max estimation: " << maxEstimationErr << endl;
1979 f <<
"Mean estimation: " << meanEstimationErr << endl;
1980 f <<
"Standard Desv: " << stdEstimationErr << endl;
1984 cout << endl <<
"Data about number of faces" << endl;
1997 cout << endl <<
"Mean hist: " << meanHist << endl;
1998 cout <<
"Min hist: " << minHist << endl;
1999 cout <<
"Max hist: " << maxHist << endl;
2000 cout <<
"Stdv: " << stdHist << endl;
2005 f << endl <<
"Data about number of faces" << endl;
2025 unsigned int& falsePositivesDeleted,
unsigned int& realFacesDeleted)
2028 const unsigned int numFalsePositives = falsePositives.size();
2029 const unsigned int numIgnored = ignore.size();
2030 unsigned int ignoredDetected = 0;
2032 falsePositivesDeleted = 0;
2034 for (
unsigned int i = 0; i < numDeleted; i++)
2038 bool falsePositive =
false;
2041 while (!falsePositive && (j < numFalsePositives))
2043 if (region == falsePositives[j]) falsePositive =
true;
2048 falsePositivesDeleted++;
2054 while (!igno && (j < numIgnored))
2056 if (region == ignore[j]) igno =
true;
2060 if (igno) ignoredDetected++;
2064 realFacesDeleted = numDeleted - falsePositivesDeleted - ignoredDetected;
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
virtual void init(const mrpt::utils::CConfigFileBase &cfg)
Initialize cascade classifier detection.
std::shared_ptr< CDetectable2D > Ptr
std::shared_ptr< CDetectable3D > Ptr
Specific class for face detection.
void experimental_calcHist(const mrpt::utils::CImage &face, const size_t &c1, const size_t &r1, const size_t &c2, const size_t &r2, mrpt::math::CMatrixTemplate< unsigned int > &hist)
bool m_checkIfFaceRegions_res
Save result of checkIfFaceRegions filter.
void experimental_viewFacePointsScanned(const std::vector< float > &xs, const std::vector< float > &ys, const std::vector< float > &zs)
std::promise< void > m_enter_checkIfDiagonalSurface
Indicates to thread_checkIfDiagonalSurface that exist a new face to analyze.
bool checkIfDiagonalSurface2(mrpt::obs::CObservation3DRangeScan *face)
virtual void detectObjects_Impl(const mrpt::obs::CObservation *obs, vector_detectable_object &detected)
std::thread m_thread_checkIfDiagonalSurface
Thread that execute checkIfDiagonalSurface filter.
bool checkIfFacePlaneCov(mrpt::obs::CObservation3DRangeScan *face)
static void dummy_checkIfFacePlaneCov(CFaceDetection *obj)
std::promise< void > m_enter_checkIfFacePlaneCov
Indicates to thread_checkIfFacePlaneCov that exist a new face to analyze.
bool checkIfFaceRegions(mrpt::obs::CObservation3DRangeScan *face)
size_t checkRelativePosition(const mrpt::math::TPoint3D &p1, const mrpt::math::TPoint3D &p2, const mrpt::math::TPoint3D &p, double &dist)
std::vector< double > m_meanHist
void thread_checkIfFaceRegions()
std::promise< void > m_enter_checkIfFaceRegions
Indicates to thread_checkIfFaceRegions that exist a new face to analyze.
std::promise< void > m_leave_checkIfFaceRegions
Indicates to main thread that thread_checkIfFaceRegions has been completed analisis of the last face ...
bool checkIfDiagonalSurface(mrpt::obs::CObservation3DRangeScan *face)
mrpt::obs::CObservation3DRangeScan m_lastFaceDetected
Last face detected.
mrpt::utils::CTimeLogger m_timeLog
CCascadeClassifierDetection cascadeClassifier
std::thread m_thread_checkIfFacePlaneCov
Thread that execute checkIfFacePlaneCov filter.
void thread_checkIfDiagonalSurface()
std::promise< void > m_leave_checkIfFacePlaneCov
Indicates to main thread that thread_checkIfFacePlaneCov has been completed analisis of the last face...
void thread_checkIfFacePlaneCov()
bool m_end_threads
Indicates to all threads that must finish their execution.
struct mrpt::detectors::CFaceDetection::TMeasurement m_measure
static void dummy_checkIfFaceRegions(CFaceDetection *obj)
std::thread m_thread_checkIfFaceRegions
Thread that execute checkIfFaceRegions filter.
void experimental_showMeasurements()
static void dummy_checkIfDiagonalSurface(CFaceDetection *obj)
bool m_checkIfFacePlaneCov_res
Save result of checkIfFacePlaneCov filter.
virtual void init(const mrpt::utils::CConfigFileBase &cfg)
Initialize the object with parameters loaded from the given config source.
void debug_returnResults(const vector_uint &falsePositives, const vector_uint &ignore, unsigned int &falsePositivesDeleted, unsigned int &realFacesDeleted)
void experimental_viewFacePointsAndEigenVects(const std::vector< mrpt::math::CArrayDouble< 3 >> &pointsVector, const mrpt::math::CMatrixDouble &eigenVect, const mrpt::math::CVectorDouble &eigenVal)
void experimental_viewRegions(const std::vector< mrpt::math::TPoint3D > regions[9], const mrpt::math::TPoint3D meanPos[3][3])
std::promise< void > m_leave_checkIfDiagonalSurface
Indicates to main thread that thread_checkIfDiagonalSurface has been completed analisis of the last f...
struct mrpt::detectors::CFaceDetection::TTestsOptions m_testsOptions
bool m_checkIfDiagonalSurface_res
Save result of checkIfDiagonalSurface filter.
void experimental_segmentFace(const mrpt::obs::CObservation3DRangeScan &face, mrpt::math::CMatrixTemplate< bool > ®ion)
bool checkIfFacePlane(mrpt::obs::CObservation3DRangeScan *face)
struct mrpt::detectors::CFaceDetection::TOptions m_options
void detectObjects(const mrpt::obs::CObservation::Ptr obs, vector_detectable_object &detected)
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
void setCameraPointingToPoint(float x, float y, float z)
Changes the camera parameters programmatically.
void unlockAccess3DScene()
Unlocks the access to the internal 3D scene.
void setCameraZoom(float zoom)
Changes the camera parameters programmatically.
void setWindowTitle(const std::string &str) override
Changes the window title.
mrpt::opengl::COpenGLScene::Ptr & get3DSceneAndLock()
Gets a reference to the smart shared pointer that holds the internal scene (carefuly read introductio...
void setCameraAzimuthDeg(float deg)
Changes the camera parameters programmatically.
void resize(unsigned int width, unsigned int height) override
Resizes the window, stretching the image to fit into the display area.
void repaint()
Repaints the window.
void setCameraElevationDeg(float deg)
Changes the camera parameters programmatically.
This class creates a window as a graphical user interface (GUI) for displaying images to the user.
void showImage(const mrpt::utils::CImage &img)
Show a given color or grayscale image on the window.
A map of 2D/3D points with individual colours (RGB).
void setPointColor(size_t index, float R, float G, float B)
Changes just the color of a given point from the map.
void setAllPoints(const std::vector< float > &X, const std::vector< float > &Y, const std::vector< float > &Z)
Set all the points at once from vectors with X,Y and Z coordinates.
Declares a matrix of booleans (non serializable).
void set_unsafe(size_t row, size_t col, const T &v)
Fast but unsafe method to write a value in the matrix.
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
const T & get_unsafe(size_t row, size_t col) const
Fast but unsafe method to read a value from the matrix.
size_t getColCount() const
Number of columns in the matrix.
size_t getRowCount() const
Number of rows in the matrix.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
bool hasPoints3D
true means the field points3D contains valid data.
void getZoneAsObs(CObservation3DRangeScan &obs, const unsigned int &r1, const unsigned int &r2, const unsigned int &c1, const unsigned int &c2)
Extract a ROI of the 3D observation as a new one.
mrpt::math::CMatrix rangeImage
If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters)
Declares a class that represents any robot's observation.
std::shared_ptr< CArrow > Ptr
std::shared_ptr< COpenGLScene > Ptr
std::shared_ptr< CPointCloudColoured > Ptr
std::shared_ptr< CSetOfLines > Ptr
std::shared_ptr< CSphere > Ptr
This class allows loading and storing values and vectors of different types from a configuration text...
bool read_bool(const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
double read_double(const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
A class for storing images as grayscale or RGB bitmaps.
std::string getStatsAsText(const size_t column_width=80) const
Dump all stats to a multi-line text string.
void enter(const char *func_name)
Start of a named section.
void enable(bool enabled=true)
double leave(const char *func_name)
End of a named section.
void meanAndStd(VEC &outMeanVector, VEC &outStdVector, const bool unbiased_variance=true) const
Computes a row with the mean values of each column in the matrix and the associated vector with the s...
GLsizei GLsizei GLuint * obj
GLenum GLenum GLvoid * row
GLuint GLuint GLsizei count
GLenum GLuint GLint GLenum face
GLdouble GLdouble GLdouble r
GLsizei const GLfloat * value
GLsizei const GLfloat * points
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
double getRegressionPlane(const std::vector< TPoint3D > &points, TPlane &plane)
Using eigenvalues, gets the best fitting plane for a set of 3D points.
std::vector< uint32_t > vector_uint
void pause(const std::string &msg=std::string("Press any key to continue...")) noexcept
Shows the message "Press any key to continue" (or other custom message) to the current standard outpu...
std::vector< CDetectableObject::Ptr > vector_detectable_object
Classes for creating GUI windows for 2D and 3D visualization.
This base provides a set of functions for maths stuff.
Eigen::Matrix< typename MATRIX::Scalar, MATRIX::ColsAtCompileTime, MATRIX::ColsAtCompileTime > cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample,...
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
This namespace contains representation of robot actions and observations.
The namespace for 3D scene representation and rendering.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::math::CVectorDouble sumDistances
bool saveMeasurementsToFile
mrpt::math::CVectorDouble errorEstimations
int numPossibleFacesDetected
vector_uint deletedRegions
mrpt::math::CVectorDouble lessEigenVals
bool useSizeDistanceRelationFilter
bool useDiagonalDistanceFilter
double regionsTest_sumDistThreshold_bottom
double regionsTest_sumDistThreshold_top
double planeTest_eigenVal_top
double planeTest_eigenVal_bottom
3D Plane, represented by its equation
double distanceTo(const TPoint3D &p) const
Point-to-point distance.
double x
X,Y,Z coordinates.
3D segment, consisting of two points.
A RGB color - floats in the range [0,1].
A pair (x,y) of pixel coordinates (integer resolution).