// Demo_Live_MFCDlg.h : 头文件 // #pragma once #include "afxwin.h" #include "opencv.hpp" #include #include #include #include "CWFaceConfig.h" // CDemo_Live_MFCDlg 对话框 class CDemo_Live_MFCDlg : public CDialogEx { // 构造 public: CDemo_Live_MFCDlg(CWnd* pParent = NULL); // 标准构造函数 // 对话框数据 enum { IDD = IDD_DEMO_LIVE_MFC_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 // 实现 protected: HICON m_hIcon; // 生成的消息映射函数 virtual BOOL OnInitDialog(); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); afx_msg void OnDestroy(); DECLARE_MESSAGE_MAP() afx_msg void OnBnClickedBtnInit(); afx_msg void OnBnClickedBtnOpenusb(); afx_msg void OnBnClickedBtnLiveCamera(); afx_msg void OnBnClickedBtnCamera(); afx_msg void OnBnClickedBtnLoad1(); afx_msg void OnBnClickedBtnLoad2(); afx_msg void OnBnClickedBtnPicLive(); afx_msg LRESULT OnThreadShowVideo(WPARAM wPapam, LPARAM lPapam); private: void ThreadFaceDet(); bool CreateFaceHandle(); void ReleaseFaceHandle(); void ShowVideo(char* szFrame,int iImgWidth,int iImgHeight); void ShowImg(CString sPicPath, HDC hDCVideo, RECT rectVideo); int GetFaceInfoByMat(void *pDetHandle, const cv::Mat &matImage, cw_face_res_t* pFaceBuffer); int GetNisLiveStateByMat(const cv::Mat &matImageVis, const cv::Mat &matImageNir, cw_nirliv_res_t *res); cw_errcode_t NirLivDet(char* imgDataVis, int iDataLenVis, int iWidthVis, int iHeightVis, cw_img_form_t formatVis, char* imgDataNir, int iDataLenNir, int iWidthNir, int iHeightNir, cw_img_form_t formatNir, cw_nirliv_det_rst_t *state, float *fScore); cw_errcode_t GetFaceInfoByImg(void *pDetHandle, char *pImgData, int iImgLen, int iWidth, int iHeight, cw_img_form_t format, cw_face_res_t* pFaceBuffer); private: typedef std::list ListMat; CEdit m_edtVersion; CEdit m_edtCameraLiveScore; CEdit m_edtCameraLiveResult; CEdit m_edtCameraLiveTime; CEdit m_edtPicLiveScore; CEdit m_edtPicLiveResult; CEdit m_edtPicLiveTime; CStatic m_staticVideo; // 显示USB摄像头的控件 RECT m_rectVideo; HDC m_hDCVideo; CStatic m_staticPic1; RECT m_rectPic1; HDC m_hDCPic1; CStatic m_staticPic2; RECT m_rectPic2; HDC m_hDCPic2; cv::VideoCapture m_captureVis; // 可见光摄像头操作对象 cv::VideoCapture m_captureNis; // 红外摄像头操作对象 ListMat m_listVisFrame; // 当前可见光帧链表,最多保存5帧,5帧中超过3帧为活体,即判断当前为活体 ListMat m_listNisFrame; // 当前红外帧链表 std::thread m_threadFaceDet; // 视频线程 std::mutex m_mutex; // 锁 CString m_sPic1Path; // 可见光图片路径 CString m_sPic2Path; // 红外图片路径 bool m_bStartThread; // 是否开启摄像头线程 bool m_bInitNirLiv; // 是否初始化红外活体服务 void* m_pDetThread; // 检测线程中的检测句柄,主要用来画人脸框 void* m_pNirLiv; //红外活体检测句柄 };