Python APIs for writing UDF for gst-udf-loader¶
Initialization
class Udf: """Example UDF """ def __init__(self): """Constructor """ # Add the initialization code in this method.
Process Actual Data
The API used to process the actual frame is as follows:
process(self, frame, metadata): # Process the frame in this method # metadata can be used to return inference result
Argument:
frame: Image frame in numpy’s ndarray format
metadata: An empty dictionary. Inference results can be inserted in this data structure.
Return value:
This function returns three values.
1st Value : Represents if the frame Need to be dropped or Not. It is boolean in nature. In case of failure user can return True in this positional return value.
2nd Value : It represents the actual modified frame if at all it has been modified. Hence the type is numpy’s ndarray. If the frame is not modified user can return a None in this place.
3rd Value : Metadata is returned in this place. Hence the type is dict. In general user can return the passed argument as part of this function.
For reference, you can find example UDFs code in links.
Dummy UDF(
[WORK_DIR]/IEdgeInsights/EdgeVideoAnalyticsMicroservice/eva_udfs/dummy.py
)