30 #include <mrpt/otherlibs/do_opencv_includes.h> 47 CFaceDetection::CFaceDetection() : m_end_threads(false)
81 cfg.
read_int(
"FaceDetection",
"confidenceThreshold", 240);
84 cfg.
read_bool(
"FaceDetection",
"useCovFilter",
true);
86 cfg.
read_bool(
"FaceDetection",
"useRegionsFilter",
true);
88 cfg.
read_bool(
"FaceDetection",
"useSizeDistanceRelationFilter",
true);
90 cfg.
read_bool(
"FaceDetection",
"useDiagonalDistanceFilter",
true);
93 cfg.
read_double(
"FaceDetection",
"planeThreshold", 50);
95 cfg.
read_double(
"FaceDetection",
"planeTest_eigenVal_top", 0.011);
97 cfg.
read_double(
"FaceDetection",
"planeTest_eigenVal_bottom", 0.0002);
99 "FaceDetection",
"regionsTest_sumDistThreshold_top", 0.5);
101 "FaceDetection",
"regionsTest_sumDistThreshold_bottom", 0.04);
105 cfg.
read_bool(
"FaceDetection",
"takeMeasures",
false);
107 cfg.
read_bool(
"FaceDetection",
"saveMeasurementsToFile",
false);
171 vector<size_t> deleteDetected;
175 for (
unsigned int i = 0; i < localDetected.size(); i++)
181 unsigned int r1 = rec->m_y;
182 unsigned int r2 = rec->m_y + rec->m_height;
183 unsigned int c1 = rec->m_x;
184 unsigned int c2 = rec->m_x + rec->m_width;
218 deleteDetected.push_back(i);
250 deleteDetected.push_back(i);
257 deleteDetected.push_back(i);
265 deleteDetected.push_back(i);
289 for (
unsigned int i = deleteDetected.size(); i > 0; i--)
291 localDetected.begin() + deleteDetected[i - 1]);
295 for (
unsigned int i = 0; i < localDetected.size(); i++)
298 std::dynamic_pointer_cast<CDetectable2D>(localDetected[i])));
299 detected.push_back(object3d);
309 detected = localDetected;
328 size_t N =
face->points3D_x.size();
332 for (
size_t i = 0; i < N; i++)
334 face->points3D_x.at(i),
face->points3D_y.at(i),
335 face->points3D_z.at(i));
355 obj->thread_checkIfFacePlaneCov();
387 const unsigned int faceWidth =
face->intensityImage.getWidth();
388 const unsigned int faceHeight =
face->intensityImage.getHeight();
391 const bool confidence =
face->hasConfidenceImage;
394 vector<CArrayDouble<3>> pointsVector;
399 for (
unsigned int j = 0; j < faceHeight; j++)
401 for (
unsigned int k = 0; k < faceWidth; k++)
408 (*(
face->confidenceImage.get_unsafe(k, j, 0)) >
410 (*(
face->intensityImage.get_unsafe(k, j)) >
413 int position = faceWidth * j + k;
414 aux[0] =
face->points3D_x[position];
415 aux[1] =
face->points3D_y[position];
416 aux[2] =
face->points3D_z[position];
417 pointsVector.push_back(aux);
423 if (pointsVector.empty())
return false;
434 cov.eigenValues(eVals);
436 cov.eigenVectors(eVects, m_eVals);
452 cout << eVals[0] <<
" " << eVals[1] <<
" " << eVals[2] <<
" > ";
453 cout << eVals[0] / eVals[2] << endl;
464 if (eVals[0] / eVals[2] > 0.06)
483 obj->thread_checkIfFaceRegions();
515 const unsigned int faceWidth =
face->intensityImage.getWidth();
516 const unsigned int faceHeight =
face->intensityImage.getHeight();
519 unsigned int sectionVSize = faceHeight / 3.0;
539 int numPoints[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
541 vector<TPoint3D> regions2[9];
558 for (
size_t r = 0;
r < region.
rows();
r++)
559 for (
size_t c = 1;
c < region.
cols();
c++)
572 if (
end == 0)
end = faceWidth - 1;
573 if (
end < 3 * (faceWidth / 4))
574 end = 3 * (faceWidth / 4);
576 if (
start > faceWidth / 4)
start = faceWidth / 4;
581 unsigned int utilWidth = faceWidth -
start - (faceWidth -
end);
582 unsigned int c1 = ceil(utilWidth / 3.0 +
start);
583 unsigned int c2 = ceil(2 * (utilWidth / 3.0) +
start);
593 face->intensityImage,
start, 0,
end, ceil(faceHeight * 0.1), hist);
595 size_t countHist = 0;
596 for (
size_t i = 0; i < 60; i++)
602 size_t downLimit = faceHeight - 1;
606 upLimit = floor(faceHeight * 0.1);
607 downLimit = floor(faceHeight * 0.9);
618 unsigned int cont = 0;
620 for (
unsigned int r = 0;
r < faceHeight;
r++)
622 for (
unsigned int c = 0;
c < faceWidth;
c++, cont++)
624 if ((
r >= upLimit) && (
r <= downLimit) &&
626 (*(
face->confidenceImage.get_unsafe(
c,
r, 0)) >
628 (*(
face->intensityImage.get_unsafe(
c,
r)) > 50))
630 unsigned int row, col;
631 if (
r < sectionVSize + upLimit * 0.3)
633 else if (
r < sectionVSize * 2 - upLimit * 0.15)
646 face->points3D_x[cont],
face->points3D_y[cont],
647 face->points3D_z[cont]);
648 meanPos[
row][col] = meanPos[
row][col] + point;
650 ++numPoints[
row][col];
652 if (
row == 0 && col == 0)
654 face->points3D_x[cont],
face->points3D_y[cont],
655 face->points3D_z[cont]));
656 else if (
row == 0 && col == 1)
658 face->points3D_x[cont],
face->points3D_y[cont],
659 face->points3D_z[cont]));
660 else if (
row == 0 && col == 2)
662 face->points3D_x[cont],
face->points3D_y[cont],
663 face->points3D_z[cont]));
664 else if (
row == 1 && col == 0)
666 face->points3D_x[cont],
face->points3D_y[cont],
667 face->points3D_z[cont]));
668 else if (
row == 1 && col == 1)
670 face->points3D_x[cont],
face->points3D_y[cont],
671 face->points3D_z[cont]));
672 else if (
row == 1 && col == 2)
674 face->points3D_x[cont],
face->points3D_y[cont],
675 face->points3D_z[cont]));
676 else if (
row == 2 && col == 0)
678 face->points3D_x[cont],
face->points3D_y[cont],
679 face->points3D_z[cont]));
680 else if (
row == 2 && col == 1)
682 face->points3D_x[cont],
face->points3D_y[cont],
683 face->points3D_z[cont]));
686 face->points3D_x[cont],
face->points3D_y[cont],
687 face->points3D_z[cont]));
696 vector<double> oldPointsX1;
701 if (regions2[0].
size() > 0)
703 for (
size_t i = 0; i < regions2[0].size(); i++)
704 oldPointsX1.push_back(regions2[0][i].x);
706 middle1 = floor((
double)oldPointsX1.size() / 2);
708 oldPointsX1.begin(), oldPointsX1.begin() + middle1,
712 vector<double> oldPointsX2;
714 if (regions2[2].
size() > 0)
716 for (
size_t i = 0; i < regions2[2].size(); i++)
717 oldPointsX2.push_back(regions2[2][i].x);
719 middle2 = floor((
double)oldPointsX2.size() / 2);
721 oldPointsX2.begin(), oldPointsX2.begin() + middle2,
725 for (
size_t i = 0; i < 3; i++)
726 for (
size_t j = 0; j < 3; j++)
727 if (!numPoints[i][j])
730 meanPos[i][j] = meanPos[i][j] / numPoints[i][j];
732 if (regions2[0].
size() > 0) meanPos[0][0].
x = oldPointsX1.at(middle1);
734 if (regions2[2].
size() > 0) meanPos[0][2].
x = oldPointsX2.at(middle2);
739 vector<double> dist(5);
741 meanPos[1][0], meanPos[1][2], meanPos[1][1], dist[0]);
743 meanPos[2][0], meanPos[2][2], meanPos[2][1], dist[1]);
745 meanPos[0][0], meanPos[0][2], meanPos[0][1], dist[2]);
747 meanPos[0][0], meanPos[2][2], meanPos[1][1], dist[3]);
749 meanPos[2][0], meanPos[0][2], meanPos[1][1], dist[4]);
752 f.open(
"dist.txt", ofstream::app);
753 f <<
sum(dist) << endl;
759 else if ((
res = 1) && (
sum(dist) > 0.04))
762 f.open(
"tam.txt", ofstream::app);
763 f << meanPos[0][1].
distanceTo(meanPos[2][1]) << endl;
813 double yIdeal = y1 + (((
x - x1) * (y2 - y1)) / (x2 - x1));
835 obj->thread_checkIfDiagonalSurface();
871 const unsigned int faceWidth =
face->intensityImage.getWidth();
872 const unsigned int faceHeight =
face->intensityImage.getHeight();
876 unsigned int x1 = ceil(faceWidth * 0.25);
877 unsigned int x2 = floor(faceWidth * 0.75);
878 unsigned int y1 = ceil(faceHeight * 0.15);
879 unsigned int y2 = floor(faceHeight * 0.85);
882 unsigned int cont = (y1 == 0 ? 0 : faceHeight * (y1 - 1));
885 valids.
setSize(faceHeight, faceWidth);
890 for (
unsigned int i = y1; i <= y2; i++)
894 for (
unsigned int j = x1; j <= x2; j++, cont++)
896 if (*(
face->confidenceImage.get_unsafe(j, i, 0)) >
899 sumDepth +=
face->points3D_x[cont];
902 face->points3D_x[cont],
face->points3D_y[cont],
903 face->points3D_z[cont]));
906 cont += faceWidth - x2 - 1;
909 double meanDepth = sumDepth / total;
920 double maxFaceDistance = 0.5 + 1000 / (pow(faceWidth, 1.9));
937 if (maxFaceDistance < meanDepth)
960 f.open(
"relaciones2.txt", ofstream::app);
961 f << meanDepth << endl;
970 cont = (y1 == 1 ? 0 : faceHeight * (y1 - 1));
972 for (
unsigned int i = y1; i <= y2; i++)
976 for (
unsigned int j = x1; j <= x2; j++, cont++)
978 if ((*(
face->confidenceImage.get_unsafe(j, i, 0)) >
985 face->points3D_x[cont],
face->points3D_y[cont],
986 face->points3D_z[cont]));
991 cont += faceWidth - x2 - 1;
1000 double sumDistances = 0;
1006 for (
unsigned int i = y1; i <= y2; i++)
1010 for (
unsigned int j = x1; j <= x2; j++, cont++)
1018 if ((i + 1 <= y2) && (j + 1 <= x2))
1023 face->points3D_x[cont],
face->points3D_y[cont],
1024 face->points3D_z[cont]);
1025 offsetIndex = cont + faceWidth + 1;
1027 face->points3D_x[offsetIndex],
1028 face->points3D_y[offsetIndex],
1029 face->points3D_z[offsetIndex]));
1033 bool validOffset =
true;
1043 face->points3D_x[cont],
1044 face->points3D_y[cont],
1045 face->points3D_z[cont]);
1046 offsetIndex = cont + faceWidth +
offset;
1048 face->points3D_x[offsetIndex],
1049 face->points3D_y[offsetIndex],
1050 face->points3D_z[offsetIndex]));
1056 validOffset =
false;
1064 cont += faceWidth - x2 - 1;
1073 fo.open(
"distances.txt", ofstream::app);
1075 fo << sumDistances << endl;
1078 fo.open(
"distances2.txt", ofstream::app);
1085 double yMax = 3 + 6 / (pow(meanDepth, 2));
1086 double yMin = 1 + 3.8 / (pow(meanDepth + 1.2, 2));
1094 if (((sumDistances <= yMax) && (sumDistances >= yMin)) && (
res))
1138 const unsigned int faceWidth =
face->intensityImage.getWidth();
1139 const unsigned int faceHeight =
face->intensityImage.getHeight();
1150 for (
unsigned int row = 0;
row < faceHeight;
row++)
1152 for (
unsigned int col = 0; col < faceWidth; col++, cont++)
1155 (*(
face->confidenceImage.get_unsafe(col,
row, 0)) >
1158 sumDepth +=
face->points3D_x[cont];
1161 face->points3D_x[cont],
face->points3D_y[cont],
1162 face->points3D_z[cont]));
1167 double meanDepth = sumDepth / total;
1173 double maxFaceDistance = 0.5 + 1000 / (pow(faceWidth, 1.9));
1190 if (maxFaceDistance < meanDepth)
1213 f.open(
"relaciones2.txt", ofstream::app);
1214 f << meanDepth << endl;
1229 double sumDistances = 0;
1231 size_t offsetIndex = 0;
1235 for (
unsigned int i = 0; i < faceHeight; i++)
1237 for (
unsigned int j = 0; j < faceWidth; j++, cont++)
1242 if ((i + 1 < faceHeight) && (j + 1 < faceWidth))
1247 face->points3D_x[cont],
face->points3D_y[cont],
1248 face->points3D_z[cont]);
1249 offsetIndex = cont + faceWidth + 1;
1251 face->points3D_x[offsetIndex],
1252 face->points3D_y[offsetIndex],
1253 face->points3D_z[offsetIndex]));
1257 bool validOffset =
true;
1262 if ((i +
offset < faceHeight) &&
1263 (j +
offset < faceWidth))
1268 face->points3D_x[cont],
1269 face->points3D_y[cont],
1270 face->points3D_z[cont]);
1271 offsetIndex = cont + faceWidth +
offset;
1273 face->points3D_x[offsetIndex],
1274 face->points3D_y[offsetIndex],
1275 face->points3D_z[offsetIndex]));
1281 validOffset =
false;
1297 f.open(
"distances.txt", ofstream::app);
1299 f << sumDistances << endl;
1309 double yMax = 3 + 11.8 / (pow(meanDepth, 0.9));
1310 double yMin = 1 + 3.8 / (pow(meanDepth + 7, 6));
1318 if (((sumDistances <= yMax) && (sumDistances >= yMin)) && (
res))
1352 vector<float> xs, ys, zs;
1354 unsigned int N =
face.points3D_x.size();
1360 for (
unsigned int i = 0; i < N; i++)
1362 xs[i] =
face.points3D_x[i];
1363 ys[i] =
face.points3D_y[i];
1364 zs[i] =
face.points3D_z[i];
1375 const vector<TPoint3D>&
points)
1377 vector<float> xs, ys, zs;
1379 unsigned int N =
points.size();
1385 for (
unsigned int i = 0; i < N; i++)
1400 const vector<float>& xs,
const vector<float>& ys,
const vector<float>& zs)
1414 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
1415 gl_points->setPointSize(4.5);
1419 scene->insert(gl_points);
1420 scene->insert(mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
1426 gl_points->loadFromPointsMap(&pntsMap);
1473 vector<float> xs, ys, zs;
1475 const size_t size = pointsVector.size();
1481 for (
size_t i = 0; i <
size; i++)
1483 xs[i] = pointsVector[i][0];
1484 ys[i] = pointsVector[i][1];
1485 zs[i] = pointsVector[i][2];
1502 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
1503 gl_points->setPointSize(4.5);
1507 CSphere::Ptr sphere = mrpt::make_aligned_shared<CSphere>(0.005f);
1508 sphere->setLocation(center);
1509 sphere->setColor(
TColorf(0, 1, 0));
1510 scene->insert(sphere);
1520 eigenVect.get_unsafe(0, 0), eigenVect.get_unsafe(0, 1),
1521 eigenVect.get_unsafe(0, 2));
1523 eigenVect.get_unsafe(1, 0), eigenVect.get_unsafe(1, 1),
1524 eigenVect.get_unsafe(1, 2));
1526 eigenVect.get_unsafe(2, 0), eigenVect.get_unsafe(2, 1),
1527 eigenVect.get_unsafe(2, 2));
1531 TPoint3D p1(center + E1 * eigenVal[0] * 100);
1532 TPoint3D p2(center + E2 * eigenVal[1] * 100);
1533 TPoint3D p3(center + E3 * eigenVal[2] * 100);
1535 CArrow::Ptr arrow1 = mrpt::make_aligned_shared<CArrow>(
1536 center.
x, center.
y, center.
z, p1.x, p1.y, p1.z);
1537 CArrow::Ptr arrow2 = mrpt::make_aligned_shared<CArrow>(
1538 center.
x, center.
y, center.
z, p2.
x, p2.
y, p2.
z);
1539 CArrow::Ptr arrow3 = mrpt::make_aligned_shared<CArrow>(
1540 center.
x, center.
y, center.
z, p3.
x, p3.
y, p3.
z);
1542 arrow1->setColor(
TColorf(0, 1, 0));
1543 arrow2->setColor(
TColorf(1, 0, 0));
1544 arrow3->setColor(
TColorf(0, 0, 1));
1546 scene->insert(arrow1);
1547 scene->insert(arrow2);
1548 scene->insert(arrow3);
1560 scene->insert(gl_points);
1561 scene->insert(mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
1567 gl_points->loadFromPointsMap(&pntsMap);
1580 const vector<TPoint3D> regions[9],
const TPoint3D meanPos[3][3])
1594 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
1595 gl_points->setPointSize(6);
1599 if (meanPos !=
nullptr)
1601 for (
size_t i = 0; i < 3; i++)
1602 for (
size_t j = 0; j < 3; j++)
1605 mrpt::make_aligned_shared<CSphere>(0.005f);
1606 sphere->setLocation(meanPos[i][j]);
1607 sphere->setColor(
TColorf(0, 1, 0));
1608 scene->insert(sphere);
1612 vector<TSegment3D> sgms;
1613 sgms.push_back(
TSegment3D(meanPos[0][0], meanPos[0][1]));
1614 sgms.push_back(
TSegment3D(meanPos[0][1], meanPos[0][2]));
1615 sgms.push_back(
TSegment3D(meanPos[1][0], meanPos[1][1]));
1616 sgms.push_back(
TSegment3D(meanPos[1][1], meanPos[1][2]));
1617 sgms.push_back(
TSegment3D(meanPos[2][0], meanPos[2][1]));
1618 sgms.push_back(
TSegment3D(meanPos[2][1], meanPos[2][2]));
1619 sgms.push_back(
TSegment3D(meanPos[0][0], meanPos[1][1]));
1620 sgms.push_back(
TSegment3D(meanPos[1][1], meanPos[2][2]));
1621 sgms.push_back(
TSegment3D(meanPos[2][0], meanPos[1][1]));
1622 sgms.push_back(
TSegment3D(meanPos[1][1], meanPos[0][2]));
1624 mrpt::make_aligned_shared<mrpt::opengl::CSetOfLines>(sgms);
1625 lines->setColor(0, 0, 1, 1);
1626 lines->setLineWidth(10);
1628 scene->insert(lines);
1630 scene->insert(gl_points);
1631 scene->insert(mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
1632 scene->insert(mrpt::make_aligned_shared<mrpt::opengl::CAxis>(
1633 -5, -5, -5, 5, 5, 5, 2.5, 3,
true));
1637 vector<float> xs, ys, zs;
1639 for (
size_t i = 0; i < 9; i++)
1640 for (
unsigned int j = 0; j < regions[i].size(); j++)
1642 xs.push_back(regions[i][j].
x);
1643 ys.push_back(regions[i][j].
y);
1644 zs.push_back(regions[i][j].
z);
1650 float colors[9][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1},
1651 {1, 1, 0}, {1, 0, 1}, {0, 1, 1},
1652 {0.5f, 0.25f, 0}, {0.5f, 0, 0.25f}, {0, 0.35f, 0.5f}};
1653 for (
size_t i = 0; i < 9; i++)
1655 float R = colors[i][0];
1656 float G = colors[i][1];
1657 float B = colors[i][2];
1659 for (
unsigned int j = 0; j < regions[i].size(); j++, cont++)
1663 gl_points->loadFromPointsMap(&pntsMap);
1679 const unsigned int faceWidth =
face.intensityImage.getWidth();
1680 const unsigned int faceHeight =
face.intensityImage.getHeight();
1682 region.
setSize(faceWidth, faceHeight,
true);
1684 unsigned int x1 = ceil(faceWidth * 0.4);
1685 unsigned int x2 = floor(faceWidth * 0.6);
1686 unsigned int y1 = ceil(faceHeight * 0.4);
1687 unsigned int y2 = floor(faceHeight * 0.6);
1689 region.
setSize(faceHeight, faceWidth);
1691 toExpand.
setSize(faceHeight, faceWidth,
true);
1693 unsigned int cont = (y1 <= 1 ? 0 : faceHeight * (y1 - 1));
1701 range2D *= 1.0f / 5;
1702 img.setFromMatrix(range2D);
1705 for (
unsigned int i = y1; i <= y2; i++)
1709 for (
unsigned int j = x1; j <= x2; j++, cont++)
1711 if (*(
face.confidenceImage.get_unsafe(j, i, 0)) >
1721 cont += faceWidth - x2;
1750 bool newExpanded =
true;
1754 newExpanded =
false;
1756 for (
size_t row = 0;
row < faceHeight;
row++)
1758 for (
size_t col = 0; col < faceWidth; col++)
1766 unsigned char*
c =
img.get_unsafe(col,
row);
1771 unsigned char*
c =
img.get_unsafe(col,
row - 1);
1772 int value2 = (int)*
c;
1773 if (abs(
value - value2) < 2)
1780 if ((
row < faceWidth - 1) &&
1783 unsigned char*
c =
img.get_unsafe(col,
row + 1);
1784 int value2 = (int)*
c;
1785 if (abs(
value - value2) < 2)
1794 unsigned char*
c =
img.get_unsafe(col - 1,
row);
1795 int value2 = (int)*
c;
1796 if (abs(
value - value2) < 2)
1803 if ((col < faceHeight - 1) &&
1806 unsigned char*
c =
img.get_unsafe(col + 1,
row);
1807 int value2 = (int)*
c;
1808 if (abs(
value - value2) < 2)
1821 for (
unsigned int row = 0;
row < faceHeight;
row++)
1823 for (
unsigned int col = 0; col < faceWidth; col++)
1827 img.setPixel(col,
row, 0);
1847 const CImage&
face,
const size_t& c1,
const size_t& r1,
const size_t& c2,
1853 for (
size_t col = c1; col <= c2; col++)
1855 unsigned char*
c =
face.get_unsafe(col,
row);
1856 size_t value = (size_t)*
c;
1873 f.open(
"statistics.txt", ofstream::app);
1877 double meanEigenVal, stdEigenVal;
1878 double minEigenVal = *min_element(
1880 double maxEigenVal = *max_element(
1886 <<
"Statistical data about eigen values calculated of regions " 1889 cout <<
"Min eigenVal: " << minEigenVal << endl;
1890 cout <<
"Max eigenVal: " << maxEigenVal << endl;
1891 cout <<
"Mean eigenVal: " << meanEigenVal << endl;
1892 cout <<
"Standard Desv: " << stdEigenVal << endl;
1897 <<
"Statistical data about eigen values calculated of regions " 1900 f <<
"Min eigenVal: " << minEigenVal << endl;
1901 f <<
"Max eigenVal: " << maxEigenVal << endl;
1902 f <<
"Mean eigenVal: " << meanEigenVal << endl;
1903 f <<
"Standard Desv: " << stdEigenVal << endl;
1909 double meanSumDist, stdSumDist;
1910 double minSumDist = *min_element(
1912 double maxSumDist = *max_element(
1917 cout << endl <<
"Statistical data about sum of distances" << endl;
1918 cout <<
"Min sumDistances: " << minSumDist << endl;
1919 cout <<
"Max sumDistances: " << maxSumDist << endl;
1920 cout <<
"Mean sumDistances: " << meanSumDist << endl;
1921 cout <<
"Standard Desv: " << stdSumDist << endl;
1925 f << endl <<
"Statistical data about sum of distances" << endl;
1926 f <<
"Min sumDistances: " << minSumDist << endl;
1927 f <<
"Max sumDistances: " << maxSumDist << endl;
1928 f <<
"Mean sumDistances: " << meanSumDist << endl;
1929 f <<
"Standard Desv: " << stdSumDist << endl;
1935 double meanEstimationErr, stdEstimationErr;
1936 double minEstimationErr = *min_element(
1939 double maxEstimationErr = *max_element(
1947 <<
"Statistical data about estimation error adjusting a plane of " 1948 "regions detected as faces" 1950 cout <<
"Min estimation: " << minEstimationErr << endl;
1951 cout <<
"Max estimation: " << maxEstimationErr << endl;
1952 cout <<
"Mean estimation: " << meanEstimationErr << endl;
1953 cout <<
"Standard Desv: " << stdEstimationErr << endl;
1958 <<
"Statistical data about estimation error adjusting a plane of " 1959 "regions detected as faces" 1961 f <<
"Min estimation: " << minEstimationErr << endl;
1962 f <<
"Max estimation: " << maxEstimationErr << endl;
1963 f <<
"Mean estimation: " << meanEstimationErr << endl;
1964 f <<
"Standard Desv: " << stdEstimationErr << endl;
1968 cout << endl <<
"Data about number of faces" << endl;
1981 cout << endl <<
"Mean hist: " << meanHist << endl;
1982 cout <<
"Min hist: " << minHist << endl;
1983 cout <<
"Max hist: " << maxHist << endl;
1984 cout <<
"Stdv: " << stdHist << endl;
1989 f << endl <<
"Data about number of faces" << endl;
2009 const std::vector<uint32_t>& ignore,
unsigned int& falsePositivesDeleted,
2010 unsigned int& realFacesDeleted)
2014 const unsigned int numIgnored = ignore.size();
2015 unsigned int ignoredDetected = 0;
2017 falsePositivesDeleted = 0;
2019 for (
unsigned int i = 0; i < numDeleted; i++)
2023 bool falsePositive =
false;
2026 while (!falsePositive && (j < numFalsePositives))
2033 falsePositivesDeleted++;
2039 while (!igno && (j < numIgnored))
2041 if (region == ignore[j]) igno =
true;
2045 if (igno) ignoredDetected++;
2049 realFacesDeleted = numDeleted - falsePositivesDeleted - ignoredDetected;
double regionsTest_sumDistThreshold_bottom
const T & get_unsafe(size_t row, size_t col) const
Fast but unsafe method to read a value from the matrix.
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...
GLuint GLuint GLsizei count
std::thread m_thread_checkIfFacePlaneCov
Thread that execute checkIfFacePlaneCov filter.
void unlockAccess3DScene()
Unlocks the access to the internal 3D scene.
double planeTest_eigenVal_top
bool m_end_threads
Indicates to all threads that must finish their execution.
void thread_checkIfDiagonalSurface()
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.
Declares a matrix of booleans (non serializable).
#define MRPT_TRY_END
The end of a standard MRPT "try...catch()" block that allows tracing throw the call stack after an ex...
CCascadeClassifierDetection cascadeClassifier
bool saveMeasurementsToFile
bool m_checkIfFaceRegions_res
Save result of checkIfFaceRegions filter.
void debug_returnResults(const std::vector< uint32_t > &falsePositives, const std::vector< uint32_t > &ignore, unsigned int &falsePositivesDeleted, unsigned int &realFacesDeleted)
void setWindowTitle(const std::string &str) override
Changes the window title.
void experimental_viewFacePointsAndEigenVects(const std::vector< mrpt::math::CArrayDouble< 3 >> &pointsVector, const mrpt::math::CMatrixDouble &eigenVect, const mrpt::math::CVectorDouble &eigenVal)
mrpt::opengl::COpenGLScene::Ptr & get3DSceneAndLock()
Gets a reference to the smart shared pointer that holds the internal scene (carefuly read introductio...
void resize(unsigned int width, unsigned int height) override
Resizes the window, stretching the image to fit into the display area.
static void dummy_checkIfDiagonalSurface(CFaceDetection *obj)
std::thread m_thread_checkIfDiagonalSurface
Thread that execute checkIfDiagonalSurface filter.
void setCameraPointingToPoint(float x, float y, float z)
Changes the camera parameters programmatically.
This file implements several operations that operate element-wise on individual or pairs of container...
double planeTest_eigenVal_bottom
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually...
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement, as from a time-of-flight range camera or any other RGBD sensor.
struct mrpt::detectors::CFaceDetection::TTestsOptions m_testsOptions
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
std::vector< double > m_meanHist
size_t checkRelativePosition(const mrpt::math::TPoint3D &p1, const mrpt::math::TPoint3D &p2, const mrpt::math::TPoint3D &p, double &dist)
virtual void init(const mrpt::config::CConfigFileBase &cfg)
Initialize cascade classifier detection.
std::vector< CDetectableObject::Ptr > vector_detectable_object
std::promise< void > m_enter_checkIfFacePlaneCov
Indicates to thread_checkIfFacePlaneCov that exist a new face to analyze.
GLsizei GLsizei GLuint * obj
mrpt::obs::CObservation3DRangeScan m_lastFaceDetected
Last face detected.
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
std::string getStatsAsText(const size_t column_width=80) const
Dump all stats to a multi-line text string.
GLsizei const GLfloat * points
mrpt::math::CMatrix rangeImage
If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters) ...
bool useDiagonalDistanceFilter
vector< std::vector< uint32_t > > falsePositives
#define MRPT_TRY_START
The start of a standard MRPT "try...catch()" block that allows tracing throw the call stack after an ...
std::thread m_thread_checkIfFaceRegions
Thread that execute checkIfFaceRegions filter.
std::promise< void > m_leave_checkIfFaceRegions
Indicates to main thread that thread_checkIfFaceRegions has been completed analisis of the last face ...
double regionsTest_sumDistThreshold_top
This class allows loading and storing values and vectors of different types from a configuration text...
This base provides a set of functions for maths stuff.
int numPossibleFacesDetected
3D segment, consisting of two points.
bool checkIfDiagonalSurface2(mrpt::obs::CObservation3DRangeScan *face)
void experimental_calcHist(const mrpt::img::CImage &face, const size_t &c1, const size_t &r1, const size_t &c2, const size_t &r2, mrpt::math::CMatrixTemplate< unsigned int > &hist)
double distanceTo(const TPoint3D &p) const
Point-to-point distance.
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.
bool checkIfFacePlaneCov(mrpt::obs::CObservation3DRangeScan *face)
This class creates a window as a graphical user interface (GUI) for displaying images to the user...
bool useSizeDistanceRelationFilter
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
size_t rows() const
Number of rows in the matrix.
virtual void init(const mrpt::config::CConfigFileBase &cfg)
Initialize the object with parameters loaded from the given config source.
A pair (x,y) of pixel coordinates (integer resolution).
This namespace contains representation of robot actions and observations.
bool checkIfFaceRegions(mrpt::obs::CObservation3DRangeScan *face)
3D Plane, represented by its equation
void thread_checkIfFaceRegions()
void experimental_segmentFace(const mrpt::obs::CObservation3DRangeScan &face, mrpt::math::CMatrixTemplate< bool > ®ion)
std::vector< uint32_t > deletedRegions
double getRegressionPlane(const std::vector< TPoint3D > &points, TPlane &plane)
Using eigenvalues, gets the best fitting plane for a set of 3D points.
bool checkIfDiagonalSurface(mrpt::obs::CObservation3DRangeScan *face)
double x
X,Y,Z coordinates.
double read_double(const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const
void thread_checkIfFacePlaneCov()
Specific class for face detection.
double leave(const char *func_name)
End of a named section.
A map of 2D/3D points with individual colours (RGB).
std::promise< void > m_leave_checkIfFacePlaneCov
Indicates to main thread that thread_checkIfFacePlaneCov has been completed analisis of the last face...
size_t cols() const
Number of columns in the matrix.
mrpt::gui::CDisplayWindow3D::Ptr win
void set_unsafe(size_t row, size_t col, const T &v)
Fast but unsafe method to write a value in the matrix.
bool hasPoints3D
true means the field points3D contains valid data.
std::promise< void > m_enter_checkIfDiagonalSurface
Indicates to thread_checkIfDiagonalSurface that exist a new face to analyze.
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...
struct mrpt::detectors::CFaceDetection::TMeasurement m_measure
void enable(bool enabled=true)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
mrpt::math::CVectorDouble lessEigenVals
bool checkIfFacePlane(mrpt::obs::CObservation3DRangeScan *face)
void experimental_viewFacePointsScanned(const std::vector< float > &xs, const std::vector< float > &ys, const std::vector< float > &zs)
virtual void detectObjects_Impl(const mrpt::obs::CObservation *obs, vector_detectable_object &detected)
Declares a class that represents any robot's observation.
mrpt::system::CTimeLogger m_timeLog
bool read_bool(const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::rtti::CObject) is of the give...
GLenum GLenum GLvoid * row
void experimental_showMeasurements()
mrpt::math::CVectorDouble errorEstimations
A RGB color - floats in the range [0,1].
static void dummy_checkIfFacePlaneCov(CFaceDetection *obj)
std::promise< void > m_leave_checkIfDiagonalSurface
Indicates to main thread that thread_checkIfDiagonalSurface has been completed analisis of the last f...
void setCameraZoom(float zoom)
Changes the camera parameters programmatically.
The namespace for 3D scene representation and rendering.
static void dummy_checkIfFaceRegions(CFaceDetection *obj)
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
mrpt::math::CVectorDouble sumDistances
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...
Classes for creating GUI windows for 2D and 3D visualization.
GLsizei const GLfloat * value
std::promise< void > m_enter_checkIfFaceRegions
Indicates to thread_checkIfFaceRegions that exist a new face to analyze.
void repaint()
Repaints the window.
std::shared_ptr< CDetectable3D > Ptr
bool m_checkIfDiagonalSurface_res
Save result of checkIfDiagonalSurface filter.
void detectObjects(const mrpt::obs::CObservation::Ptr obs, vector_detectable_object &detected)
struct mrpt::detectors::CFaceDetection::TOptions m_options
bool m_checkIfFacePlaneCov_res
Save result of checkIfFacePlaneCov filter.
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
void setCameraAzimuthDeg(float deg)
Changes the camera parameters programmatically.
void enter(const char *func_name)
Start of a named section.
GLenum GLuint GLint GLenum face
void setPointColor(size_t index, float R, float G, float B)
Changes just the color of a given point from the map.
A class for storing images as grayscale or RGB bitmaps.
void experimental_viewRegions(const std::vector< mrpt::math::TPoint3D > regions[9], const mrpt::math::TPoint3D meanPos[3][3])
void setCameraElevationDeg(float deg)
Changes the camera parameters programmatically.
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.