Main MRPT website > C++ reference for MRPT 1.4.0
CFaceDetection.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef CFaceDetection_H
11 #define CFaceDetection_H
12 
15 #include <mrpt/utils/CTimeLogger.h>
16 #include <mrpt/system/threads.h>
17 #include <mrpt/synch.h>
19 #include <mrpt/obs/obs_frwds.h>
20 
21 namespace mrpt
22 {
23  /** \ingroup mrpt_detectors_grp */
24  namespace detectors
25  {
26  /** Specific class for face detection.
27  * Methods and variables labeled as experimentals are temporals (for debug or testing
28  * purposes) and may disappear in future versions.
29  * \ingroup mrpt_detectors_grp
30  */
32  {
33  public:
34 
36 
38 
39  ~CFaceDetection();
40 
41  virtual void init(const mrpt::utils::CConfigFileBase &cfg );
42 
43  virtual void detectObjects_Impl(const mrpt::obs::CObservation *obs, vector_detectable_object &detected);
44 
45  struct TOptions
46  {
49 
54 
55  bool batchMode;
56 
57  }m_options;
58 
60  {
66 
67  }m_testsOptions;
68 
69  // Experimental methods
70  void experimental_showMeasurements();
71 
72  void debug_returnResults( const vector_uint &falsePositives, const vector_uint &ignore, unsigned int &falsePositivesDeleted, unsigned int &realFacesDeleted );
73 
74  private:
75 
76  mrpt::system::TThreadHandle m_thread_checkIfFaceRegions; //!< Thread that execute checkIfFaceRegions filter
77  mrpt::system::TThreadHandle m_thread_checkIfFacePlaneCov; //!< Thread that execute checkIfFacePlaneCov filter
78  mrpt::system::TThreadHandle m_thread_checkIfDiagonalSurface; //!< Thread that execute checkIfDiagonalSurface filter
79 
80  bool m_checkIfFaceRegions_res; //!< Save result of checkIfFaceRegions filter
81  bool m_checkIfFacePlaneCov_res; //!< Save result of checkIfFacePlaneCov filter
82  bool m_checkIfDiagonalSurface_res; //!< Save result of checkIfDiagonalSurface filter
83 
84  bool m_end_threads; //!< Indicates to all threads that must finish their execution
85 
86  mrpt::synch::CSemaphore m_enter_checkIfFaceRegions; //!< Indicates to thread_checkIfFaceRegions that exist a new face to analyze
87  mrpt::synch::CSemaphore m_enter_checkIfFacePlaneCov; //!< Indicates to thread_checkIfFacePlaneCov that exist a new face to analyze
88  mrpt::synch::CSemaphore m_enter_checkIfDiagonalSurface; //!< Indicates to thread_checkIfDiagonalSurface that exist a new face to analyze
89 
90  mrpt::synch::CSemaphore m_leave_checkIfFaceRegions; //!< Indicates to main thread that thread_checkIfFaceRegions has been completed analisis of the last face detected
91  mrpt::synch::CSemaphore m_leave_checkIfFacePlaneCov; //!< Indicates to main thread that thread_checkIfFacePlaneCov has been completed analisis of the last face detected
92  mrpt::synch::CSemaphore m_leave_checkIfDiagonalSurface; //!< Indicates to main thread that thread_checkIfDiagonalSurface has been completed analisis of the last face detected
93 
95 
96  struct TMeasurement
97  {
99 
103 
105 
106  int faceNum;
110 
111  bool takeTime;
112 
114 
115  }m_measure;
116 
117  // To take measures abaout execution time
119 
120  std::vector<double> m_meanHist;
121 
122 
123  // Test to check if a candidate region is a real face
124 
125  bool checkIfFacePlane( mrpt::obs::CObservation3DRangeScan* face );
126 
127  bool checkIfFacePlaneCov( mrpt::obs::CObservation3DRangeScan* face );
128 
129  void thread_checkIfFacePlaneCov( );
130 
131  static void dummy_checkIfFacePlaneCov( CFaceDetection *obj );
132 
133 
134  bool checkIfFaceRegions( mrpt::obs::CObservation3DRangeScan* face );
135 
136  void thread_checkIfFaceRegions( );
137 
138  static void dummy_checkIfFaceRegions( CFaceDetection *obj );
139 
140  size_t checkRelativePosition( const mrpt::math::TPoint3D &p1, const mrpt::math::TPoint3D &p2, const mrpt::math::TPoint3D &p, double &dist );
141 
142 
143  void thread_checkIfDiagonalSurface( );
144 
145  bool checkIfDiagonalSurface( mrpt::obs::CObservation3DRangeScan* face );
146 
147  bool checkIfDiagonalSurface2( mrpt::obs::CObservation3DRangeScan* face );
148 
149  static void dummy_checkIfDiagonalSurface( CFaceDetection *obj );
150 
151  // Experimental methods to view 3D points
152 
153  void experimental_viewFacePointsScanned( const std::vector<float> &xs, const std::vector<float> &ys, const std::vector<float> &zs );
154 
155  void experimental_viewFacePointsScanned( const mrpt::obs::CObservation3DRangeScan &face );
156 
157  void experimental_viewFacePointsScanned( const std::vector<mrpt::math::TPoint3D> &points );
158 
159  void experimental_viewFacePointsAndEigenVects( const std::vector<mrpt::math::CArrayDouble<3> > &pointsVector, const mrpt::math::CMatrixDouble &eigenVect, const mrpt::math::CVectorDouble &eigenVal );
160 
161  void experimental_viewRegions( const std::vector<mrpt::math::TPoint3D> regions[9], const mrpt::math::TPoint3D meanPos[3][3] );
162 
163  // Segmentation methods
164  void experimental_segmentFace( const mrpt::obs::CObservation3DRangeScan &face, mrpt::math::CMatrixTemplate<bool> &region );
165 
166  // Histogram methods
167  void experimental_calcHist( const mrpt::utils::CImage &face, const size_t &c1, const size_t &r1, const size_t &c2,
168  const size_t &r2, mrpt::math::CMatrixTemplate<unsigned int> &hist );
169 
170 
171 
172  }; // End of class
173  }
174 
175 }
176 
177 #endif
mrpt::detectors::CFaceDetection::TMeasurement::lessEigenVals
mrpt::math::CVectorDouble lessEigenVals
Definition: CFaceDetection.h:100
mrpt::detectors::CCascadeClassifierDetection
Definition: CCascadeClassifierDetection.h:22
mrpt::detectors::CFaceDetection::TTestsOptions::planeTest_eigenVal_top
double planeTest_eigenVal_top
Definition: CFaceDetection.h:62
mrpt::detectors::CFaceDetection::TOptions::batchMode
bool batchMode
Definition: CFaceDetection.h:55
mrpt::detectors::CFaceDetection::TMeasurement::numRealFacesDetected
int numRealFacesDetected
Definition: CFaceDetection.h:109
mrpt::detectors::CFaceDetection::TOptions::multithread
bool multithread
Definition: CFaceDetection.h:48
mrpt::vector_uint
std::vector< uint32_t > vector_uint
Definition: types_simple.h:28
mrpt::detectors::CFaceDetection::m_meanHist
std::vector< double > m_meanHist
Definition: CFaceDetection.h:120
mrpt::detectors::CFaceDetection::m_enter_checkIfFaceRegions
mrpt::synch::CSemaphore m_enter_checkIfFaceRegions
Indicates to thread_checkIfFaceRegions that exist a new face to analyze.
Definition: CFaceDetection.h:86
mrpt::math::dynamic_vector
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
Definition: eigen_frwds.h:35
mrpt::detectors::CFaceDetection
Specific class for face detection.
Definition: CFaceDetection.h:31
threads.h
mrpt::detectors::CFaceDetection::TTestsOptions::planeTest_eigenVal_bottom
double planeTest_eigenVal_bottom
Definition: CFaceDetection.h:63
mrpt::detectors::CFaceDetection::TMeasurement::deletedRegions
vector_uint deletedRegions
Definition: CFaceDetection.h:107
mrpt::math::CMatrixTemplate< bool >
mrpt::detectors::CFaceDetection::TMeasurement::saveMeasurementsToFile
bool saveMeasurementsToFile
Definition: CFaceDetection.h:113
mrpt::detectors::CFaceDetection::m_checkIfFacePlaneCov_res
bool m_checkIfFacePlaneCov_res
Save result of checkIfFacePlaneCov filter.
Definition: CFaceDetection.h:81
mrpt::detectors::CFaceDetection::TMeasurement::meanRegions
mrpt::math::CVectorDouble meanRegions
Definition: CFaceDetection.h:102
CObjectDetection.h
mrpt::detectors::vector_detectable_object
std::vector< CDetectableObjectPtr > vector_detectable_object
Definition: CObjectDetection.h:22
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CParticleFilter.h:16
mrpt::detectors::CFaceDetection::TMeasurement::errorEstimations
mrpt::math::CVectorDouble errorEstimations
Definition: CFaceDetection.h:101
mrpt::detectors::CFaceDetection::TTestsOptions::regionsTest_sumDistThreshold_top
double regionsTest_sumDistThreshold_top
Definition: CFaceDetection.h:64
mrpt::utils::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
mrpt::utils::CTimeLogger
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X),...
Definition: CTimeLogger.h:35
mrpt::detectors::CFaceDetection::TOptions::useDiagonalDistanceFilter
bool useDiagonalDistanceFilter
Definition: CFaceDetection.h:53
mrpt::detectors::CFaceDetection::m_checkIfDiagonalSurface_res
bool m_checkIfDiagonalSurface_res
Save result of checkIfDiagonalSurface filter.
Definition: CFaceDetection.h:82
mrpt::detectors::CFaceDetection::m_checkIfFaceRegions_res
bool m_checkIfFaceRegions_res
Save result of checkIfFaceRegions filter.
Definition: CFaceDetection.h:80
mrpt::detectors::CFaceDetection::TMeasurement::sumDistances
mrpt::math::CVectorDouble sumDistances
Definition: CFaceDetection.h:104
mrpt::detectors::CFaceDetection::cascadeClassifier
CCascadeClassifierDetection cascadeClassifier
Definition: CFaceDetection.h:35
mrpt::detectors::CFaceDetection::m_enter_checkIfDiagonalSurface
mrpt::synch::CSemaphore m_enter_checkIfDiagonalSurface
Indicates to thread_checkIfDiagonalSurface that exist a new face to analyze.
Definition: CFaceDetection.h:88
mrpt::synch::CSemaphore
A semaphore for inter-thread synchronization.
Definition: CSemaphore.h:31
mrpt::math::CMatrixTemplateNumeric< double >
mrpt::detectors::CObjectDetection
Definition: CObjectDetection.h:25
mrpt::detectors::CFaceDetection::m_thread_checkIfFacePlaneCov
mrpt::system::TThreadHandle m_thread_checkIfFacePlaneCov
Thread that execute checkIfFacePlaneCov filter.
Definition: CFaceDetection.h:77
mrpt::detectors::CFaceDetection::m_thread_checkIfFaceRegions
mrpt::system::TThreadHandle m_thread_checkIfFaceRegions
Thread that execute checkIfFaceRegions filter.
Definition: CFaceDetection.h:76
mrpt::detectors::CFaceDetection::m_end_threads
bool m_end_threads
Indicates to all threads that must finish their execution.
Definition: CFaceDetection.h:84
mrpt::detectors::CFaceDetection::m_leave_checkIfFacePlaneCov
mrpt::synch::CSemaphore m_leave_checkIfFacePlaneCov
Indicates to main thread that thread_checkIfFacePlaneCov has been completed analisis of the last face...
Definition: CFaceDetection.h:91
CObservation3DRangeScan.h
mrpt::detectors::CFaceDetection::m_leave_checkIfDiagonalSurface
mrpt::synch::CSemaphore m_leave_checkIfDiagonalSurface
Indicates to main thread that thread_checkIfDiagonalSurface has been completed analisis of the last f...
Definition: CFaceDetection.h:92
mrpt::detectors::CFaceDetection::TOptions::useSizeDistanceRelationFilter
bool useSizeDistanceRelationFilter
Definition: CFaceDetection.h:52
mrpt::obs::CObservation3DRangeScan
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
Definition: obs/CObservation3DRangeScan.h:112
mrpt::detectors::CFaceDetection::TOptions::useRegionsFilter
bool useRegionsFilter
Definition: CFaceDetection.h:51
mrpt::utils::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: CConfigFileBase.h:30
mrpt::detectors::CFaceDetection::TOptions::confidenceThreshold
int confidenceThreshold
Definition: CFaceDetection.h:47
mrpt::detectors::CFaceDetection::TOptions
Definition: CFaceDetection.h:45
mrpt::detectors::CFaceDetection::TTestsOptions::planeThreshold
double planeThreshold
Definition: CFaceDetection.h:61
mrpt::detectors::CFaceDetection::m_lastFaceDetected
mrpt::obs::CObservation3DRangeScan m_lastFaceDetected
Last face detected.
Definition: CFaceDetection.h:94
CTimeLogger.h
obs_frwds.h
mrpt::detectors::CFaceDetection::TMeasurement::faceNum
int faceNum
Definition: CFaceDetection.h:106
mrpt::math::CArrayDouble< 3 >
mrpt::system::TThreadHandle
This structure contains the information needed to interface the threads API on each platform:
Definition: threads.h:25
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:229
CCascadeClassifierDetection.h
mrpt::detectors::CFaceDetection::m_thread_checkIfDiagonalSurface
mrpt::system::TThreadHandle m_thread_checkIfDiagonalSurface
Thread that execute checkIfDiagonalSurface filter.
Definition: CFaceDetection.h:78
mrpt::detectors::CFaceDetection::TOptions::useCovFilter
bool useCovFilter
Definition: CFaceDetection.h:50
mrpt::obs::CObservation
Declares a class that represents any robot's observation.
Definition: obs/CObservation.h:47
mrpt::detectors::CFaceDetection::m_enter_checkIfFacePlaneCov
mrpt::synch::CSemaphore m_enter_checkIfFacePlaneCov
Indicates to thread_checkIfFacePlaneCov that exist a new face to analyze.
Definition: CFaceDetection.h:87
mrpt::detectors::CFaceDetection::TMeasurement::takeTime
bool takeTime
Definition: CFaceDetection.h:111
mrpt::detectors::CFaceDetection::m_timeLog
mrpt::utils::CTimeLogger m_timeLog
Definition: CFaceDetection.h:118
mrpt::detectors::CFaceDetection::m_leave_checkIfFaceRegions
mrpt::synch::CSemaphore m_leave_checkIfFaceRegions
Indicates to main thread that thread_checkIfFaceRegions has been completed analisis of the last face ...
Definition: CFaceDetection.h:90
mrpt::detectors::CFaceDetection::TTestsOptions
Definition: CFaceDetection.h:59
mrpt::detectors::CFaceDetection::TMeasurement::numPossibleFacesDetected
int numPossibleFacesDetected
Definition: CFaceDetection.h:108
synch.h
mrpt::detectors::CFaceDetection::TMeasurement::takeMeasures
bool takeMeasures
Definition: CFaceDetection.h:98
mrpt::detectors::CFaceDetection::TTestsOptions::regionsTest_sumDistThreshold_bottom
double regionsTest_sumDistThreshold_bottom
Definition: CFaceDetection.h:65
mrpt::detectors::CFaceDetection::TMeasurement
Definition: CFaceDetection.h:96



Page generated by Doxygen 1.8.17 for MRPT 1.4.0 SVN: at Sat Jan 18 22:37:07 UTC 2020