Cpp-Processing
CommonParameters.h
1 #pragma once
2 #include <filesystem>
3 #include <CPUInfo.h>
4 #include <opencv4/opencv2/core.hpp>
5 // Ignore the warning for the unused include, it is here for the backward compatibility
6 #include <variant>
7 #include "CompilationParams.h"
8 #include "CelanturExceptions.h"
9 
10 namespace celantur {
27  enum class BlurType {
28  None = 0,
29  BBox_Oval = 1,
30  BBox_Rectangle = 2,
31  Segmentation = 3,
32  };
33 
39  enum class CelanturClassId {
40  LicensePlate = 101,
41  Person = 102,
42  Face = 103,
43  Vehicle = 104,
44  };
45 
64  float gradient_start{0.3};
74  float gradient_stop{0.0};
84  float kernel_size{0.2f};
85 
92  bool beautify_blur{true};
93  };
94 
101  typedef std::map<CelanturClassId, DetectionProcessingConfig> PerTypeProcessingConfig;
102 
107  (
108  {
110 
112  0.3f,
113  0.0f,
114  1.0f,
115  true
116  }},
120  0.3f,
121  0.0f,
122  0.2f,
123  true
124  }},
126  }
127  );
128 
140  std::filesystem::path inference_plugin;
142  int n_tiles_x{1};
144  int n_tiles_y{1};
146  float ol_x{0.0f};
148  float ol_y{0.0f};
150  bool swapRB{false};
152  cv::Rect_<float> roi{0.0f, 0.0f, 1.0f, 1.0f};
159  float nms_threshold{0.5f};
169  int queue_size{std::numeric_limits<int>::max()};
174  };
175 
176 
183  enum class Rotation {
184  None = 0,
185  Rotated90Clockwise = 1,
186  Rotated180 = 2,
188  };
193  struct ImageMetadata {
194 
195  };
196 
201  struct FrameMetadata {
202  int frame_number{-1};
203  int source_id{0};
204  bool vertical_flip{false};
205  bool horizontal_flip{false};
207  };
208 
213  struct MatContainer {
214  cv::Mat mat;
215  std::variant<ImageMetadata, FrameMetadata> metadata;
216  };
219 } // namespace celantur
220 
221 
226 std::ostream& operator<<(std::ostream& os, const celantur::BlurType& blur_type);
227 std::istream& operator>>(std::istream& os, celantur::BlurType& blur_type);
228 
229 std::ostream& operator<<(std::ostream& os, const celantur::CelanturClassId& id);
230 std::istream& operator>>(std::istream& os, celantur::CelanturClassId& id);
const PerTypeProcessingConfig DEFAULT_PER_TYPE_PROCESSING_CONFIG({ {CelanturClassId::LicensePlate, DetectionProcessingConfig{ BlurType::BBox_Rectangle, 0.3f, 0.0f, 1.0f, true }}, {CelanturClassId::Person, {BlurType::None}}, {CelanturClassId::Face, { BlurType::BBox_Oval, 0.3f, 0.0f, 0.2f, true }}, {CelanturClassId::Vehicle, {BlurType::None}}, })
Default per-type processing configuration.
std::ostream & operator<<(std::ostream &os, const celantur::BlurType &blur_type)
Definition: CommonParameters.cpp:6
std::istream & operator>>(std::istream &os, celantur::BlurType &blur_type)
Definition: CommonParameters.cpp:24
Rotation
Enum to represent image rotation states. is used in celantur::FrameMetadata to describe the rotation ...
Definition: CommonParameters.h:183
BlurType
Enum to describe the blur in celantur::DetectionProcessingConfig.
Definition: CommonParameters.h:27
std::map< CelanturClassId, DetectionProcessingConfig > PerTypeProcessingConfig
Configuration map for processing different detection types. This map associates each CelanturClassId ...
Definition: CommonParameters.h:101
CelanturClassId
Class ids enum that is used in celantur::CelanturDetection and celantur::DetectionProcessingConfig to...
Definition: CommonParameters.h:39
Definition: CelanturDetection.h:6
Configuration that describes processing of a particular class This structure contains the type of blu...
Definition: CommonParameters.h:52
bool beautify_blur
If true, applies additional beautification to the blur effect, making it visually more appealing....
Definition: CommonParameters.h:92
float gradient_stop
Responsible for the point where the blur is absolute. Value of 0.0 guarantees that the blur will be a...
Definition: CommonParameters.h:74
float kernel_size
Responsible for strength of the blur applied. Values between 0.0 and 1.0 are considered relative to t...
Definition: CommonParameters.h:84
BlurType blur_type
celantur::BlurType of blur to be applied to the detection.
Definition: CommonParameters.h:57
float gradient_start
Responsible for the starting point of the gradient blur. Larger values mean that the blur starts furh...
Definition: CommonParameters.h:64
Metadata associated with a video frame. for now, just a placeholder.
Definition: CommonParameters.h:201
int frame_number
Definition: CommonParameters.h:202
int source_id
Definition: CommonParameters.h:203
bool vertical_flip
Definition: CommonParameters.h:204
Rotation rotation
Definition: CommonParameters.h:206
bool horizontal_flip
Definition: CommonParameters.h:205
Metadata associated with an image or frame. for now, just a placeholder.
Definition: CommonParameters.h:193
Container for an image and its associated metadata. for now, just a placeholder.
Definition: CommonParameters.h:213
std::variant< ImageMetadata, FrameMetadata > metadata
Definition: CommonParameters.h:215
cv::Mat mat
Definition: CommonParameters.h:214
Structure to hold model threshold values for different object classes. This structure contains thresh...
Definition: CompilationParams.h:86
Structure to hold parameters for the image processor. This structure contains various settings for co...
Definition: CommonParameters.h:134
bool swapRB
Swap Red and Blue channels. Useful when input data is in BGR format (when its loaded with OpenCV for ...
Definition: CommonParameters.h:150
int queue_size
Specifies the maximum size of the queue.
Definition: CommonParameters.h:169
float ol_y
Overlap of tiles in vertical direction as a fraction of tile height.
Definition: CommonParameters.h:148
int n_tiles_x
Number of tiles in horizontal direction.
Definition: CommonParameters.h:142
cv::Rect_< float > roi
Region of interest. Measured from 0 to 1 The region of interest is a rectangle that defines the area ...
Definition: CommonParameters.h:152
std::filesystem::path inference_plugin
Definition: CommonParameters.h:140
ModelThresholds thresholds
The thresholds for the model.
Definition: CommonParameters.h:154
float ol_x
Overlap of tiles in horizontal direction as a fraction of tile width.
Definition: CommonParameters.h:146
float nms_threshold
The NMS threshold (Non-Maximum Suppression threshold) is used during the process to eliminate redunda...
Definition: CommonParameters.h:159
PerTypeProcessingConfig per_type_processing_config
Fine-tuning the processing of detections based on their class.
Definition: CommonParameters.h:173
int n_tiles_y
Number of tiles in vertical direction.
Definition: CommonParameters.h:144