Cpp-Processing
CelanturSDKInterface.h
1 #pragma once
2 
3 #include <filesystem>
4 #include <opencv4/opencv2/core/types.hpp>
5 #include "CelanturDetection.h"
6 #include "CommonParameters.h"
7 
8 namespace celantur {
9  class Processor;
10 }
11 
12 namespace CelanturSDK {
16 class Processor;
17 
24  int context_width = 1280;
25  int context_height = 1280;
26 };
27 
28 
34  std::filesystem::path inference_plugin;
35 };
36 
44 class License {
45 friend class Processor;
46 public:
47  License(std::filesystem::path license_path);
48  License(const License& other);
49  License& operator=(const License& other);
50  License(License&& other) noexcept;
51  License& operator=(License&& other) noexcept;
52  ~License();
53 public:
54  void* _pimpl;
55 };
56 
62 class Anonymiser {
63 public:
64  Anonymiser(
65  std::filesystem::path license_path,
67  );
68  Anonymiser(const Anonymiser& other);
69  Anonymiser& operator=(const Anonymiser& other);
70  Anonymiser(Anonymiser&& other) noexcept;
71  Anonymiser& operator=(Anonymiser&& other) noexcept;
72  ~Anonymiser() = default;
73 
79  void anonymise(cv::Mat &mat, const celantur::CelanturDetection& det);
80 
86  void anonymise(cv::Mat &mat, const std::vector<celantur::CelanturDetection>& dets);
87 
94  void anonymise(cv::Mat &mat, const celantur::CelanturDetection& det, const celantur::PerTypeProcessingConfig& config);
95 
96 private:
98  License license_;
99 };
100 
101 
109 class Tracker {
110 public:
126  Tracker(
127  std::filesystem::path license_path,
128  float min_iou_threshold = 0.3f,
129  float high_score_threshold = 0.7f
130  );
131 
135  Tracker(const Tracker& other) = delete;
136  Tracker& operator=(const Tracker& other) = delete;
137  Tracker(Tracker&& other) noexcept;
138  Tracker& operator=(Tracker&& other) noexcept;
139  ~Tracker();
141 
150  void update(const std::vector<celantur::CelanturDetection>& detections);
151 
169  std::vector<celantur::CelanturDetection> get_lost_detections() const;
170 
175  void reset();
176 
182  void init_logging();
183 
184 private:
185  void* pimpl_;
186  License license_;
187 };
188 
196 public:
197  ModelCompiler(std::filesystem::path license, ModelCompilerParams params);
198  ModelCompiler(const ModelCompiler& other);
199  ModelCompiler& operator=(const ModelCompiler& other);
200  ModelCompiler(ModelCompiler&& other) noexcept;
201  ModelCompiler& operator=(ModelCompiler&& other) noexcept;
202  ~ModelCompiler();
203 
211  celantur::InferenceEnginePluginCompileSettings preload_model(std::filesystem::path model_path);
212 
223  void compile_model(celantur::InferenceEnginePluginCompileSettings settings, std::filesystem::path output_path);
224 private:
225  License _license;
226  void* _pimpl;
227 };
228 
229 
237 class Processor {
238 public:
249  Processor(celantur::ProcessorParams params, std::filesystem::path license_path);
250  Processor(const Processor& other);
251  Processor& operator=(const Processor& other);
252  Processor(Processor&& other);
253  Processor& operator=(Processor&& other);
254 
260  celantur::InferenceEnginePluginSettings get_inference_settings(std::filesystem::path model_path);
261 
270 
276  [[deprecated("Using this method does not allow for model-specific settings that are needed for OpenVINO and TensorRT plugins\n \
277  use celantur::InferenceEnginePluginSettings get_inference_settings(std::filesystem::path model_path instead\n \
278  To get better access to the new features for all inference plugins")]]
280 
290  [[deprecated("Using this method does not allow for model-specific settings that are needed for OpenVINO and TensorRT plugins\n \
291  use celantur::InferenceEnginePluginSettings get_inference_settings(std::filesystem::path model_path instead\n \
292  To get better access to the new features for all inference plugins")]]
294 
295  ~Processor();
296 
304  void process(cv::Mat mat);
305 
314  cv::Mat get_result();
315 
322  std::vector<celantur::CelanturDetection> get_detections();
323 
324 private:
325  void* _pimpl;
326  License _license;
327 };
328 } // namespace CelanturSDK
Applies blur to the given image based on the detection and processing config.
Definition: CelanturSDKInterface.h:62
Anonymiser(std::filesystem::path license_path, celantur::PerTypeProcessingConfig config)
Definition: CelanturSDKInterface.cpp:107
Anonymiser & operator=(const Anonymiser &other)
Definition: CelanturSDKInterface.cpp:124
void anonymise(cv::Mat &mat, const celantur::CelanturDetection &det)
anonymise the image detection using default configuration provided in constructor
Definition: CelanturSDKInterface.cpp:151
This class represents a loaded into memory license file;.
Definition: CelanturSDKInterface.h:44
License & operator=(const License &other)
Definition: CelanturSDKInterface.cpp:56
~License()
Definition: CelanturSDKInterface.cpp:76
void * _pimpl
Definition: CelanturSDKInterface.h:54
License(std::filesystem::path license_path)
Definition: CelanturSDKInterface.cpp:32
This class is used to compile the model for the inference engine plugin;.
Definition: CelanturSDKInterface.h:195
~ModelCompiler()
Definition: CelanturSDKInterface.cpp:409
ModelCompiler(std::filesystem::path license, ModelCompilerParams params)
Definition: CelanturSDKInterface.cpp:367
void compile_model(celantur::InferenceEnginePluginCompileSettings settings, std::filesystem::path output_path)
Compile the preloaded model with the given settings and save it to the given output path;.
Definition: CelanturSDKInterface.cpp:440
ModelCompiler & operator=(const ModelCompiler &other)
Definition: CelanturSDKInterface.cpp:387
celantur::InferenceEnginePluginCompileSettings preload_model(std::filesystem::path model_path)
Preload the model from the given path and return the settings that are needed to compile the model;.
Definition: CelanturSDKInterface.cpp:418
This the main class of SDK is used to process images and obtain the results.
Definition: CelanturSDKInterface.h:237
Processor & operator=(const Processor &other)
Definition: CelanturSDKInterface.cpp:284
Processor(celantur::ProcessorParams params, std::filesystem::path license_path)
Construct the processor object with the given Processor parameters and a path to the license file;.
Definition: CelanturSDKInterface.cpp:260
cv::Mat get_result()
get anonymised image that was processed by process() method
Definition: CelanturSDKInterface.cpp:250
std::vector< celantur::CelanturDetection > get_detections()
get the detections that were found in the last image that was processed; Note that this is necessary ...
Definition: CelanturSDKInterface.cpp:244
void process(cv::Mat mat)
Enqueue the given image (mat) for processing; This function is non-blocking and returns immediately;.
Definition: CelanturSDKInterface.cpp:255
celantur::InferenceEnginePluginSettings get_inference_settings()
Get the inference engine plugin settings;.
Definition: CelanturSDKInterface.cpp:329
~Processor()
Definition: CelanturSDKInterface.cpp:307
void load_inference_model(celantur::InferenceEnginePluginSettings settings, AdditionalProcessorParams params=AdditionalProcessorParams())
Load the preloaded inference model with the given settings;.
Definition: CelanturSDKInterface.cpp:360
Manages object persistence and state across sequential video frames. The Tracker takes raw detections...
Definition: CelanturSDKInterface.h:109
~Tracker()
Definition: CelanturSDKInterface.cpp:199
Tracker(std::filesystem::path license_path, float min_iou_threshold=0.3f, float high_score_threshold=0.7f)
Constructs a new Tracker instance.
Definition: CelanturSDKInterface.cpp:165
void update(const std::vector< celantur::CelanturDetection > &detections)
Processes a new frame of detections.
Definition: CelanturSDKInterface.cpp:204
std::vector< celantur::CelanturDetection > get_lost_detections() const
Retrieves detections associated with tracks currently in the 'Lost' state.
Definition: CelanturSDKInterface.cpp:209
Tracker(const Tracker &other)=delete
Tracker & operator=(const Tracker &other)=delete
void init_logging()
Initializes the internal logging system for the Tracker module.
Definition: CelanturSDKInterface.cpp:238
void reset()
Resets the tracker state.
Definition: CelanturSDKInterface.cpp:233
std::map< std::string, std::any > InferenceEnginePluginCompileSettings
The settings for compiling the model for the inference engine. The settings are passed as a map of ke...
Definition: CompilationParams.h:114
std::map< std::string, std::any > InferenceEnginePluginSettings
The settings for the inference engine used during runtime. The settings are passed as a map of key-va...
Definition: CompilationParams.h:108
std::map< CelanturClassId, DetectionProcessingConfig > PerTypeProcessingConfig
Configuration map for processing different detection types. This map associates each CelanturClassId ...
Definition: CommonParameters.h:129
Definition: CelanturSDKInterface.h:12
Definition: CelanturDetection.h:6
This struct contains the parameters for the Processor class.
Definition: CelanturSDKInterface.h:23
int context_width
Definition: CelanturSDKInterface.h:24
int context_height
Definition: CelanturSDKInterface.h:25
This struct contains the parameters for the ModelCompiler class.
Definition: CelanturSDKInterface.h:33
std::filesystem::path inference_plugin
Definition: CelanturSDKInterface.h:34
Structure to hold information about a detection made by the Celantur SDK.
Definition: CelanturDetection.h:18
Structure to hold parameters for the image processor. This structure contains various settings for co...
Definition: CommonParameters.h:287