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