MRPT  2.0.4
CFaceDetection.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
16 #include <mrpt/obs/obs_frwds.h>
18 #include <future>
19 
20 namespace mrpt
21 {
22 /** \ingroup mrpt_detectors_grp */
23 namespace detectors
24 {
25 /** Specific class for face detection.
26  * Methods and variables labeled as experimentals are temporals (for debug or
27  * testing
28  * purposes) and may disappear in future versions.
29  * \ingroup mrpt_detectors_grp
30  */
32 {
33  public:
35 
37 
39 
40  void init(const mrpt::config::CConfigFileBase& cfg) override;
41 
42  void detectObjects_Impl(
43  const mrpt::obs::CObservation& obs,
44  vector_detectable_object& detected) override;
45 
46  struct TOptions
47  {
50 
55 
56  bool batchMode;
57 
58  } m_options;
59 
61  {
67 
69 
70  // Experimental methods
72 
74  const std::vector<uint32_t>& falsePositives,
75  const std::vector<uint32_t>& ignore,
76  unsigned int& falsePositivesDeleted, unsigned int& realFacesDeleted);
77 
78  private:
79  /** Thread that execute checkIfFaceRegions filter */
81  /** Thread that execute checkIfFacePlaneCov filter */
83  /** Thread that execute checkIfDiagonalSurface filter */
85 
86  /** Save result of checkIfFaceRegions filter */
88  /** Save result of checkIfFacePlaneCov filter */
90  /** Save result of checkIfDiagonalSurface filter */
92 
93  /** Indicates to all threads that must finish their execution */
94  bool m_end_threads{false};
95 
96  /** Indicates to thread_checkIfFaceRegions that exist a new face to analyze
97  */
98  std::promise<void> m_enter_checkIfFaceRegions;
99  /** Indicates to thread_checkIfFacePlaneCov that exist a new face to analyze
100  */
101  std::promise<void> m_enter_checkIfFacePlaneCov;
102  /** Indicates to thread_checkIfDiagonalSurface that exist a new face to
103  * analyze */
104  std::promise<void> m_enter_checkIfDiagonalSurface;
105 
106  /** Indicates to main thread that thread_checkIfFaceRegions has been
107  * completed analisis of the last face detected */
108  std::promise<void> m_leave_checkIfFaceRegions;
109  /** Indicates to main thread that thread_checkIfFacePlaneCov has been
110  * completed analisis of the last face detected */
111  std::promise<void> m_leave_checkIfFacePlaneCov;
112  /** Indicates to main thread that thread_checkIfDiagonalSurface has been
113  * completed analisis of the last face detected */
114  std::promise<void> m_leave_checkIfDiagonalSurface;
115 
116  /** Last face detected */
118 
120  {
122 
126 
128 
129  int faceNum;
130  std::vector<uint32_t> deletedRegions;
133 
134  bool takeTime;
135 
137 
138  } m_measure;
139 
140  // To take measures abaout execution time
142 
143  std::vector<double> m_meanHist;
144 
145  // Test to check if a candidate region is a real face
146 
148 
150 
152 
153  static void dummy_checkIfFacePlaneCov(CFaceDetection* obj);
154 
156 
158 
159  static void dummy_checkIfFaceRegions(CFaceDetection* obj);
160 
161  size_t checkRelativePosition(
162  const mrpt::math::TPoint3D& p1, const mrpt::math::TPoint3D& p2,
163  const mrpt::math::TPoint3D& p, double& dist);
164 
166 
168 
170 
172 
173  // Experimental methods to view 3D points
174 
176  const std::vector<float>& xs, const std::vector<float>& ys,
177  const std::vector<float>& zs);
178 
181 
183  const std::vector<mrpt::math::TPoint3D>& points);
184 
186  const std::vector<mrpt::math::CVectorFixedDouble<3>>& pointsVector,
187  const mrpt::math::CMatrixDouble& eigenVect,
188  const std::vector<double>& eigenVal);
189 
191  const std::vector<mrpt::math::TPoint3D> regions[9],
192  const mrpt::math::TPoint3D meanPos[3][3]);
193 
194  // Segmentation methods
198 
199  // Histogram methods
201  const mrpt::img::CImage& face, size_t c1, size_t r1, size_t c2,
203 
204 }; // End of class
205 } // namespace detectors
206 } // namespace mrpt
mrpt::detectors::CFaceDetection::checkRelativePosition
size_t checkRelativePosition(const mrpt::math::TPoint3D &p1, const mrpt::math::TPoint3D &p2, const mrpt::math::TPoint3D &p, double &dist)
Definition: CFaceDetection.cpp:793
mrpt::detectors::CFaceDetection::TMeasurement::lessEigenVals
mrpt::math::CVectorDouble lessEigenVals
Definition: CFaceDetection.h:123
mrpt::detectors::CFaceDetection::thread_checkIfFacePlaneCov
void thread_checkIfFacePlaneCov()
Definition: CFaceDetection.cpp:356
mrpt::detectors::CCascadeClassifierDetection
Definition: CCascadeClassifierDetection.h:19
mrpt::detectors::CFaceDetection::TTestsOptions::planeTest_eigenVal_top
double planeTest_eigenVal_top
Definition: CFaceDetection.h:63
mrpt::detectors::CFaceDetection::m_leave_checkIfFaceRegions
std::promise< void > m_leave_checkIfFaceRegions
Indicates to main thread that thread_checkIfFaceRegions has been completed analisis of the last face ...
Definition: CFaceDetection.h:108
mrpt::detectors::CFaceDetection::TOptions::batchMode
bool batchMode
Definition: CFaceDetection.h:56
mrpt::detectors::CFaceDetection::init
void init(const mrpt::config::CConfigFileBase &cfg) override
Initialize the object with parameters loaded from the given config source.
Definition: CFaceDetection.cpp:76
mrpt::detectors::CFaceDetection::experimental_segmentFace
void experimental_segmentFace(const mrpt::obs::CObservation3DRangeScan &face, mrpt::math::CMatrixDynamic< bool > &region)
Definition: CFaceDetection.cpp:1654
mrpt::detectors::CFaceDetection::TMeasurement::numRealFacesDetected
int numRealFacesDetected
Definition: CFaceDetection.h:132
mrpt::detectors::CFaceDetection::TOptions::multithread
bool multithread
Definition: CFaceDetection.h:49
mrpt::math::TPoint3D_< double >
mrpt::detectors::CFaceDetection::m_meanHist
std::vector< double > m_meanHist
Definition: CFaceDetection.h:143
mrpt::detectors::CFaceDetection::checkIfFaceRegions
bool checkIfFaceRegions(mrpt::obs::CObservation3DRangeScan *face)
Definition: CFaceDetection.cpp:501
mrpt::system::CTimeLogger
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X),...
Definition: system/CTimeLogger.h:50
mrpt::detectors::CFaceDetection
Specific class for face detection.
Definition: CFaceDetection.h:31
mrpt::detectors::CFaceDetection::TTestsOptions::planeTest_eigenVal_bottom
double planeTest_eigenVal_bottom
Definition: CFaceDetection.h:64
mrpt::detectors::CFaceDetection::dummy_checkIfFacePlaneCov
static void dummy_checkIfFacePlaneCov(CFaceDetection *obj)
Definition: CFaceDetection.cpp:351
mrpt::detectors::CFaceDetection::TMeasurement::saveMeasurementsToFile
bool saveMeasurementsToFile
Definition: CFaceDetection.h:136
mrpt::detectors::CFaceDetection::dummy_checkIfFaceRegions
static void dummy_checkIfFaceRegions(CFaceDetection *obj)
Definition: CFaceDetection.cpp:477
mrpt::detectors::CFaceDetection::m_checkIfFacePlaneCov_res
bool m_checkIfFacePlaneCov_res
Save result of checkIfFacePlaneCov filter.
Definition: CFaceDetection.h:89
mrpt::detectors::CFaceDetection::CFaceDetection
CFaceDetection()
Definition: CFaceDetection.cpp:45
mrpt::detectors::CFaceDetection::TMeasurement::meanRegions
mrpt::math::CVectorDouble meanRegions
Definition: CFaceDetection.h:125
CObjectDetection.h
mrpt::detectors::CFaceDetection::m_thread_checkIfDiagonalSurface
std::thread m_thread_checkIfDiagonalSurface
Thread that execute checkIfDiagonalSurface filter.
Definition: CFaceDetection.h:84
mrpt::detectors::CFaceDetection::~CFaceDetection
~CFaceDetection()
Definition: CFaceDetection.cpp:58
CObservation3DRangeScan.h
mrpt::detectors::CFaceDetection::m_thread_checkIfFacePlaneCov
std::thread m_thread_checkIfFacePlaneCov
Thread that execute checkIfFacePlaneCov filter.
Definition: CFaceDetection.h:82
falsePositives
vector< std::vector< uint32_t > > falsePositives
Definition: vision_stereo_rectify/test.cpp:48
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: BaseAppDataSource.h:15
mrpt::detectors::CFaceDetection::TMeasurement::errorEstimations
mrpt::math::CVectorDouble errorEstimations
Definition: CFaceDetection.h:124
mrpt::detectors::CFaceDetection::TTestsOptions::regionsTest_sumDistThreshold_top
double regionsTest_sumDistThreshold_top
Definition: CFaceDetection.h:65
mrpt::detectors::CFaceDetection::TOptions::useDiagonalDistanceFilter
bool useDiagonalDistanceFilter
Definition: CFaceDetection.h:54
mrpt::detectors::CFaceDetection::m_checkIfDiagonalSurface_res
bool m_checkIfDiagonalSurface_res
Save result of checkIfDiagonalSurface filter.
Definition: CFaceDetection.h:91
mrpt::detectors::CFaceDetection::experimental_viewFacePointsAndEigenVects
void experimental_viewFacePointsAndEigenVects(const std::vector< mrpt::math::CVectorFixedDouble< 3 >> &pointsVector, const mrpt::math::CMatrixDouble &eigenVect, const std::vector< double > &eigenVal)
Definition: CFaceDetection.cpp:1461
mrpt::detectors::CFaceDetection::m_checkIfFaceRegions_res
bool m_checkIfFaceRegions_res
Save result of checkIfFaceRegions filter.
Definition: CFaceDetection.h:87
mrpt::detectors::CFaceDetection::checkIfDiagonalSurface
bool checkIfDiagonalSurface(mrpt::obs::CObservation3DRangeScan *face)
Definition: CFaceDetection.cpp:850
mrpt::detectors::CFaceDetection::TMeasurement::sumDistances
mrpt::math::CVectorDouble sumDistances
Definition: CFaceDetection.h:127
mrpt::detectors::CFaceDetection::cascadeClassifier
CCascadeClassifierDetection cascadeClassifier
Definition: CFaceDetection.h:34
mrpt::detectors::CFaceDetection::checkIfFacePlane
bool checkIfFacePlane(mrpt::obs::CObservation3DRangeScan *face)
Definition: CFaceDetection.cpp:322
mrpt::detectors::CFaceDetection::m_options
struct mrpt::detectors::CFaceDetection::TOptions m_options
mrpt::detectors::CFaceDetection::detectObjects_Impl
void detectObjects_Impl(const mrpt::obs::CObservation &obs, vector_detectable_object &detected) override
Definition: CFaceDetection.cpp:132
mrpt::detectors::CObjectDetection
Definition: CObjectDetection.h:21
CVectorDynamic.h
mrpt::detectors::CFaceDetection::m_end_threads
bool m_end_threads
Indicates to all threads that must finish their execution.
Definition: CFaceDetection.h:94
mrpt::detectors::CFaceDetection::thread_checkIfDiagonalSurface
void thread_checkIfDiagonalSurface()
Definition: CFaceDetection.cpp:830
mrpt::math::CMatrixFixed
A compile-time fixed-size numeric matrix container.
Definition: CMatrixFixed.h:33
mrpt::detectors::CFaceDetection::TOptions::useSizeDistanceRelationFilter
bool useSizeDistanceRelationFilter
Definition: CFaceDetection.h:53
mrpt::obs::CObservation3DRangeScan
A range or depth 3D scan measurement, as from a time-of-flight range camera or a structured-light dep...
Definition: CObservation3DRangeScan.h:168
mrpt::detectors::CFaceDetection::TOptions::useRegionsFilter
bool useRegionsFilter
Definition: CFaceDetection.h:52
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
mrpt::detectors::CFaceDetection::TMeasurement::deletedRegions
std::vector< uint32_t > deletedRegions
Definition: CFaceDetection.h:130
mrpt::detectors::CFaceDetection::experimental_calcHist
void experimental_calcHist(const mrpt::img::CImage &face, size_t c1, size_t r1, size_t c2, size_t r2, mrpt::math::CMatrixDynamic< unsigned int > &hist)
Definition: CFaceDetection.cpp:1788
mrpt::detectors::CFaceDetection::TOptions::confidenceThreshold
int confidenceThreshold
Definition: CFaceDetection.h:48
mrpt::detectors::CFaceDetection::TOptions
Definition: CFaceDetection.h:46
mrpt::detectors::CFaceDetection::TTestsOptions::planeThreshold
double planeThreshold
Definition: CFaceDetection.h:62
mrpt::detectors::CFaceDetection::m_lastFaceDetected
mrpt::obs::CObservation3DRangeScan m_lastFaceDetected
Last face detected.
Definition: CFaceDetection.h:117
mrpt::detectors::CFaceDetection::m_testsOptions
struct mrpt::detectors::CFaceDetection::TTestsOptions m_testsOptions
obs_frwds.h
mrpt::detectors::CFaceDetection::experimental_viewFacePointsScanned
void experimental_viewFacePointsScanned(const std::vector< float > &xs, const std::vector< float > &ys, const std::vector< float > &zs)
Definition: CFaceDetection.cpp:1391
mrpt::detectors::CFaceDetection::TMeasurement::faceNum
int faceNum
Definition: CFaceDetection.h:129
mrpt::detectors::CFaceDetection::m_enter_checkIfFacePlaneCov
std::promise< void > m_enter_checkIfFacePlaneCov
Indicates to thread_checkIfFacePlaneCov that exist a new face to analyze.
Definition: CFaceDetection.h:101
mrpt::detectors::CFaceDetection::thread_checkIfFaceRegions
void thread_checkIfFaceRegions()
Definition: CFaceDetection.cpp:482
mrpt::math::CVectorDynamic< double >
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:148
mrpt::detectors::CFaceDetection::m_thread_checkIfFaceRegions
std::thread m_thread_checkIfFaceRegions
Thread that execute checkIfFaceRegions filter.
Definition: CFaceDetection.h:80
mrpt::detectors::CFaceDetection::m_enter_checkIfDiagonalSurface
std::promise< void > m_enter_checkIfDiagonalSurface
Indicates to thread_checkIfDiagonalSurface that exist a new face to analyze.
Definition: CFaceDetection.h:104
mrpt::detectors::CFaceDetection::dummy_checkIfDiagonalSurface
static void dummy_checkIfDiagonalSurface(CFaceDetection *obj)
Definition: CFaceDetection.cpp:825
mrpt::detectors::CFaceDetection::checkIfDiagonalSurface2
bool checkIfDiagonalSurface2(mrpt::obs::CObservation3DRangeScan *face)
Definition: CFaceDetection.cpp:1117
mrpt::detectors::CFaceDetection::m_enter_checkIfFaceRegions
std::promise< void > m_enter_checkIfFaceRegions
Indicates to thread_checkIfFaceRegions that exist a new face to analyze.
Definition: CFaceDetection.h:98
mrpt::detectors::vector_detectable_object
std::vector< CDetectableObject::Ptr > vector_detectable_object
Definition: CObjectDetection.h:18
CCascadeClassifierDetection.h
mrpt::detectors::CFaceDetection::m_leave_checkIfDiagonalSurface
std::promise< void > m_leave_checkIfDiagonalSurface
Indicates to main thread that thread_checkIfDiagonalSurface has been completed analisis of the last f...
Definition: CFaceDetection.h:114
CTimeLogger.h
mrpt::detectors::CFaceDetection::experimental_viewRegions
void experimental_viewRegions(const std::vector< mrpt::math::TPoint3D > regions[9], const mrpt::math::TPoint3D meanPos[3][3])
Definition: CFaceDetection.cpp:1558
mrpt::detectors::CFaceDetection::TOptions::useCovFilter
bool useCovFilter
Definition: CFaceDetection.h:51
mrpt::obs::CObservation
Declares a class that represents any robot's observation.
Definition: CObservation.h:43
mrpt::detectors::CFaceDetection::TMeasurement::takeTime
bool takeTime
Definition: CFaceDetection.h:134
mrpt::detectors::CFaceDetection::m_measure
struct mrpt::detectors::CFaceDetection::TMeasurement m_measure
mrpt::detectors::CFaceDetection::TTestsOptions
Definition: CFaceDetection.h:60
mrpt::detectors::CFaceDetection::debug_returnResults
void debug_returnResults(const std::vector< uint32_t > &falsePositives, const std::vector< uint32_t > &ignore, unsigned int &falsePositivesDeleted, unsigned int &realFacesDeleted)
Definition: CFaceDetection.cpp:1948
mrpt::detectors::CFaceDetection::TMeasurement::numPossibleFacesDetected
int numPossibleFacesDetected
Definition: CFaceDetection.h:131
mrpt::detectors::CFaceDetection::checkIfFacePlaneCov
bool checkIfFacePlaneCov(mrpt::obs::CObservation3DRangeScan *face)
Definition: CFaceDetection.cpp:374
mrpt::math::CMatrixDynamic< double >
mrpt::detectors::CFaceDetection::m_leave_checkIfFacePlaneCov
std::promise< void > m_leave_checkIfFacePlaneCov
Indicates to main thread that thread_checkIfFacePlaneCov has been completed analisis of the last face...
Definition: CFaceDetection.h:111
mrpt::detectors::CFaceDetection::experimental_showMeasurements
void experimental_showMeasurements()
Definition: CFaceDetection.cpp:1807
mrpt::detectors::CFaceDetection::TMeasurement::takeMeasures
bool takeMeasures
Definition: CFaceDetection.h:121
mrpt::detectors::CFaceDetection::m_timeLog
mrpt::system::CTimeLogger m_timeLog
Definition: CFaceDetection.h:141
mrpt::detectors::CFaceDetection::TTestsOptions::regionsTest_sumDistThreshold_bottom
double regionsTest_sumDistThreshold_bottom
Definition: CFaceDetection.h:66
mrpt::detectors::CFaceDetection::TMeasurement
Definition: CFaceDetection.h:119



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 17:54:30 UTC 2020