Video Optical Flow using Nvidia Deepstream 4.0

Optical flow or optic flow is the pattern of apparent motion of objects, surfaces, and edges in a visual scene caused by the relative motion between an observer and a scene.

Nvidia Deepstream 4.0 framework comes has native support for optical flow video calculation with two ready to use gstreamer plugins : Nvof and Nvofvisual.. The first one generates the motion vectors and the second one visualizes the motion vectors data using a predefined color wheel matrix.

To download and install Nvidia Deepstream 4.0 follow guidelines from :

My workstation is based on Unbuntu 18.04 with Nvidia Geforce RTX 2080 nvidia dirvers 418.87 cuda 10.1

Follow Nvidia deepstream 4.0 installation guides to install required packages as Gstreamer 1.14.1 and TensorRT 5.1.

For Deepstream 4.0 installation package suggest using deb intallation which take care to install Deepstream 4.0 library and gstreamer plugins in correct paths.

Once you have installed correctly Nvidia deepstream 4.0 and all required packages it’s easy to test optical flow Nvidia deepstream plugin on your video source just running the following gstreamer pipeline :

gst-launch-1.0 filesrc location=<path to your source video file> ! qtdemux ! h264parse ! nvv4l2decoder ! m.sink_0 nvstreammux name=m batch-size=1 width=<video source width> height=<video source height> ! nvof preset-level=2 ! tee name=t ! queue ! nvofvisual ! nvmultistreamtiler width=<Optical flow output window width> height=<Optical flow output window height> ! nveglglessink t. ! queue ! nvmultistreamtiler width=<source video output window width> height=<source video output window height> ! nvvideoconvert ! nveglglessink

That’s my test on Nvida video sample enjoy :

You may also like