GstCUDA - Example 1: cudafilter

From RidgeRun Developer Wiki


Previous: Examples Index Next: Example - cudafilter: NVMM direct mapping





This page gives an usage example of the cudafilter element.

Introduction

GstCUDA offers two basic CUDA algorithm library examples. They are designed for the cudafilter element and works just out of the box, so they are perfect for training and giving the first steps on GstCUDA. The idea is to give detailed examples on how to use the cudafilter element, and also to give some examples of written code of a functional (out of the box) CUDA algorithm library for the cudafilter element. The CUDA algorithm library examples are built automatically, and you can find them under the following paths:

  • $GstCUDA_DIR/tests/examples/cudafilter_algorithms/memcpy/memcpy.so
  • $GstCUDA_DIR/tests/examples/cudafilter_algorithms/gray-scale-filter/gray-scale-filter.so
  • $GstCUDA_DIR/tests/examples/cudafilter_algorithms/median-filter/median-filter.so

The memcpy.so CUDA algorithm library consists of a very basic algorithm that receives a full-color YUV I420 image and generates an exact copy of the incoming image. It is a basic image filter that copies the luminance and chrominance components of the incoming image. The image copy is executed on the GPU, so it is hardware accelerated, that assures optimal performance. This basic algorithm is just for example and demonstration purposes because it shows the capability of GstCUDA to execute an algorithm on the GPU that goes through each pixel in the incoming image and copies it to the output image. This can be a high load task if we consider a 4K@60fps video stream, due to the high data transaction rate, but GstCUDA could handle it with no problem.

The gray-scale-filter.so CUDA algorithm library consists of a very basic algorithm that receives a full-color YUV I420 image and converts it to a gray-scale YUV I420 image. It is a basic image filter that modifies the chrominance components of the image by assigning a fixed value that makes the image look in a gray-scale. All the processing of the image is done in the GPU.

The median-filter.so CUDA algorithm is a basic implementation of a median filter that takes a full-color YUV I420 image and applies a median filter to the image. This allows removing basic salt-and-pepper noise in an image. The filter process is done in the GPU.

GstCUDA supports two modes of memory handling. NVMM direct mapping mode uses the CUDA mapper and the element receives NVMM memory type buffers as input. Unified memory allocator mode avoids the use of NVMM memory buffers by providing a memory allocator that directly passes the buffer to the GPU. Both modes are supported for Jetpack 3.0, however, NVMM direct mapping mode is not supported for Jetpack 3.1.

Below you will find a set of test pipelines for both modes, with their respective performance stats for each CUDA algorithm library.

Note: To get the best performance on the Tegra platform, you must execute the jetson_clocks.sh script. This script tune-up the Tegra to high-performance mode. All the reported performance stats came from tests done after ran the jetson_clocks.sh script. Execute command: sudo ~/jetson_clocks.sh

Examples Index


Previous: Examples Index Next: Example - cudafilter: NVMM direct mapping