The vvas_xmetaaffixer plug-in is designed to adjust the metadata information for different resolutions. When performing machine learning on a frame with a different resolution or color format from the original, the metadata can still be associated with the original, full-resolution frame. The vvas_metaaffixer includes two types of pads: master pads and slave pads. The number of input pads created depends on the number of input sources and can be requested as needed. The plug-in requires at least one mandatory master input pad (sink pad) to receive the original/reference metadata, while the remaining input pads are referred to as slave pads. The metadata received on the master sink pad is adjusted based on the resolution of each slave sink pad. The adjusted metadata is then added to the output buffer coming out of the source slave pads. Up to 16 slave pads can be created as required.
For insight into the implementation details, refer to the vvas_xmetaaffixer source code located at <vvas>/vvas-gst-plugins/gst/metaaffixer/.
Input and Output
This plug-in is format agnostic and can accept any input format. It operates only on the metadata. The vvas_xmetaaffixer plug-in supports the GstInferenceMeta data structure. For details about this structure, refer to the VVAS Inference Metadata section.
Control Parameters and Plug-in Properties
Property Name |
Type |
Range |
Default |
Description |
|---|---|---|---|---|
sync |
Boolean |
True/False |
True |
This property is to enable the synchronization between master and slave pads buffers. If sync=true is set, then the metadata is scaled and attached to buffers on slave pads that have matching PTS or PTS falls within frame duration of the buffer on the master sink pad. If sync=false is set on the element, then the metadata is scaled and attached to all the buffers on the slave pads. If this option is used, there is possibility that the metadata is not suitable for the frames/buffers that are not corresponding to the frames/buffers on the master pad. |
timeout |
Int64 |
-1 to 9223372036854 |
2000 |
Timeout in milliseconds. The plug-in will wait for a “timeout” duration for a buffer on other pads before pushing the buffer on the output pad. This is to avoid a hang in case the buffers are arriving at different frame rates and the slave pad buffer is waiting for another buffer at the master pad (which might not arrive as there is no more buffers available). |
Signal Name |
Description |
callback |
|---|---|---|
pad-added |
This signal will be emitted when a new pad is added. |
void user_function (GstElement* object, GstPad* arg0, gpointer user_data); |
pad-removed |
This signal will be emitted when a new pad is removed. |
void user_function (GstElement* object, GstPad* arg0, gpointer user_data); |
Pad Naming Syntax
The pad naming syntax is listed, and the following image shows the syntax:
MetaAffixer master input pad should be named sink_master.
MetaAffixer master output pad should be named src_master.
MetaAffixer slave input pad should be named sink_slave_0, sink_slave_1.
MetaAffixer slave output pad should be named src_slave_0, src_slave_1, src_slave_2.
Example Pipelines
The following pipeline demonstrates the use of the vvas_xmetaaffixer plug-in, where in, it is taking input on the master sink pad which has the inference metadata result for the resnet model (classification). On the slave sink pad, it is taking the 720p scaled version of the input image. Output on the master source pad will have no change in the metadata information. For output on the slave source pad, vvas_xmetaaffixer uses the master pad’s classification inference result and adds it as meta data
Note
The JSONs provided below are only samples. Ensure
model-pathis set to point to your available model before running.
gst-launch-1.0 filesrc location=<INPUT>.nv12 \
! rawvideoparse width=<INPUT_WIDTH> height=<INPUT_HEIGHT> format=nv12 ! queue ! tee name=t \
! vvas_xinfer config-file=/etc/vvas/configs/infer/resnet50_onnxrt.json name=infer1 ! queue \
! ma.sink_master vvas_xmetaaffixer name=ma ma.src_master \
! queue ! vvas_xmetaconvert config-location=/etc/vvas/configs/metaconvert/metaconvert_config.json ! vvas_xoverlay \
! filesink location=output_master.nv12 t. \
! vvas_xabrscaler xclbin-location=/run/media/mmcblk0p1/x_plus_ml.xclbin \
! "video/x-raw, width=1280, height=720, format=NV12" \
! queue max-size-time=0 max-size-bytes=0 \
! ma.sink_slave_0 ma.src_slave_0 \
! queue min-threshold-buffers=4 ! vvas_xmetaconvert config-location=/etc/vvas/configs/metaconvert/metaconvert_config.json ! vvas_xoverlay ! filesink location=output_slave.nv12 -v
Note
When master and slave branches are split from a tee, size the slave-branch
queue so it does not back-pressure the tee and starve the master
(inference) branch. For raw/uncompressed video, set max-size-bytes=0 on the
slave-branch queue (as shown above); otherwise a single large buffer can
exceed the default byte limit and stall the branch, leaving some output frames
without metadata until the timeout elapses.