#ifndef FACECOMPARE_H
#define FACECOMPARE_H

#include <QWidget>
#include <opencv2/opencv.hpp>

#include <QTimer>
#include <thread>
#include <mutex>
#include "CHttpBll.h"
#include "CLiveViodeProc.h"
#include "skipFaceCompare.h"

namespace Ui {
class faceCompare;
}

class faceCompare : public QWidget, ITRTCVideoRenderCallback
{
    Q_OBJECT

signals:
    void exitFaceCompare();
    void faceComparePass();

    void compareFailed(QString sErrorMsg);
public:
    explicit faceCompare(QWidget *parent = nullptr);
    ~faceCompare();

private slots:
    void on_btn_fc_compare_clicked();

    void on_btn_fc_close_clicked();

    void onClientExamProcessUploadSign(CClientExamProcessUploadSign processUpload); //文件上传
    void onUploadFileToAliyun(CUploadFileToAliyun uploadFileToAliyun);
    void onSaveFaceCompareResult(CBaseResponsePackage res);//保存人脸识别比对验证结果

    void onDownLoadFile(CDownLoadFileInfo downLoadFileInfo);
private:
    void onRenderVideoFrame(const char* userId, TRTCVideoStreamType streamType, TRTCVideoFrame* frame);
    void initUI();
    bool setBaseImage();

    Ui::faceCompare *ui;

	
	std::shared_ptr<QTimer> m_pVideoTimer;
    std::shared_ptr<skipFaceCompare> m_pSkipFaceCompare;


    void threadProc();

    __int64 m_lastFaceTime = 0;

    std::thread m_thread;
    bool m_bIsRun;
    bool m_bStartCompare;
    cv::Mat m_nCurImage;
    std::mutex m_imageMutex;
	float m_fScore;
	int m_nFaceCount;
	int m_nTime;
};

#endif // FACECOMPARE_H
