class GVA::RegionOfInterest#

Overview#

This class represents region of interest - object describing detection result (bounding box) and containing multiple Tensor objects (inference results) attached by multiple models. For example, it can be region of interest with detected face and recognized age and sex of a person. It can be produced by a pipeline with gvadetect with detection model and two gvaclassify elements with two classification models. Such RegionOfInterest will have bounding box coordinates filled and will have 3 Tensor objects attached - 1 Tensor object with detection result and 2 Tensor objects with classification results coming from 2 classifications. More…

#include <region_of_interest.h>

class RegionOfInterest {
public:
    // construction

    RegionOfInterest(GstVideoRegionOfInterestMeta* meta);

    // methods

    Rect<uint32_t> rect() const;
    Rect<double> normalized_rect();
    std::string label() const;
    double confidence() const;
    int32_t object_id() const;
    std::vector<Tensor> tensors() const;
    Tensor add_tensor(const std::string& name);
    Tensor detection();
    int label_id() const;
    int region_id();
    void set_label(std::string label);
    void set_object_id(int32_t id);
    GstVideoRegionOfInterestMeta* _meta() const;
};

Detailed Documentation#

This class represents region of interest - object describing detection result (bounding box) and containing multiple Tensor objects (inference results) attached by multiple models. For example, it can be region of interest with detected face and recognized age and sex of a person. It can be produced by a pipeline with gvadetect with detection model and two gvaclassify elements with two classification models. Such RegionOfInterest will have bounding box coordinates filled and will have 3 Tensor objects attached - 1 Tensor object with detection result and 2 Tensor objects with classification results coming from 2 classifications.

Construction#

RegionOfInterest(GstVideoRegionOfInterestMeta* meta)

Construct RegionOfInterest instance from GstVideoRegionOfInterestMeta. After this, RegionOfInterest will obtain all tensors (detection & inference results) from GstVideoRegionOfInterestMeta.

Parameters:

meta

GstVideoRegionOfInterestMeta containing bounding box information and tensors

Methods#

Rect<uint32_t> rect() const

Get bounding box of the RegionOfInterest as pixel coordinates in original image.

Returns:

Bounding box coordinates of the RegionOfInterest

Rect<double> normalized_rect()

Get bounding box of the RegionOfInterest as normalized coordinates in the range [0, 1].

Returns:

Bounding box coordinates of the RegionOfInterest

std::string label() const

Get RegionOfInterest label.

Returns:

RegionOfInterest label

double confidence() const

Get RegionOfInterest detection confidence (set by gvadetect)

Returns:

last added detection Tensor confidence if exists, otherwise 0.0

int32_t object_id() const

Get unique id of the RegionOfInterest. The id typically created by gvatrack element.

Returns:

Unique id, or zero value if not found

std::vector<Tensor> tensors() const

Get all Tensor instances added to this RegionOfInterest.

Returns:

vector of Tensor instances added to this RegionOfInterest

Tensor add_tensor(const std::string& name)

Add new tensor (inference result) to this RegionOfInterest with name set. To add detection tensor, set name to “detection”.

Parameters:

name

name for the tensor. If name is set to “detection”, detection Tensor will be created and set for this RegionOfInterest

Returns:

just created Tensor object, which can be filled with tensor information further

Tensor detection()

Returns detection Tensor, last added to this RegionOfInterest. As any other Tensor, returned detection Tensor can contain arbitrary information. If you use RegionOfInterest based on GstVideoRegionOfInterestMeta attached by gvadetect by default, then this Tensor will contain “label_id”, “confidence”, “x_min”, “x_max”, “y_min”, “y_max” fields. If RegionOfInterest doesn’t have detection Tensor, it will be created in-place.

Returns:

detection Tensor, empty if there were no detection Tensor objects added to this RegionOfInterest when this method was called

int label_id() const

Get label_id from detection Tensor, last added to this RegionOfInterest.

Returns:

last added detection Tensor label_id if exists, otherwise 0

int region_id()

Access RegionOfInterest ID Use this method to get RegionOfInterest ID. ID is generated with “GVA::VideoFrame::add_region()” call. Region ID can be a positive or negative integer, but never zero.

Returns:

ID field value

void set_label(std::string label)

Set RegionOfInterest label.

Parameters:

label

Label to set

void set_object_id(int32_t id)

Set object ID.

Parameters:

id

ID to set

GstVideoRegionOfInterestMeta* _meta() const

Internal function, don’t use or use with caution.

Returns:

pointer to underlying GstVideoRegionOfInterestMeta