Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef CFaceDetection_H
00030 #define CFaceDetection_H
00031
00032 #include <mrpt/detectors/CObjectDetection.h>
00033 #include <mrpt/detectors/CCascadeClassifierDetection.h>
00034 #include <mrpt/utils/CTimeLogger.h>
00035 #include <mrpt/system.h>
00036 #include <mrpt/synch.h>
00037 #include <mrpt/slam/CObservation3DRangeScan.h>
00038
00039 namespace mrpt
00040 {
00041
00042 namespace slam { class CObservation3DRangeScan; }
00043
00044 namespace detectors
00045 {
00046 using namespace mrpt::slam;
00047 using namespace mrpt::system;
00048 using namespace mrpt::synch;
00049
00050
00051
00052
00053
00054 class DETECTORS_IMPEXP CFaceDetection: public CObjectDetection
00055 {
00056 public:
00057
00058 CCascadeClassifierDetection cascadeClassifier;
00059
00060 CFaceDetection();
00061
00062 ~CFaceDetection();
00063
00064 virtual void init(const mrpt::utils::CConfigFileBase &cfg );
00065
00066 virtual void detectObjects_Impl(const CObservation *obs, vector_detectable_object &detected);
00067
00068 struct TOptions
00069 {
00070 int confidenceThreshold;
00071 bool multithread;
00072
00073 bool useCovFilter;
00074 bool useRegionsFilter;
00075 bool useSizeDistanceRelationFilter;
00076 bool useDiagonalDistanceFilter;
00077
00078 bool batchMode;
00079
00080 }m_options;
00081
00082 struct TTestsOptions
00083 {
00084 double planeThreshold;
00085 double planeTest_eigenVal_top;
00086 double planeTest_eigenVal_bottom;
00087 double regionsTest_sumDistThreshold_top;
00088 double regionsTest_sumDistThreshold_bottom;
00089
00090 }m_testsOptions;
00091
00092
00093 void experimental_showMeasurements();
00094
00095 void debug_returnResults( const vector_uint &falsePositives, const vector_uint &ignore, unsigned int &falsePositivesDeleted, unsigned int &realFacesDeleted );
00096
00097 private:
00098
00099 TThreadHandle m_thread_checkIfFaceRegions;
00100 TThreadHandle m_thread_checkIfFacePlaneCov;
00101 TThreadHandle m_thread_checkIfDiagonalSurface;
00102
00103 bool m_checkIfFaceRegions_res;
00104 bool m_checkIfFacePlaneCov_res;
00105 bool m_checkIfDiagonalSurface_res;
00106
00107 bool m_end_threads;
00108
00109 CSemaphore m_enter_checkIfFaceRegions;
00110 CSemaphore m_enter_checkIfFacePlaneCov;
00111 CSemaphore m_enter_checkIfDiagonalSurface;
00112
00113 CSemaphore m_leave_checkIfFaceRegions;
00114 CSemaphore m_leave_checkIfFacePlaneCov;
00115 CSemaphore m_leave_checkIfDiagonalSurface;
00116
00117 CObservation3DRangeScan m_lastFaceDetected;
00118
00119 struct TMeasurement
00120 {
00121 bool takeMeasures;
00122
00123 vector_double lessEigenVals;
00124 vector_double errorEstimations;
00125 vector_double meanRegions;
00126
00127 vector_double sumDistances;
00128
00129 int faceNum;
00130 vector_uint deletedRegions;
00131 int numPossibleFacesDetected;
00132 int numRealFacesDetected;
00133
00134 bool takeTime;
00135
00136 bool saveMeasurementsToFile;
00137
00138 }m_measure;
00139
00140
00141 CTimeLogger m_timeLog;
00142
00143 std::vector<double> m_meanHist;
00144
00145
00146
00147
00148 bool checkIfFacePlane( CObservation3DRangeScan* face );
00149
00150 bool checkIfFacePlaneCov( CObservation3DRangeScan* face );
00151
00152 void thread_checkIfFacePlaneCov( );
00153
00154 static void dummy_checkIfFacePlaneCov( CFaceDetection *obj );
00155
00156
00157 bool checkIfFaceRegions( CObservation3DRangeScan* face );
00158
00159 void thread_checkIfFaceRegions( );
00160
00161 static void dummy_checkIfFaceRegions( CFaceDetection *obj );
00162
00163 size_t checkRelativePosition( const TPoint3D &p1, const TPoint3D &p2, const TPoint3D &p, double &dist );
00164
00165
00166 void thread_checkIfDiagonalSurface( );
00167
00168 bool checkIfDiagonalSurface( CObservation3DRangeScan* face );
00169
00170 bool checkIfDiagonalSurface2( CObservation3DRangeScan* face );
00171
00172 static void dummy_checkIfDiagonalSurface( CFaceDetection *obj );
00173
00174
00175
00176 void experimental_viewFacePointsScanned( const std::vector<float> &xs, const std::vector<float> &ys, const std::vector<float> &zs );
00177
00178 void experimental_viewFacePointsScanned( const CObservation3DRangeScan &face );
00179
00180 void experimental_viewFacePointsScanned( const std::vector<TPoint3D> &points );
00181
00182 void experimental_viewFacePointsAndEigenVects( const std::vector<CArrayDouble<3> > &pointsVector, const CMatrixDouble &eigenVect, const vector_double &eigenVal );
00183
00184 void experimental_viewRegions( const std::vector<TPoint3D> regions[9], const TPoint3D meanPos[3][3] );
00185
00186
00187
00188 void experimental_segmentFace( const CObservation3DRangeScan &face, CMatrixTemplate<bool> ®ion );
00189
00190
00191
00192 void experimental_calcHist( const CImage &face, const size_t &c1, const size_t &r1, const size_t &c2,
00193 const size_t &r2, CMatrixTemplate<unsigned int> &hist );
00194
00195
00196
00197 };
00198 }
00199
00200 }
00201
00202 #endif