#include "ANSLIB.h"

class CUSTOM_API ANSCustomFallDetector : public IANSCustomClass
{
private:
	using ANSLIBPtr = std::unique_ptr<ANSCENTER::ANSLIB, decltype(&ANSCENTER::ANSLIB::Destroy)>;

	int						engineType{ 0 };
	ANSLIBPtr _detector{ nullptr, &ANSCENTER::ANSLIB::Destroy };
	ANSLIBPtr _motiondetector{ nullptr, &ANSCENTER::ANSLIB::Destroy };

	std::recursive_mutex	_mutex;
	cv::Rect                _detectedArea;
	cv::Rect                _previousDetectedArea;
	int                     _retainDetectedArea{ 0 };
	bool				    _isFallDetected{ false };
	float                   _detectionScoreThreshold{ 0.5 };

	// ----- Model config -----
	int _detectorModelType;
	int _detectorDetectionType;
	int _motionModelType;
	int _motionDetectionType;

	cv::Rect                GenerateMinimumSquareBoundingBox(const std::vector<ANSCENTER::Object>& detectedObjects, int minSize = 640);

public:
	bool Initialize(const std::string& modelDiretory, float detectionScoreThreshold, std::string& labelMap)override;
	bool OptimizeModel(bool fp16)override;
	std::vector<CustomObject> RunInference(const cv::Mat& input)override;
	std::vector<CustomObject> RunInference(const cv::Mat& input, const std::string& camera_id)override;
	bool Destroy()override;
	ANSCustomFallDetector();
	~ANSCustomFallDetector();
};
