#ifndef CINPROGRESSFACE_H
#define CINPROGRESSFACE_H

#include <QObject>
#include "CHttpBll.h"
#include <opencv2/opencv.hpp>
#include <thread>
#include <mutex>

class CInprogressFace : public QObject
{
    Q_OBJECT

signals:
    void compareFailed(QString sErrorMsg);
public:
    CInprogressFace();
    ~CInprogressFace();

    void startFaceVerify(bool bVerify);
    void addImage(cv::Mat matImage);
    void addFaceCountImage(cv::Mat matImage);

    void uploadFile(cv::Mat faceMat, int nFaceCount, float fScore, int nRealness);
private slots:
    void onClientExamProcessUploadSign(CClientExamProcessUploadSign processUpload); //文件上传
    void onUploadFileToAliyun(CUploadFileToAliyun uploadFileToAliyun);
    void onSaveFaceCaptureResult(CBaseResponsePackage res);//保存人脸抓拍比对验证结果
private:
    std::thread m_thread;
    bool m_bIsRun;

    void threadProc();
    void genCameraInfo();

    std::mutex m_mImgList;
    std::list<cv::Mat> m_vImgList;
    std::mutex m_mImgFaceCountList;
    std::list<cv::Mat> m_vImgFaceCountList;

    bool m_bStart;
    __int64 m_nLastFaceCountTime = 0;
    QString m_sCameraInfo = "";
    bool m_bHasVirtualCamera = false;
};

extern std::shared_ptr<CInprogressFace> g_inProcessFace;

#endif // CINPROGRESSFACE_H
