Source code for payload

import numpy as np 
import cv2
from python_plugin_template import AggregatorTemplate
from python_plugin_template import SimaaiPythonBuffer, MetaStruct
import gi
from typing import List, Tuple
gi.require_version('Gst', '1.0')
gi.require_version('GstBase', '1.0')
gi.require_version('GObject', '2.0')
from gi.repository import Gst, GObject, GstBase

"""
To use Metadata fieds from the input buffers:  
Parse the MetaStruct object. It has the following 4 fields:  
class MetaStruct:
    def __init__(self, buffer_name, stream_id, timestamp, frame_id):
        self.buffer_name = buffer_name
        self.stream_id = stream_id
        self.timestamp = timestamp
        self.frame_id = frame_id

"""

[docs] plugin_name = "python_plugin" #define PLUGIN_NAME HERE
[docs] out_size = int(1280 * 720 * 1.5) # outsize of plugin in bytes
[docs] class MyPlugin(AggregatorTemplate): def __init__(self): super(MyPlugin, self).__init__(plugin_name=plugin_name, out_size=out_size)
[docs] def run(self, input_buffers: List[SimaaiPythonBuffer], output_buffer: bytes) -> None: """ Define your plugin logic HERE Inputs: input_buffers List[SimaaiPythonBuffer]: List of input buffers Object of class SimaaiPythonBuffer has three fields: 1. metadata MetaStruct Refer to the structure above 2. data bytes - raw bytes of the incoming buffer 3. size int - size of incoming buffer in bytes """ pass
GObject.type_register(MyPlugin) __gstelementfactory__ = (plugin_name, Gst.Rank.NONE, MyPlugin)