class gstgva::region_of_interest::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. More…

class RegionOfInterest: public object {
public:
    // methods

    def rect(self self);
    def normalized_rect(self self);
    str label(self self);
    float confidence(self self);
    int object_id(self self);
    def set_object_id(self self, int object_id);
    def tensors(self self);
    Tensor detection(self self);
    int label_id(self self);
    Tensor add_tensor(self self, str name = "", Tensor tensor = None);
    VideoRegionOfInterestMeta meta(self self);
    def __init__(self self, VideoRegionOfInterestMeta roi_meta);
    def region_id(self self);
};

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

Methods#

def rect(self self)

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

Returns:

Bounding box coordinates of the RegionOfInterest

def normalized_rect(self self)

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

Returns:

Bounding box coordinates of the RegionOfInterest

str label(self self)

Get class label of this RegionOfInterest.

Returns:

Class label of this RegionOfInterest

float confidence(self self)

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

Returns:

last added detection Tensor confidence if exists, otherwise None

int object_id(self self)

Get object id.

Returns:

object id as an int, None if failed to get

def set_object_id(self self, int object_id)

Set object id.

Returns:

None

def tensors(self self)

Get all Tensor instances added to this RegionOfInterest.

Returns:

list of Tensor instances added to this RegionOfInterest

Tensor detection(self self)

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 VideoRegionOfInterestMeta 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(self self)

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

Returns:

last added detection Tensor label_id if exists, otherwise None

Tensor add_tensor(self self, str name = "", Tensor tensor = None)

Add new Tensor (inference result) to the RegionOfInterest.

Parameters:

name

Name for the tensor.

tensor

(optional) Tensor object. This function does not take ownership of tensor passed, but only copies its contents

Returns:

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

VideoRegionOfInterestMeta meta(self self)

Get VideoRegionOfInterestMeta containing bounding box information and tensors (inference results).

Tensors are represented as GstStructures added to GstVideoRegionOfInterestMeta.params

Returns:

VideoRegionOfInterestMeta containing bounding box and tensors (inference results)

def __init__(self self, VideoRegionOfInterestMeta roi_meta)

Construct RegionOfInterest instance from VideoRegionOfInterestMeta.

After this, RegionOfInterest will obtain all tensors (detection & inference results) from VideoRegionOfInterestMeta

Parameters:

roi_meta

VideoRegionOfInterestMeta containing bounding box information and tensors

def region_id(self self)

Get region ID.

Returns:

Region id as an int. Can be a positive or negative integer, but never zero.