Skip to content

Not able to integrate kwarg into gvapython callback #462

@paakhim10

Description

@paakhim10

Hi!
I am building this pipeline:
gst-launch-1.0 \ rtspsrc location="$INPUT_PATH" protocols=tcp ! \ rtph264depay ! h264parse ! avdec_h264 ! \ videoconvert ! capsfilter caps="video/x-raw,format=BGRx" ! \ gvadetect model=${MODEL} model_proc=${MODEL_PROC} device=CPU ! \ gvafpscounter interval=1 ! \ gvapython module=/home/dlstreamer/config/scripts/zone_detection.py class=FrameProcessor kwarg="{\"zone_config\":\"$ZONE_JSON\"}" ! \ gvametaconvert ! \ gvametapublish file-format=json-lines file-path=$METADATA_FILE ! \ videoconvert ! x264enc tune=zerolatency ! \ rtspclientsink location=$OUTPUT_PATH

Here, I need to access $ZONE_JSON, which is processed as follows in the backend:
'ZONE_JSON': json.dumps(zone_json)

In my gvapython function:

class FrameProcessor:
    def __init__(self, **kwargs):
        self.zone_config = kwargs.get("zone_config", "{}")
        if isinstance(self.zone_config, str):
            self.zone_config = json.loads(self.zone_config)

    def process_frame(self, frame: VideoFrame):
        """Main function to process and visualize each frame."""
        try:
            zone_json = self.zone_config
and further processing ...

I have been trying to troubleshoot it, coming up with various errors, but the current one is this:

Image

The elements inside this (attributes, occluded, false) are actually keys in the zone_json file. Can you help me troubleshoot this? I can't find the necessary documentation to pass a json string into the pipeline usinggvapython's kwarg, so I haven't been able to resolve it.

Thank you so much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions