NVIDIA VPI GStreamer Plug-in - Examples - Convolution

From RidgeRun Developer Wiki


Previous: Examples/Videoscale Index Next: Examples/Separable Convolution






Introduction to Convolution

The vpiconvolution element applies the Convolution algorithm from the NVIDIA VPI library to a video stream. In order to use this algorithm, you must provide the kernel matrix to be applied.

Element properties

  • backend

Backend to use to execute VPI algorithms. Available options:

cpu: CPU backend
cuda: CUDA backend
pva: PVA backend (Xavier only)
vic: VIC backend

Flags: readable, writable
Default: "cuda"

  • kernel

Convolution kernel to be applied with a minimum size of 1x1 and maximum size 11x11. Usage example:

<<1.0, 0.0, -1.0>, <0.0, 0.0, 0.0>, <-1.0, 0.0, 1.0>>

Type: GstValueArray of GValues of type GstValueArray
Flags: readable, writable
Default: <<1>>

  • boundary

How pixel values outside of the image domain should be treated. Available options:

zero: All pixels outside the image are considered 0.
clamp: Border pixels are repeated indefinitely.

Flags: readable, writable
Default: "zero"

NVIDIA VPI GStreamer Plug-in Example Pipeline for Convolution

The following example pipe will help you apply convolution to the input video stream from your camera. You may modify the properties values according to the information above.

For a convolution given by an edge detection kernel of size 3x3, and a boundary condition of zero you may use:

gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! 'video/x-raw,format=GRAY8' ! vpiupload ! vpiconvolution kernel="<<1.0, 0.0, -1.0>, <0.0, 0.0, 0.0>, <-1.0, 0.0, 1.0>>" ! vpidownload ! nvvidconv ! 'video/x-raw(memory:NVMM),format=I420' ! nvoverlaysink

Another example pipeline for a video test source could be the following:

gst-launch-1.0 videotestsrc pattern=spokes ! 'video/x-raw,format=GRAY8' ! vpiupload ! vpiconvolution kernel="<<1.0, 0.0, -1.0>, <0.0, 0.0, 0.0>, <-1.0, 0.0, 1.0>>" ! vpidownload ! nvvidconv ! "video/x-raw(memory:NVMM),format=I420" ! nvoverlaysink

Alternative display pipeline.

gst-launch-1.0 videotestsrc pattern=spokes ! 'video/x-raw,format=GRAY8' ! vpiupload ! vpiconvolution kernel="<<1.0, 0.0, -1.0>, <0.0, 0.0, 0.0>, <-1.0, 0.0, 1.0>>" ! vpidownload ! nvvidconv ! "video/x-raw(memory:NVMM),format=I420" ! nvvidconv ! autovideosink


Previous: Examples/Videoscale Index Next: Examples/Separable Convolution