Cpp-Processing
Functions
Detection Utilities

Utilities to work with celantur::CelanturDetection. More...

Collaboration diagram for Detection Utilities:

Functions

void celantur::serialise_image_metrics_to_json (cv::Mat image, std::vector< CelanturDetection > detections, std::string image_name, std::string input_folder, std::ostream &os)
 serialise detections to JSON format. Is identical to the celantur-container functionality. More...
 
std::vector< CelanturDetectioncelantur::deserialise_image_metrics_from_json (std::string_view is)
 Construct detections vector from the JSON string. More...
 
std::vector< CelanturDetectioncelantur::filter_detections_by_threshold (const std::vector< CelanturDetection > &detections, const ModelThresholds &thresholds)
 Filter detections based on confidence thresholds for different object classes. This function takes a vector of CelanturDetection objects and filters them according to the specified thresholds for each class. More...
 
std::vector< CelanturDetectioncelantur::filter_detections_by_class_name (const std::vector< CelanturDetection > &detections, const std::set< std::string > &classes)
 Filter detections based on a set of class names. This function takes a vector of CelanturDetection objects and filters them to include only those whose class names are present in the provided set. More...
 
std::vector< CelanturDetectioncelantur::filter_detections_by_class (const std::vector< CelanturDetection > &detections, const std::set< CelanturClassId > &classes)
 Filter detections by type. This function takes a vector of CelanturDetection objects and filters them to include only those whose class IDs are present in the provided set. More...
 
cv::Mat celantur::generate_binary_mask (const cv::Size &image_size, const std::vector< CelanturDetection > &detections, PerTypeProcessingConfig config)
 Generate a binary mask for a specific class from detections. This function creates a binary mask image where pixels corresponding to the specified class in the detections are set to 255 (white) and all other pixels are set to 0 (black). More...
 
cv::Mat celantur::visualise_detections (const cv::Mat image, std::vector< CelanturDetection > detections)
 Visualise detections on an image. This function takes an input image and a vector of CelanturDetection objects, and draws bounding boxes and class labels on the image to visualize the detections. Can be used for debug purposes. More...
 

Detailed Description

Utilities to work with celantur::CelanturDetection.

Function Documentation

◆ deserialise_image_metrics_from_json()

std::vector< CelanturDetection > celantur::deserialise_image_metrics_from_json ( std::string_view  is)

Construct detections vector from the JSON string.

Parameters
isjson string that needs to be deserialised

References celantur::CelanturDetection::box, celantur::CelanturDetection::class_id, celantur::CelanturDetection::class_name, and celantur::CelanturDetection::confidence.

◆ filter_detections_by_class()

std::vector< CelanturDetection > celantur::filter_detections_by_class ( const std::vector< CelanturDetection > &  detections,
const std::set< CelanturClassId > &  classes 
)

Filter detections by type. This function takes a vector of CelanturDetection objects and filters them to include only those whose class IDs are present in the provided set.

Parameters
detectionsThe vector of CelanturDetection objects to be filtered.
classesA set of CelanturClassId to filter by.
Returns
A vector of CelanturDetection objects whose class IDs are in the provided set.

References celantur::CelanturDetection::class_id.

◆ filter_detections_by_class_name()

std::vector< CelanturDetection > celantur::filter_detections_by_class_name ( const std::vector< CelanturDetection > &  detections,
const std::set< std::string > &  classes 
)

Filter detections based on a set of class names. This function takes a vector of CelanturDetection objects and filters them to include only those whose class names are present in the provided set.

Parameters
detectionsThe vector of CelanturDetection objects to be filtered.
classesA set of class names to filter by.
Returns
A vector of CelanturDetection objects whose class names are in the provided set.

References celantur::CelanturDetection::class_name.

◆ filter_detections_by_threshold()

std::vector< CelanturDetection > celantur::filter_detections_by_threshold ( const std::vector< CelanturDetection > &  detections,
const ModelThresholds thresholds 
)

Filter detections based on confidence thresholds for different object classes. This function takes a vector of CelanturDetection objects and filters them according to the specified thresholds for each class.

Parameters
detectionsThe vector of CelanturDetection objects to be filtered.
thresholdsThe ModelThresholds object containing the confidence thresholds for each class.
Returns
A vector of CelanturDetection objects that meet or exceed the specified thresholds.

References celantur::CelanturDetection::class_id, celantur::CelanturDetection::confidence, celantur::ModelThresholds::face, celantur::ModelThresholds::license_plate, celantur::ModelThresholds::person, and celantur::ModelThresholds::vehicle.

◆ generate_binary_mask()

cv::Mat celantur::generate_binary_mask ( const cv::Size &  image_size,
const std::vector< CelanturDetection > &  detections,
PerTypeProcessingConfig  config 
)

Generate a binary mask for a specific class from detections. This function creates a binary mask image where pixels corresponding to the specified class in the detections are set to 255 (white) and all other pixels are set to 0 (black).

Parameters
image_sizeThe size of the output mask image as a cv::Size object. Can be obtained from the original image with orig_img.size().
detectionsThe vector of CelanturDetection objects containing the detected objects.
configa config used to create the detection
Returns
A cv::Mat object representing the binary mask for the specified class.

References celantur::BBox_Oval, celantur::BBox_Rectangle, celantur::None, and celantur::Segmentation.

◆ serialise_image_metrics_to_json()

void celantur::serialise_image_metrics_to_json ( cv::Mat  image,
std::vector< CelanturDetection detections,
std::string  image_name,
std::string  input_folder,
std::ostream &  os 
)

serialise detections to JSON format. Is identical to the celantur-container functionality.

Parameters
imageThe input image as a cv::Mat object.
detectionsThe vector of CelanturDetection objects to be serialized.
image_nameThe name of the image (filename or custom identifier).
input_folderThe input folder path where the image is located.
osThe output stream where the JSON will be written.

◆ visualise_detections()

cv::Mat celantur::visualise_detections ( const cv::Mat  image,
std::vector< CelanturDetection detections 
)

Visualise detections on an image. This function takes an input image and a vector of CelanturDetection objects, and draws bounding boxes and class labels on the image to visualize the detections. Can be used for debug purposes.

Parameters
imageThe input image as a cv::Mat object.
detectionsThe vector of CelanturDetection objects to be visualized.
Returns
A new cv::Mat object with the detections drawn on it.