53 lines
2.5 KiB
C
53 lines
2.5 KiB
C
|
|
#ifndef ANSOYOLOV10OVOD_H
|
||
|
|
#define ANSOYOLOV10OVOD_H
|
||
|
|
#pragma once
|
||
|
|
#include "ANSEngineCommon.h"
|
||
|
|
#include<openvino/openvino.hpp>
|
||
|
|
namespace ANSCENTER {
|
||
|
|
class ANSENGINE_API ANSOYOLOV10OVOD :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();
|
||
|
|
~ANSOYOLOV10OVOD();
|
||
|
|
private:
|
||
|
|
std::string _modelFilePath;
|
||
|
|
float m_ratio = 1;
|
||
|
|
float m_imgWidth = 0;
|
||
|
|
float m_imgHeight = 0;
|
||
|
|
|
||
|
|
// ADD THESE for batch processing
|
||
|
|
std::vector<int> m_batchImgHeights;
|
||
|
|
std::vector<int> m_batchImgWidths;
|
||
|
|
|
||
|
|
std::vector<float> _inputData; // Reusable buffer for input tensor data
|
||
|
|
cv::Mat _frameBuffer; // Reusable buffer for preprocessing
|
||
|
|
|
||
|
|
private:
|
||
|
|
void InitialModel(const std::string& model_path);
|
||
|
|
void InitModelStaticBatchSize(const std::string& model_path);
|
||
|
|
void Preprocessing(cv::Mat* img, int length, float* factor, std::vector<float>& data);
|
||
|
|
cv::Mat resizeKeepAspectRatioPadRightBottom(const cv::Mat& input, size_t height, size_t width, const cv::Scalar& bgcolor);
|
||
|
|
std::vector<Object> PostProcessing(float* result, float factor, int outputLength, const std::string& camera_id);
|
||
|
|
std::vector<Object> PostProcessingBatch(float* result,
|
||
|
|
const std::vector<float>& factors,
|
||
|
|
int outputLength,
|
||
|
|
int batchSize,
|
||
|
|
const std::string& camera_id);
|
||
|
|
void PreprocessingBatch(const std::vector<cv::Mat>& images,
|
||
|
|
int length,
|
||
|
|
std::vector<float>& factors,
|
||
|
|
std::vector<float>& data);
|
||
|
|
std::vector<Object> DetectObjectsBatch(const std::vector<cv::Mat>& inputImages,
|
||
|
|
const std::string& camera_id);
|
||
|
|
ov::InferRequest request;
|
||
|
|
ov::CompiledModel compiled_model;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
#endif
|