Please provide complete information as applicable to your setup.
• Hardware Platform: NVIDIA L40 GPU
• DeepStream 7.0
• NVIDIA GPU Driver Version 535.183.06
Hi, my team are trying to expand on the NvOSD overlay in the Python DeepStream API, such as rendering icons and more complicated shapes in the form of a UI directly within the deepstream pipeline, but we’re struggling to get anything to display beyond the basic bounding box and text parameters of the NvOSD. This is heavily based on the DeepStream Python Apps examples.
When creating a custom probe on an overlay element, and trying to modify the NvBufSurface
via pyds.get_nvds_buf_surface
, if the NvBufSurface
is modified in any way then the program cleanly crashes. This happens whether using opencv to draw a line on the image, or even just raw numpy to, for example make half of the image red (as an example):
def tiler_sink_pad_buffer_probe(pad, info, u_data):
gst_buffer = info.get_buffer()
if not gst_buffer:
print("Unable to get GstBuffer ")
return
batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
l_frame = batch_meta.frame_meta_list
while l_frame is not None:
try:
frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
except StopIteration:
break
l_obj = frame_meta.obj_meta_list
while l_obj is not None:
try:
obj_meta = pyds.NvDsObjectMeta.cast(l_obj.data)
except StopIteration:
break
n_frame = pyds.get_nvds_buf_surface(
hash(gst_buffer), frame_meta.batch_id
)
height, width, channels = n_frame.shape
# Set the first half of the image to red
n_frame[:, : width // 2, 0] = 255 # Set the red channel to 255
n_frame[:, : width // 2, 1] = 0 # Set the green channel to 0
n_frame[:, : width // 2, 2] = 0 # Set the blue channel to 0
n_frame[:, : width // 2, 3] = 128 # Set the alpha channel to 128
Which is connected with the following links in the pipeline:
streammux.link(pgie)
pgie.link(tracker)
tracker.link(analytics)
analytics.link(demux)
demux.link(nvvidconv)
nvvidconv.link(filter1)
filter1.link(tiler)
tiler.link(nvvidconv1)
nvvidconv1.link(nvosd)
nvosd.link(tee)
tiler_sink_pad = tiler.get_static_pad("sink")
tiler_sink_pad.add_probe(
Gst.PadProbeType.BUFFER, tiler_sink_pad_buffer_probe, 0
)
How do we modify the buffer surface to draw our own custom bounding boxes with icons and custom shapes onto the frames of the video stream? If I remove the code where I modify the pixels of n_frame
, then the video displays as expected with the default OSD, but if I add it then I get a black screen and the program halts. The same result occurs if I use anything else to modify n_frame
in any manner.
I know that I can use a probe to modify the NvOSD element’s display meta, but I need a solution to modify the frame pixel data in a more custom/direct manner to allow for adding icons and more complicated shapes (like rounded squares or triangles).
Any advice on how to fix the above code, or even an alternate approach with a similar result would be greatly appreciated.