Main MRPT website > C++ reference
MRPT logo
CFaceDetection.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef CFaceDetection_H
30 #define CFaceDetection_H
31 
34 #include <mrpt/utils/CTimeLogger.h>
35 #include <mrpt/system.h>
36 #include <mrpt/synch.h>
38 
39 namespace mrpt
40 {
41 
42  namespace slam { class CObservation3DRangeScan; }
43 
44  /** \ingroup mrpt_detectors_grp */
45  namespace detectors
46  {
47  using namespace mrpt::slam;
48  using namespace mrpt::system;
49  using namespace mrpt::synch;
50 
51  /** Specific class for face detection.
52  * Methods and variables labeled as experimentals are temporals (for debug or testing
53  * purposes) and may disappear in future versions.
54  * \ingroup mrpt_detectors_grp
55  */
57  {
58  public:
59 
61 
63 
64  ~CFaceDetection();
65 
66  virtual void init(const mrpt::utils::CConfigFileBase &cfg );
67 
68  virtual void detectObjects_Impl(const CObservation *obs, vector_detectable_object &detected);
69 
70  struct TOptions
71  {
74 
79 
80  bool batchMode;
81 
82  }m_options;
83 
85  {
91 
92  }m_testsOptions;
93 
94  // Experimental methods
95  void experimental_showMeasurements();
96 
97  void debug_returnResults( const vector_uint &falsePositives, const vector_uint &ignore, unsigned int &falsePositivesDeleted, unsigned int &realFacesDeleted );
98 
99  private:
100 
101  TThreadHandle m_thread_checkIfFaceRegions; //!< Thread that execute checkIfFaceRegions filter
102  TThreadHandle m_thread_checkIfFacePlaneCov; //!< Thread that execute checkIfFacePlaneCov filter
103  TThreadHandle m_thread_checkIfDiagonalSurface; //!< Thread that execute checkIfDiagonalSurface filter
104 
105  bool m_checkIfFaceRegions_res; //!< Save result of checkIfFaceRegions filter
106  bool m_checkIfFacePlaneCov_res; //!< Save result of checkIfFacePlaneCov filter
107  bool m_checkIfDiagonalSurface_res; //!< Save result of checkIfDiagonalSurface filter
108 
109  bool m_end_threads; //!< Indicates to all threads that must finish their execution
110 
111  CSemaphore m_enter_checkIfFaceRegions; //!< Indicates to thread_checkIfFaceRegions that exist a new face to analyze
112  CSemaphore m_enter_checkIfFacePlaneCov; //!< Indicates to thread_checkIfFacePlaneCov that exist a new face to analyze
113  CSemaphore m_enter_checkIfDiagonalSurface; //!< Indicates to thread_checkIfDiagonalSurface that exist a new face to analyze
114 
115  CSemaphore m_leave_checkIfFaceRegions; //!< Indicates to main thread that thread_checkIfFaceRegions has been completed analisis of the last face detected
116  CSemaphore m_leave_checkIfFacePlaneCov; //!< Indicates to main thread that thread_checkIfFacePlaneCov has been completed analisis of the last face detected
117  CSemaphore m_leave_checkIfDiagonalSurface; //!< Indicates to main thread that thread_checkIfDiagonalSurface has been completed analisis of the last face detected
118 
120 
122  {
124 
128 
130 
131  int faceNum;
135 
136  bool takeTime;
137 
139 
140  }m_measure;
141 
142  // To take measures abaout execution time
144 
145  std::vector<double> m_meanHist;
146 
147 
148  // Test to check if a candidate region is a real face
149 
150  bool checkIfFacePlane( CObservation3DRangeScan* face );
151 
152  bool checkIfFacePlaneCov( CObservation3DRangeScan* face );
153 
154  void thread_checkIfFacePlaneCov( );
155 
156  static void dummy_checkIfFacePlaneCov( CFaceDetection *obj );
157 
158 
159  bool checkIfFaceRegions( CObservation3DRangeScan* face );
160 
161  void thread_checkIfFaceRegions( );
162 
163  static void dummy_checkIfFaceRegions( CFaceDetection *obj );
164 
165  size_t checkRelativePosition( const TPoint3D &p1, const TPoint3D &p2, const TPoint3D &p, double &dist );
166 
167 
168  void thread_checkIfDiagonalSurface( );
169 
170  bool checkIfDiagonalSurface( CObservation3DRangeScan* face );
171 
172  bool checkIfDiagonalSurface2( CObservation3DRangeScan* face );
173 
174  static void dummy_checkIfDiagonalSurface( CFaceDetection *obj );
175 
176  // Experimental methods to view 3D points
177 
178  void experimental_viewFacePointsScanned( const std::vector<float> &xs, const std::vector<float> &ys, const std::vector<float> &zs );
179 
180  void experimental_viewFacePointsScanned( const CObservation3DRangeScan &face );
181 
182  void experimental_viewFacePointsScanned( const std::vector<TPoint3D> &points );
183 
184  void experimental_viewFacePointsAndEigenVects( const std::vector<CArrayDouble<3> > &pointsVector, const CMatrixDouble &eigenVect, const vector_double &eigenVal );
185 
186  void experimental_viewRegions( const std::vector<TPoint3D> regions[9], const TPoint3D meanPos[3][3] );
187 
188  // Segmentation methods
189 
190  void experimental_segmentFace( const CObservation3DRangeScan &face, CMatrixTemplate<bool> &region );
191 
192  // Histogram methods
193 
194  void experimental_calcHist( const CImage &face, const size_t &c1, const size_t &r1, const size_t &c2,
195  const size_t &r2, CMatrixTemplate<unsigned int> &hist );
196 
197 
198 
199  }; // End of class
200  }
201 
202 }
203 
204 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013