Convert to grayscale through deepstream app

AGX Xavier
DeepStream 6.1

Hi,
Since yesterday i’m trying to modify this code :https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/tree/master/apps/deepstream-test1-usbcam
which convert from NV12 to RGBA to make the video stream grayscale. The probleme is i cannot find an understandable Gstream/Deepstream Python documentation.

So i would like to know how to convert from NV12 to Gray, and then convert it to rgba so it’s gray but in the rgba format so it can be used by nvosd.

In a classical Gstreamer pipeline i supposed i would have to add something like

video/x-raw,format=GRAY8 ! videoconvert

and the convert it again to rgba.

Thanks !

You can refer the source code, use the capstilert to set the color format.
Like:

 caps_vidconvsrc = Gst.ElementFactory.make("capsfilter", "nvmm_caps")
 caps_v4l2src.set_property('caps', Gst.Caps.from_string("format=GRAY8"))

Thanks for you replied, i tried your solution, it doesn’t show any error and it process correctly but image is still colored.

Could you attach your pipeline graph by refering to the link below?
https://forums.developer.nvidia.com/t/deepstream-sdk-faq/80236/10

Here it is :
pipeline.dot (9.2 KB)

You need add the capsfilter to videoconvert. You can create a new capsfilter and set the format. Then you link it after the videoconvert plugin.

I created a caps filter with Gray8 format :

caps_gray = Gst.ElementFactory.make("capsfilter", "gray_caps")
    if not caps_gray:
        sys.stderr.write(" Unable to create v4l2src capsfilter \n")
caps_gray.set_property('caps', Gst.Caps.from_string("format=GRAY8"))

i added it to the pipeline and linked it like that :

vidconvsrc.link(caps_gray)
caps_gray.link(nvvidconvsrc)

Program is working but still no gray filter, here is the pipeline.dot file
pipeline.dot (10.0 KB)

There is no update from you for a period, assuming this is not an issue anymore.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

You should add the caps after the nvvideoconvert. I have tried the cli:

gst-launch-1.0 -e filesrc location=/opt/nvidia/deepstream/deepstream/samples/streams/sam
ple_720p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! queue2 ! nvvideoconvert ! 'video/x-raw(memory:NVMM),format=GRAY8' ! nvvideoconvert ! 'video/x-raw(memory:NVMM),format=NV12' ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=out.mp4

It works well. So you can use nvvideconvert to change the format.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.