$search
00001 00002 00003 00004 00005 00006 #ifndef __PEOPLEDETECTOR_H__ 00007 #define __PEOPLEDETECTOR_H__ 00008 00009 #ifdef __LINUX__ 00010 //#include "cob_vision_ipa_utils/MathUtils.h" 00011 //#include "cob_sensor_fusion/ColoredPointCloud.h" 00012 #else 00013 #include "cob_vision/cob_vision_ipa_utils/common/include/cob_vision_ipa_utils/MathUtils.h" 00014 #include "cob_vision/cob_sensor_fusion/common/include/cob_sensor_fusion/ColoredPointCloud.h" 00015 #endif 00016 #include <fstream> 00017 #include <set> 00018 #include <opencv/ml.h> 00019 #include <opencv/cv.h> 00020 00021 namespace ipa_PeopleDetector { 00022 00025 class PeopleDetector 00026 { 00027 public: 00028 00030 PeopleDetector(void); 00031 ~PeopleDetector(void); 00032 00037 virtual unsigned long Init(std::string directory); 00038 00044 virtual unsigned long DetectColorFaces(cv::Mat& img, std::vector<cv::Rect>& faceCoordinates); 00045 00052 virtual unsigned long DetectRangeFace(cv::Mat& img, std::vector<cv::Rect>& rangeFaceCoordinates, bool fillUnassignedDepthValues=false); 00053 00063 virtual unsigned long DetectFaces(cv::Mat& img, cv::Mat& rangeImg, std::vector<cv::Rect>& colorFaceCoordinates, std::vector<cv::Rect>& rangeFaceCoordinates, std::set<size_t>& colorToRangeFaceDependency, bool fillUnassignedDepthValues=false); 00064 00073 virtual unsigned long AddFace(cv::Mat& img, cv::Rect& face, std::string id, std::vector<cv::Mat>& images, std::vector<std::string>& ids); 00074 00081 virtual unsigned long ConvertAndResize(cv::Mat& img, cv::Mat& resized, cv::Rect& face); 00082 00086 virtual cv::Mat preprocessImage(cv::Mat& input_image); 00087 00096 virtual unsigned long PCA(int* nEigens, std::vector<cv::Mat>& eigenVectors, cv::Mat& eigenValMat, cv::Mat& avgImage, std::vector<cv::Mat>& images, cv::Mat& projectedTrainFaceMat); 00097 00112 virtual unsigned long RecognizeFace(cv::Mat& colorImage, std::vector<cv::Rect>& colorFaces, int* nEigens, std::vector<cv::Mat>& eigenVectArr, cv::Mat& avgImage, cv::Mat& projectedTrainFaceMat, 00113 std::vector<int>& index, int *threshold, int *threshold_FS, cv::Mat& eigenValMat, cv::SVM* personClassifier = 0); 00114 00125 virtual unsigned long ClassifyFace(float *projectedTestFace, int *nearest, int *nEigens, cv::Mat& projectedTrainFaceMat, int *threshold, cv::Mat& eigenValMat, cv::SVM* personClassifier = 0); 00126 00136 virtual unsigned long CalculateFaceClasses(cv::Mat& projectedTrainFaceMat, std::vector<std::string>& id, int *nEigens, cv::Mat& faceClassAvgProjections, std::vector<std::string>& idUnique, cv::SVM* personClassifier = 0); 00137 00138 double m_faces_increase_search_scale; 00139 int m_faces_drop_groups; 00140 int m_faces_min_search_scale_x; 00141 int m_faces_min_search_scale_y; 00142 00143 double m_range_increase_search_scale; 00144 int m_range_drop_groups; 00145 int m_range_min_search_scale_x; 00146 int m_range_min_search_scale_y; 00147 00148 private: 00152 unsigned long InterpolateUnassignedPixels(cv::Mat& img); 00153 00154 CvMemStorage* m_storage; 00155 CvHaarClassifierCascade* m_face_cascade; 00156 CvHaarClassifierCascade* m_range_cascade; 00157 }; 00158 00159 } // end namespace 00160 00161 #endif // __PEOPLEDETECTOR_H__