Through this sample code, you can learn in Python:
This sample shows how to get the stream data (or so called image data) for further processing from element.
In get-stream-data.py, you can find the method, chainfunc, where the main stream data is processed.
First, pad_and_buffer_to_numpy is the function called in chainfunc everytime when image buffer is used for next processing. Second, do the processing you want. In this sample, we simply assume the processing is just put text overlay on the image. Replace this text overlay by the whole process you are going to do here.
Important note: OpenCV putText directly change the image data on referenced address. If you are using other method that store result in another address, do not forget to replace the original stream data by the processed result. More information can reference to Python video filter example.
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-stream-data.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_stream_data
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 you can run the pipeline command for testing:
$ gst-launch-1.0 videotestsrc pattern=18 ! video/x-raw, width=320, height=240 ! videoconvert ! get_stream_data ! videoconvert ! ximagesink
Use videotestsrc to simulate the image stream provider and set its psttern as moving ball. Then adjusting the image size to 640x480. And you will see the processed stream displayed:
