#ifndef ANSOVSEG_H
#define ANSOVSEG_H
#pragma once
#include "ANSEngineCommon.h"
#include <string>
#include <opencv2/opencv.hpp>
#include <openvino/openvino.hpp>
#include <array>

namespace ANSCENTER
{
    class ANSENGINE_API ANSOVSEG : public ANSODBase
    {
    public:
        virtual bool Initialize(std::string licenseKey, ModelConfig modelConfig, const std::string& modelZipFilePath, const std::string& modelZipPassword, std::string& labelMap) override;
        virtual bool LoadModel(const std::string& modelZipFilePath, const std::string& modelZipPassword) override;
        virtual bool LoadModelFromFolder(std::string licenseKey, ModelConfig modelConfig, std::string modelName, std::string className,const std::string& modelFolder, std::string& labelMap)override;
        virtual bool OptimizeModel(bool fp16, std::string& optimizedModelFolder);
        std::vector<Object> RunInference(const cv::Mat& input);
        std::vector<Object> RunInference(const cv::Mat& input, const std::string& camera_id);
        bool Destroy();
		~ANSOVSEG();
    private:
        std::string     _modelFilePath;
    private:
        void InitialModel();
        cv::Mat PreProcessing(const cv::Mat& source);
        cv::Rect GetBoundingBox(const cv::Rect& src);
        std::vector<Object>PostProcessing(const std::string& camera_id);
        float sigmoid_function(float a);
        cv::Mat resized_frame_;
        cv::Point2f factor_;
        cv::Size2f model_input_shape_;
        cv::Size model_output_shape_;

        ov::Tensor input_tensor_;
        ov::InferRequest inference_request_;
        ov::CompiledModel compiled_model_;
        
		// For visualization
        std::vector<cv::Scalar> colors = { cv::Scalar(255, 0, 0), cv::Scalar(255, 0, 255), cv::Scalar(170, 0, 255), cv::Scalar(255, 0, 85),
                                   cv::Scalar(255, 0, 170), cv::Scalar(85, 255, 0), cv::Scalar(255, 170, 0), cv::Scalar(0, 255, 0),
                                   cv::Scalar(255, 255, 0), cv::Scalar(0, 255, 85), cv::Scalar(170, 255, 0), cv::Scalar(0, 85, 255),
                                   cv::Scalar(0, 255, 170), cv::Scalar(0, 0, 255), cv::Scalar(0, 255, 255), cv::Scalar(85, 0, 255) };
    };
}

#endif
