pgie file config
Code executed:
4.2
#Import necessary libraries
import sys
import gi
gi.require_version(‘Gst’, ‘1.0’)
from gi.repository import GObject, Gst, GLib
from common.bus_call import bus_call
import pyds
Set up logging configuration
import logging
logging.basicConfig(level=logging.DEBUG) # Set desired logging level
def run(input_file_path):
global inference_output
inference_output=[]
Gst.init(None)
# Create element that will form a pipeline
print("Creating Pipeline")
logging.info("Starting pipeline")
pipeline=Gst.Pipeline()
source=Gst.ElementFactory.make("filesrc", "file-source")
source.set_property('location', input_file_path)
# data/assessment_stream.mp4
h264parser=Gst.ElementFactory.make("h264parse", "h264-parser")
decoder=Gst.ElementFactory.make("nvv4l2decoder", "nvv4l2-decoder")
streammux=Gst.ElementFactory.make("nvstreammux", "Stream-muxer")
streammux.set_property('width', 1280)
streammux.set_property('height', 720)
streammux.set_property('batch-size', 1)
pgie=Gst.ElementFactory.make("nvinfer", "primary-inference")
if not pgie:
sys.stderr.write(" Unable to create pgie \n")
# Construct the absolute path dynamically
base_path = '/dli/task/' # Base directory containing the config file
config_file_name = 'spec_files/pgie_config_dashcamnet.txt' # Config file name and path relative to the base directory
absolute_path = os.path.join(base_path, config_file_name)
# Set the absolute path for the config file
pgie.set_property('config-file-path', absolute_path)
# pgie.set_property('config-file-path', os.environ['SPEC_FILE'])
nvvidconv1=Gst.ElementFactory.make("nvvideoconvert", "convertor")
nvosd=Gst.ElementFactory.make("nvdsosd", "onscreendisplay")
nvvidconv2=Gst.ElementFactory.make("nvvideoconvert", "convertor2")
capsfilter=Gst.ElementFactory.make("capsfilter", "capsfilter")
caps=Gst.Caps.from_string("video/x-raw, format=I420")
capsfilter.set_property("caps", caps)
encoder=Gst.ElementFactory.make("avenc_mpeg4", "encoder")
encoder.set_property("bitrate", 2000000)
sink=Gst.ElementFactory.make("filesink", 'filesink')
# "filesink" "nveglglessink"
sink.set_property('location', 'output.mpeg4')
sink.set_property("sync", 1)
# Add the elements to the pipeline
print("Adding elements to Pipeline")
pipeline.add(source)
pipeline.add(h264parser)
pipeline.add(decoder)
pipeline.add(streammux)
pipeline.add(pgie)
pipeline.add(nvvidconv1)
pipeline.add(nvosd)
pipeline.add(nvvidconv2)
pipeline.add(capsfilter)
pipeline.add(encoder)
pipeline.add(sink)
# Link the elements together
print("Linking elements in the Pipeline")
source.link(h264parser)
h264parser.link(decoder)
decoder.get_static_pad('src').link(streammux.get_request_pad("sink_0"))
streammux.link(pgie)
pgie.link(nvvidconv1)
nvvidconv1.link(nvosd)
nvosd.link(nvvidconv2)
nvvidconv2.link(capsfilter)
capsfilter.link(encoder)
encoder.link(sink)
# Attach probe to OSD sink pad
osdsinkpad=nvosd.get_static_pad("sink")
osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, osd_sink_pad_buffer_probe, 0)
# Create an event loop and feed gstreamer bus mesages to it
loop=GLib.MainLoop()
bus=pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", bus_call, loop)
# Start play back and listen to events
print("Starting pipeline")
try:
logging.info("Starting pipeline")
pipeline.set_state(Gst.State.PLAYING)
logging.debug("Pipeline state set to PLAYING")
loop = GLib.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", bus_call, loop)
logging.debug("Starting loop.run()")
loop.run()
logging.debug("loop.run() finished")
except Exception as e:
logging.error(f"Exception occurred: {e}")
pass
logging.info("Pipeline stopping...")
pipeline.set_state(Gst.State.NULL)
logging.info("Pipeline stopped")
return inference_output
if name == “main”:
logging.info(“Starting script execution”)
run(‘path_to_your_input_file’) # Provide your input file path here
logging.info(“Script execution finished”)
Error code received:
INFO:root:Starting script execution INFO:root:Starting pipeline INFO:root:Starting pipeline DEBUG:root:Pipeline state set to PLAYING DEBUG:root:Starting loop.run() ERROR:root:Error: gst-library-error-quark: Configuration file parsing failed (5): gstnvinfer.cpp(794): gst_nvinfer_start (): /GstPipeline:pipeline3/GstNvInfer:primary-inference: Config file path: /dli/task/spec_files/pgie_config_dashcamnet.txt ERROR:root:Error: gst-library-error-quark: Configuration file parsing failed (5): gstnvinfer.cpp(794): gst_nvinfer_start (): /GstPipeline:pipeline3/GstNvInfer:primary-inference: Config file path: /dli/task/spec_files/pgie_config_dashcamnet.txt DEBUG:root:loop.run() finished INFO:root:Pipeline stopping… INFO:root:Pipeline stopped INFO:root:Script execution finished
Creating Pipeline Adding elements to Pipeline Linking elements in the Pipeline Starting pipeline

