The vvas_xmetaconvert plug-in is used to convert VVAS ML inference metadata, which is attached to an input buffer, into the overlay metadata, GstVvasOverlayMeta, that is needed by the vvas_xoverlay plug-in.
The vvas_xmetaconvert plug-in requires some static configuration parameters, such as font type and size, which are provided in the configuration file in JSON format. The config-location property allows you to specify the location of the configuration file that contains the necessary parameters.
By using these two plug-ins together, you can create an overlay, like bounding box, text, and so on, on a video frame/image that displays the ML inference results in real time.
For insight into the implementation details, refer to the vvas_xmetaconvert source code located at <vvas>/vvas-gst-plugins/gst/metaconvert/.
Input and Output
This plug-in is format agnostic and can accept any input format as it operates only on the metadata attached to the input buffer and the same will be pushed out of the source pad after attaching the overlay metadata.
Control Parameters and Plug-in Properties
The following table lists the GStreamer plug-in properties supported by the vvas_xmetaconvert plug-in.
Property Name |
Type |
Range |
Default |
Description |
|---|---|---|---|---|
config-location |
String |
NA |
NULL |
Location of the metaconvert configuration in a JSON format which will be used to convert inference metadata to overlay metadata. |
JSON File Format to Be Provided as Input to the config-location Property
This section describes the JSON file format and configuration parameters for the vvas_xmetaconvert plug-in.
The following example is of a JSON file to pass to vvas_xmetaconvert using the config-location property.
{
"config": {
"display-level": -1,
"font-size" : 0.5,
"font" : 3,
"thickness" : 2,
"radius": 5,
"mask-level" : 0,
"y-offset" : 0,
"label-color" : [
{"level": 1, "blue" : 255, "green" : 0, "red" : 0 },
{"level": 2, "blue" : 0, "green" : 255, "red" : 0 },
{"level": 3, "blue" : 0, "green" : 0, "red" : 255 }
],
"label-filter" : [ "class", "probability" ],
"classes" : [
{
"name" : "car",
"blue" : 255,
"green" : 0,
"red" : 0,
"masking" : 0
},
{
"name" : "person",
"blue" : 0,
"green" : 255,
"red" : 0,
"masking" : 0
},
{
"name" : "bus",
"blue" : 0,
"green" : 0,
"red" : 255,
"masking" : 0
},
{
"name" : "bicycle",
"blue" : 0,
"green" : 0,
"red" : 255,
"masking" : 0
}
]
}
}
Various configuration parameters passed to vvas_xmetaconvert via a JSON file are described in the following table.
Parameter |
Expected Values |
Description |
|---|---|---|
font |
0 to 7 |
The following is the list of text font values and descriptions.
|
font-size |
0.5 to 1 |
Font fraction scale factor that is multiplied by the font-specific base size. The default value is 0.5. |
thickness |
Integer 1 to 3 |
The thickness of the line that makes up the rectangle. Negative values like -1 signify that the function draws a filled rectangle. The recommended value is between 1 and 3. The default line thickness value is 1. |
mask-level |
Integer (0 or 1) |
For a cascaded ML pipeline, you can use this field to mask out the results of a particular level in the inference results tree. All bounding boxes in that level will be masked with a black color. When set to 0 (default), none of the levels are masked. The value should be 0 or 1. |
label-color |
{“level”:1,
“blue”:255,
“green”:0,
“red”:0}
Level 0 to N
0 => all levels
N => specific level
blue => 0 to 255
green => 0 to 255
red => 0 to 255
|
Using this field, you can assign the bounding box and label color to a particular level in the inference results tree. You need to pass it as an array with the level, blue, green, and red parameters. All parameters of the array are mandatory to parse. For instance, if you want to change the color for level 2, then it will be {“level”: 2, “blue”: 0, “green”: 255, “red”: 0}. If label-color is not parsed, then it will take the default colors. The default color scheme will be as follows:
Label and bounding box color will affect with the following precedence order:
|
label-filter |
Array [“class”, “probability”] |
This field controls what should be displayed in the label string. The addition of “class” in the array adds the ML classification name (for example, car, person, and so on). The addition of “probability” in the array adds the probability of a positive object identification. |
y-offset |
Integer 0 to height |
‘y’ offset to be added along the height for the label in case of the classification model. |
classes |
{“name”:”car”,
“blue”:255,
“green”:0,
“red”:0,
“masking”:0}
|
This is a filtering option when using the vvas_xoverlay. The bounding box is only drawn for the classes that are listed in this configuration, and other classes are ignored. For instance, if “car”, “person”, “bicycle” are entered under “classes”, then the bounding box is only drawn for these three classes, and other classes like horse or motorbike are ignored. The expected value column shows an example of how each class should be described. All objects in this example, by class, are using the color combination listed. The class names in this list must match the class names assigned by vvas_xdpuinfer. Otherwise, the bounding box is not drawn. The “masking” flag can be used to mask all objects of a class. Set it to 1 for enabling masking. This flag will override the “mask_level” field. For instance, if “mask_level” is set to 1 and “masking” for “car” is set to 1, and if level 1 has cars and buses, then only cars are masked, not the entire level. For face detection, keep the “classes” array empty. |
display-level |
Integer 0 to N
-1 => Display information at all the levels
0 => Do not display anything
N => Specific level
|
Display the bounding box of one particular level or all levels. The default is set to -1. |
draw_above_bbox
_flag
|
True/False |
A label will be displayed on the top of the bounding box if set to True. The default value is True. |
radius |
Integer |
Represents the radius of the circle, also used for a point. The default value is 3. |
Example Pipelines
The following example demonstrates the use of vvas_xmetaconvert with the vvas_xoverlay plug-in for drawing bounding boxes.
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>.bgr \
! rawvideoparse format=bgr width=<INPUT_WIDTH> height=<INPUT_HEIGHT> \
! vvas_xinfer config-file=/etc/vvas/configs/infer/resnet50_onnxrt.json \
! vvas_xmetaconvert config-location=/etc/vvas/configs/metaconvert/metaconvert_config.json \
! vvas_xoverlay ! filesink location=output.bgr