#ifndef HUMANDETECTIONMANAGE_H
#define HUMANDETECTIONMANAGE_H
#include "HumanDetection.h"
#include "Common.h"
#include "VidesData.h"
#include "ScopeSemaphoreExit.h"
#include "LicensePlateRecognition.h"
#include <QThread>
#include <random>
#include <QSemaphore>
#include <vector>
#include <opencv2/opencv.hpp>
#include <mutex>
class AlgorithmTaskManage{
public:
    AlgorithmTaskManage(int humanDetectionLen);
    ~AlgorithmTaskManage();
    static AlgorithmTaskManage& getInstance(int humanDetectionLen)
    {
        static AlgorithmTaskManage instance(humanDetectionLen);
        return instance;
    }
    void initHumanDetectionManage(const QString &modelPaths,
                                  float carShapeConfidence,float &height_reference,int &uniformColor);

    void initLicensePlateManage(const QString &modelPaths,
                                float carConfidence);
    
    int executeFindHuManCar(const cv::Mat &source,int res,std::vector<vides_data::ParkingArea> &currentPlate,
                            std::map<int,int>&resMap, QString sSn);

    void *schedulingAlgorithm(int scheType);


    void executeFindlicensePlateNumber(const cv::Mat &source, QString &lpNumber,vides_data::requestLicensePlate &plate,
                                       qint64 currentTime,QString sSn);
    
private:
    static AlgorithmTaskManage* instance;

    std::vector<HumanDetection*>humanDetections;
    
    std::vector<LicensePlateRecognition*>licensePlateRecognitions;
    
    int humanDetectionLen;

    QSemaphore semaphore;
    
    QSemaphore plateSemaphore;

    std::mutex mtxHuman;

    std::mutex mtxLicense;

    

};

#endif // HUMANDETECTIONMANAGE_H
