GStreamer Video Analytics (GVA) Plugin
Public Member Functions | Protected Attributes | List of all members
GVA::VideoFrame Class Reference

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. More...

#include <video_frame.h>

Public Member Functions

 VideoFrame (GstBuffer *buffer, GstVideoInfo *info)
 Construct VideoFrame instance from GstBuffer and GstVideoInfo. This is preferred way of creating VideoFrame. More...
 
 VideoFrame (GstBuffer *buffer, const GstCaps *caps)
 Construct VideoFrame instance from GstBuffer and GstCaps. More...
 
 VideoFrame (GstBuffer *buffer)
 Construct VideoFrame instance from GstBuffer. Video information will be obtained from buffer. This is not recommended way of creating VideoFrame, because it relies on GstVideoMeta which can be absent for the buffer. More...
 
GstVideoMeta * video_meta ()
 Get video metadata of buffer. More...
 
GstVideoInfo * video_info ()
 Get GstVideoInfo of this VideoFrame. This is preferrable way of getting any image information. More...
 
std::vector< RegionOfInterestregions ()
 Get RegionOfInterest objects attached to VideoFrame. More...
 
const std::vector< RegionOfInterestregions () const
 Get RegionOfInterest objects attached to VideoFrame. More...
 
std::vector< Tensortensors ()
 Get Tensor objects attached to VideoFrame. More...
 
const std::vector< Tensortensors () const
 Get Tensor objects attached to VideoFrame. More...
 
std::vector< std::string > messages ()
 Get messages attached to this VideoFrame. More...
 
RegionOfInterest add_region (double x, double y, double w, double h, std::string label=std::string(), double confidence=0.0, bool normalized=false)
 Attach RegionOfInterest to this VideoFrame. This function takes ownership of region_tensor, if passed. More...
 
Tensor add_tensor ()
 Attach empty Tensor to this VideoFrame. More...
 
void add_message (const std::string &message)
 Attach message to this VideoFrame. More...
 
void remove_region (const RegionOfInterest &roi)
 Remove RegionOfInterest. More...
 
void remove_tensor (const Tensor &tensor)
 Remove Tensor. More...
 

Protected Attributes

GstBuffer * buffer
 GstBuffer with inference results metadata attached (Gstreamer pipeline's GstBuffer, which is output of GVA inference elements, such as gvadetect, gvainference, gvaclassify)
 
std::unique_ptr< GstVideoInfo, std::function< void(GstVideoInfo *)> > info
 GstVideoInfo containing actual video information for this VideoFrame.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ VideoFrame() [1/3]

GVA::VideoFrame::VideoFrame ( GstBuffer *  buffer,
GstVideoInfo *  info 
)
inline

Construct VideoFrame instance from GstBuffer and GstVideoInfo. This is preferred way of creating VideoFrame.

Parameters
bufferGstBuffer* to which metadata is attached and retrieved
infoGstVideoInfo* containing video information

◆ VideoFrame() [2/3]

GVA::VideoFrame::VideoFrame ( GstBuffer *  buffer,
const GstCaps *  caps 
)
inline

Construct VideoFrame instance from GstBuffer and GstCaps.

Parameters
bufferGstBuffer* to which metadata is attached and retrieved
capsGstCaps* from which video information is obtained

◆ VideoFrame() [3/3]

GVA::VideoFrame::VideoFrame ( GstBuffer *  buffer)
inline

Construct VideoFrame instance from GstBuffer. Video information will be obtained from buffer. This is not recommended way of creating VideoFrame, because it relies on GstVideoMeta which can be absent for the buffer.

Parameters
bufferGstBuffer* to which metadata is attached and retrieved

Member Function Documentation

◆ add_message()

void GVA::VideoFrame::add_message ( const std::string &  message)
inline

Attach message to this VideoFrame.

Parameters
messagemessage to attach to this VideoFrame

◆ add_region()

RegionOfInterest GVA::VideoFrame::add_region ( double  x,
double  y,
double  w,
double  h,
std::string  label = std::string(),
double  confidence = 0.0,
bool  normalized = false 
)
inline

Attach RegionOfInterest to this VideoFrame. This function takes ownership of region_tensor, if passed.

Parameters
xx coordinate of the upper left corner of bounding box
yy coordinate of the upper left corner of bounding box
wwidth of the bounding box
hheight of the bounding box
labelobject label
confidencedetection confidence
normalizedif False, bounding box coordinates are pixel coordinates in range from 0 to image width/height. if True, bounding box coordinates normalized to [0,1] range.
Returns
new RegionOfInterest instance

◆ add_tensor()

Tensor GVA::VideoFrame::add_tensor ( )
inline

Attach empty Tensor to this VideoFrame.

Returns
new Tensor instance

◆ messages()

std::vector<std::string> GVA::VideoFrame::messages ( )
inline

Get messages attached to this VideoFrame.

Returns
messages attached to this VideoFrame

◆ regions() [1/2]

std::vector<RegionOfInterest> GVA::VideoFrame::regions ( )
inline

Get RegionOfInterest objects attached to VideoFrame.

Returns
vector of RegionOfInterest objects attached to VideoFrame

◆ regions() [2/2]

const std::vector<RegionOfInterest> GVA::VideoFrame::regions ( ) const
inline

Get RegionOfInterest objects attached to VideoFrame.

Returns
vector of RegionOfInterest objects attached to VideoFrame

◆ remove_region()

void GVA::VideoFrame::remove_region ( const RegionOfInterest roi)
inline

Remove RegionOfInterest.

Parameters
roithe RegionOfInterest to remove

◆ remove_tensor()

void GVA::VideoFrame::remove_tensor ( const Tensor tensor)
inline

Remove Tensor.

Parameters
tensorthe Tensor to remove

◆ tensors() [1/2]

std::vector<Tensor> GVA::VideoFrame::tensors ( )
inline

Get Tensor objects attached to VideoFrame.

Returns
vector of Tensor objects attached to VideoFrame

◆ tensors() [2/2]

const std::vector<Tensor> GVA::VideoFrame::tensors ( ) const
inline

Get Tensor objects attached to VideoFrame.

Returns
vector of Tensor objects attached to VideoFrame

◆ video_info()

GstVideoInfo* GVA::VideoFrame::video_info ( )
inline

Get GstVideoInfo of this VideoFrame. This is preferrable way of getting any image information.

Returns
GstVideoInfo of this VideoFrame

◆ video_meta()

GstVideoMeta* GVA::VideoFrame::video_meta ( )
inline

Get video metadata of buffer.

Returns
GstVideoMeta of buffer, nullptr if no GstVideoMeta available

The documentation for this class was generated from the following file: