#pragma once

#include "ANSOCRBase.h"
#include "ANSRTOCR/PaddleOCRV5RTEngine.h"
#include <memory>
#include <mutex>

namespace ANSCENTER {

class ANSOCR_API ANSRTOCR : public ANSOCRBase {
public:
    ANSRTOCR() : _engine(std::make_unique<rtocr::PaddleOCRV5RTEngine>()) {}
    ~ANSRTOCR();

    virtual bool Initialize(const std::string& licenseKey, OCRModelConfig modelConfig,
        const std::string& modelZipFilePath, const std::string& modelZipPassword,
        int engineMode) override;

    std::vector<ANSCENTER::OCRObject> RunInference(const cv::Mat& input) override;
    std::vector<ANSCENTER::OCRObject> RunInference(const cv::Mat& input, const std::string& cameraId) override;
    std::vector<ANSCENTER::OCRObject> RunInference(const cv::Mat& input, const std::vector<cv::Rect>& Bbox) override;
    std::vector<ANSCENTER::OCRObject> RunInference(const cv::Mat& input, const std::vector<cv::Rect>& Bbox, const std::string& cameraId) override;

    bool Destroy() override;

private:
    std::unique_ptr<rtocr::PaddleOCRV5RTEngine> _engine;
    std::recursive_mutex _mutex;
};

} // namespace ANSCENTER
