Through this sample code, you can learn:
This sample shows how to retrieve the adlink metadata inside the element. The target created pipeline command is:
$ gst-launch-1.0 videotestsrc ! video/x-raw, format=BGR, width=320, height=240, framerate=30/1 ! admetadebuger type=1 id=187 class=boy prob=0.876 x1=0.1 y1=0.2 x2=0.3 y2=0.4 ! get_object_detection ! fakesink
This command is used to simulate inferenced object detection result by admetadebuger and the element(this sample code), get_object_detection, retrieve the object detection data from admetadata and then print out in terminal.
This sample shows how to retrieve the adlink metadata inside the element. First, import the gst_admeta:
import gst_admeta as admeta
Second, in the method, chainfunc, of this sample has an extra code block which is going to get the object detection metadata:
# This function will get classification result from admetadata
boxes = admeta.get_detection_box(buff,0)
# Iteratively retrieve the content of object detected
with boxes as det_box :
if det_box is not None :
for box in det_box:
print('Detection result: prob={:.3f}, coordinate=({:.2f},{:.2f}) to ({:.2f},{:.2f})), Index = {}, Label = {}'.format(box.prob,box.x1,box.y1,box.x2, box.y2, box.obj_id, box.obj_label.decode("utf-8").strip()))
else:
print("None")
The metadata structure could be find in Edge Vision Analytics SDK Programming Guide : How to Use ADLINK Metadata in Chapter 5. Or can be found in the files:
Based on the structure, AdBatch can get the frame in vector and the inference data are stored in each frame based on the inference type: classification, detection, segmentation or openpose. Here, the sample use object detecion to illustrate get the metadata and print out obj_id, obj_label, prob and the box coordination to the terminal or cmd.
Same with the last process with video-filter.py, required to install into the EVA package. Install process please refer to vido filter in Python.
After installing the Python plugin get-object-detection.py file to the plugin folder, here used EVA_ROOT to preset the installed path of EVASDK, run the GStreamer tool to inspect it to see the metadata and the object information.
$ gst-inspect-1.0 get_object_detection
and you will see all of the information listed:
Factory Details:
Rank none (0)
Long-name Video Filter
Klass GstElement
Description Python based GStreamer videofilter example
Author Dr. Paul Lin <paul.lin@adlinktech.com>
Plugin Details:
Name python
Description loader for plugins written in python
Filename /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstpython.so
Version 1.14.5
License LGPL
Source module gst-python
Binary package GStreamer Python
Origin URL http://gstreamer.freedesktop.org
// more information omitted
Then run the pipeline command for testing:
$ gst-launch-1.0 videotestsrc ! video/x-raw, format=BGR, width=320, height=240, framerate=30/1 ! admetadebuger type=1 id=187 class=boy prob=0.876 x1=0.1 y1=0.2 x2=0.3 y2=0.4 ! get_object_detection ! fakesink
and you will see the message shows the inference result frame by frame in the terminal or cmd as bellow:
Detection result: prob=0.876, coordinate=(0.10,0.20) to (0.30,0.40)), Index = 187, Label = boy