class gstgva::video_frame::VideoFrame#

Overview#

This class represents video frame - object for working with RegionOfInterest and Tensor objects which belong to this video frame (image). More…

class VideoFrame {
public:
    // methods

    def __init__(
        self self,
        Gst.Buffer buffer,
        GstVideo.VideoInfo video_info = None,
        Gst.Caps caps = None
    );

    GstVideo.VideoMeta video_meta(self self);
    GstVideo.VideoInfo video_info(self self);
    def regions(self self);
    def tensors(self self);

    RegionOfInterest add_region(
        self self,
        x x,
        y y,
        w w,
        h h,
        str label = "",
        float confidence = 0.0,
        bool normalized = False
    );

    Tensor add_tensor(self self);
    List[str] messages(self self);
    def add_message(self self, str message);
    def remove_message(self self, str message);
    None remove_region(self self, roi roi);
    numpy.ndarray data(self self, Gst.MapFlags flag = Gst.MapFlags.READ);
};

Detailed Documentation#

This class represents video frame - object for working with RegionOfInterest and Tensor objects which belong to this video frame (image).

RegionOfInterest describes detected object (bounding boxes) and its Tensor objects (inference results on RegionOfInterest level). Tensor describes inference results on VideoFrame level. VideoFrame also provides access to underlying GstBuffer and GstVideoInfo describing frame’s video information (such as image width, height, channels, strides, etc.). You also can get cv::Mat object representing this video frame.

Methods#

def __init__(
    self self,
    Gst.Buffer buffer,
    GstVideo.VideoInfo video_info = None,
    Gst.Caps caps = None
)

Construct VideoFrame instance from Gst.Buffer and GstVideo.VideoInfo or Gst.Caps.

The preferred way of creating VideoFrame is to use Gst.Buffer and GstVideo.VideoInfo

Parameters:

buffer

Gst.Buffer to which metadata is attached and retrieved

video_info

GstVideo.VideoInfo containing video information

caps

Gst.Caps from which video information is obtained

GstVideo.VideoMeta video_meta(self self)

Get video metadata of buffer.

Returns:

GstVideo.VideoMeta of buffer, nullptr if no GstVideo.VideoMeta available

GstVideo.VideoInfo video_info(self self)

Get GstVideo.VideoInfo of this VideoFrame.

This is preferrable way of getting any image information

Returns:

GstVideo.VideoInfo of this VideoFrame

def regions(self self)

Get RegionOfInterest objects attached to VideoFrame.

Returns:

iterator of RegionOfInterest objects attached to VideoFrame

def tensors(self self)

Get Tensor objects attached to VideoFrame.

Returns:

iterator of Tensor objects attached to VideoFrame

RegionOfInterest add_region(
    self self,
    x x,
    y y,
    w w,
    h h,
    str label = "",
    float confidence = 0.0,
    bool normalized = False
)

Attach RegionOfInterest to this VideoFrame.

Parameters:

x

x coordinate of the upper left corner of bounding box

y

y coordinate of the upper left corner of bounding box

w

bounding box width

h

bounding box height

label

object label

confidence

detection confidence

region_tensor

base tensor for detection Tensor which will be added to this new

normalized

if True, input coordinates are assumed to be normalized (in [0,1] interval). If False, input coordinates are assumed to be expressed in pixels (this is behavior by default)

Returns:

new RegionOfInterest instance

Tensor add_tensor(self self)

Attach empty Tensor to this VideoFrame.

Returns:

new Tensor instance

List[str] messages(self self)

Get messages attached to this VideoFrame.

Returns:

messages attached to this VideoFrame

def add_message(self self, str message)

Attach message to this VideoFrame.

Parameters:

message

message to attach to this VideoFrame

def remove_message(self self, str message)

Remove message from this VideoFrame.

Parameters:

message

message to remove

None remove_region(self self, roi roi)

Remove region with the specified index.

Parameters:

roi

Region to remove

numpy.ndarray data(self self, Gst.MapFlags flag = Gst.MapFlags.READ)

Get buffer data wrapped by numpy.ndarray.

Returns:

numpy array instance