CFaceRecProc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef CFACERECPROC_H
  2. #define CFACERECPROC_H
  3. #include "opencv2/opencv.hpp"
  4. #include "seeta/FaceDetector.h"
  5. #include "seeta/FaceLandmarker.h"
  6. #include "seeta/FaceRecognizer.h"
  7. #include "seeta/PoseEstimator.h"
  8. #include "seeta/FaceAntiSpoofing.h"
  9. #include "seeta/EyeStateDetector.h"
  10. #include <QString>
  11. #define SL_FACE_DETECT 999
  12. #define SL_MOUTH_OPEN 1
  13. #define SL_HEAD_LEFT 3//!< 向左转头
  14. #define SL_HEAD_RIGHT 4//!< 向右转头
  15. #define SL_HEAD_UP 5//!< 抬头
  16. #define SL_HEAD_DOWN 6//!< 低头
  17. #define SL_EYE_CLOSE 10//!< 闭眼
  18. #define SL_EYE_OPEN 11//!< 睁眼
  19. enum
  20. {
  21. NO_FACE,
  22. BLUR,
  23. DARK,
  24. BRIGHT,
  25. ANGLE_TOOLARGE
  26. };
  27. class CFaceRecProc
  28. {
  29. public:
  30. CFaceRecProc();
  31. ~CFaceRecProc();
  32. QString errorMsg();
  33. bool getFaceCount(cv::Mat faceMat, int &nFaceCount);
  34. bool getFaceCount(QString sFaceImage, int &nFaceCount);
  35. bool getFaceAttribute(QString sFaceImage, int nFaceStatus, bool &bHasStatus, int &nFaceCount);
  36. bool getFaceAttribute(cv::Mat faceMat, int nFaceStatus, bool &bHasStatus, int &nFaceCount);
  37. /*fYaw 绕Y轴, fPitch垂直 绕x轴, fRoll 绕z轴 角度
  38. * y z
  39. * | /
  40. fYaw | /fRoll
  41. |/____x fPitch
  42. */
  43. bool getFaceAttribute(cv::Mat faceMat, float &fYaw, float &fPitch, float &fRoll, int &nFaceCount);
  44. bool faceCompare(cv::Mat faceMat, cv::Mat baseMat, int &nfaceCount, float &fScore);
  45. bool faceCompare(QString sFaceImage, QString sBaseImge, int &nfaceCount, float &fScore);
  46. bool setBaseImage(cv::Mat baseMat);
  47. bool setBaseImage(QString sBaseImge);
  48. bool compareWithBase(cv::Mat faceMat, int &nfaceCount, float &fScore);
  49. bool compareWithBase(QString sFaceImage, int &nfaceCount, float &fScore);
  50. bool faceRealness(cv::Mat faceMat, bool &bRealness);
  51. bool compareWithBase(cv::Mat faceMat, int &nfaceCount, float &fScore, SeetaRect &rt);
  52. bool compareWithBase(cv::Mat faceMat, int &nfaceCount, float &fScore, bool &bEyeClose);
  53. bool compareWithBase(cv::Mat faceMat, int &nfaceCount, float &fScore, bool &bEyeClose, bool bIsCampare, bool bIsCheckEye);
  54. bool compareWithBaseRealness(cv::Mat faceMat, int &nfaceCount, float &fScore, bool &bRealness);
  55. bool getMaxFaceScoreWithBase(cv::Mat faceMat, int &nfaceCount, float &fScore, bool &bRealness, int &nTime);
  56. bool hasBaseImage();
  57. float* getFeature();
  58. void setBaseFeature(float *feature);
  59. private:
  60. int InitHandle(std::string model_path);
  61. void destroyHandle();
  62. seeta::FaceDetector *m_pFaceDetector;//人脸检测
  63. seeta::FaceLandmarker *m_pFaceLandmarker;//特征值
  64. seeta::FaceRecognizer *m_pFaceRecognizer;//人脸识别
  65. seeta::PoseEstimator *m_pPoseEstimator;//姿态
  66. seeta::FaceAntiSpoofing *m_pFaceAntiSpoofing;//真实性
  67. seeta::EyeStateDetector *m_pEyeStateDetector;
  68. std::shared_ptr<float> m_baseFeaturePtr;
  69. QString m_sErrMsg;
  70. };
  71. extern std::shared_ptr<CFaceRecProc> g_faceRecProcPtr;
  72. #endif // CFACERECPROC_H