GstCUDA - Example: cudafilter

From RidgeRun Developer Connection
Jump to: navigation, search
Nvidia-preferred-partner-badge-rgb-for-screen.png

RR Contact Us.png

Error something wrong.jpg Problems running the pipelines shown on this page?
Please see our GStreamer Debugging guide for help.


Example 1: cudafilter


Home

Example 3: cudadebayer



This page gives an usage example of the cudamux 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

The memcpy.so CUDA algorithm library consists in a very basic algorithm that receives a full-color YUV I420 image and generate and 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 an 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 go 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 in a very basic algorithm that receives a full-color YUV I420 image and convert 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 to look in gray-scale. All the processing of the image is done in the GPU.

Below you will find a set of test pipelines 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


Gray-scale filter CUDA library algorithm

1080p 60fps capture to display (in-place=true)

Example pipeline

gst-launch-1.0 nvcamerasrc queue-size=10 sensor-id=0 fpsRange='60 60' ! "video/x-raw(memory:NVMM),width=1920,height=1080,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=1920,height=1080,format=I420,framerate=60/1" ! cudafilter in-place=true location=./gray-scale-filter.so ! perf print-arm-load=true ! nvoverlaysink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:02:13.615967657; Bps: 776; fps: 60.0; CPU: 8;  
GST-PERF INFO -->  Timestamp: 0:02:14.632537582; Bps: 763; fps: 60.3; CPU: 8;  
GST-PERF INFO -->  Timestamp: 0:02:15.632844549; Bps: 776; fps: 60.0; CPU: 8;  
GST-PERF INFO -->  Timestamp: 0:02:16.649615644; Bps: 763; fps: 60.3; CPU: 9;  
GST-PERF INFO -->  Timestamp: 0:02:17.666065311; Bps: 763; fps: 60.3; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:02:18.682560220; Bps: 763; fps: 60.3; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:02:19.699122957; Bps: 763; fps: 60.3; CPU: 11;  
GST-PERF INFO -->  Timestamp: 0:02:20.699298792; Bps: 776; fps: 60.0; CPU: 11;  
GST-PERF INFO -->  Timestamp: 0:02:21.715510459; Bps: 763; fps: 60.3; CPU: 11;  
GST-PERF INFO -->  Timestamp: 0:02:22.715910009; Bps: 776; fps: 60.0; CPU: 11;


4K 60fps capture to display (in-place=true)

Example pipeline

gst-launch-1.0 nvcamerasrc queue-size=10 sensor-id=0 fpsRange='60 60' ! "video/x-raw(memory:NVMM),width=3840,height=2160,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=3840,height=2160,format=I420,framerate=60/1" ! cudafilter in-place=true location=./gray-scale-filter.so ! perf print-arm-load=true ! nvoverlaysink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:03:56.819087040; Bps: 776; fps: 60.0; CPU: 16;  
GST-PERF INFO -->  Timestamp: 0:03:57.825121037; Bps: 771; fps: 59.64; CPU: 13;  
GST-PERF INFO -->  Timestamp: 0:03:58.837141233; Bps: 766; fps: 59.28; CPU: 14;  
GST-PERF INFO -->  Timestamp: 0:03:59.849401695; Bps: 766; fps: 59.28; CPU: 14;  
GST-PERF INFO -->  Timestamp: 0:04:00.859525079; Bps: 768; fps: 59.40; CPU: 13;  
GST-PERF INFO -->  Timestamp: 0:04:01.871618207; Bps: 766; fps: 59.28; CPU: 15;  
GST-PERF INFO -->  Timestamp: 0:04:02.883459413; Bps: 767; fps: 59.34; CPU: 15;  
GST-PERF INFO -->  Timestamp: 0:04:03.894646509; Bps: 767; fps: 59.34; CPU: 14;  
GST-PERF INFO -->  Timestamp: 0:04:04.906216370; Bps: 767; fps: 59.34; CPU: 14;  
GST-PERF INFO -->  Timestamp: 0:04:05.917121183; Bps: 768; fps: 59.40; CPU: 14;


720p 60fps videotestsrc to display (in-place=true)

Example pipeline

gst-launch-1.0 videotestsrc is-live=true ! "video/x-raw,width=1280,height=720,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=1280,height=720,format=I420,framerate=60/1" ! cudafilter in-place=true location=./gray-scale-filter.so ! perf print-arm-load=true ! nvoverlaysink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:12:29.994184572; Bps: 776; fps: 60.0; CPU: 18;  
GST-PERF INFO -->  Timestamp: 0:12:31.010495933; Bps: 763; fps: 60.3; CPU: 18;  
GST-PERF INFO -->  Timestamp: 0:12:32.010535558; Bps: 776; fps: 60.0; CPU: 18;  
GST-PERF INFO -->  Timestamp: 0:12:33.027377442; Bps: 763; fps: 60.3; CPU: 18;  
GST-PERF INFO -->  Timestamp: 0:12:34.044071960; Bps: 763; fps: 60.3; CPU: 18;  
GST-PERF INFO -->  Timestamp: 0:12:35.044204013; Bps: 776; fps: 60.0; CPU: 19;  
GST-PERF INFO -->  Timestamp: 0:12:36.044224584; Bps: 776; fps: 60.0; CPU: 19;  
GST-PERF INFO -->  Timestamp: 0:12:37.060451742; Bps: 763; fps: 60.3; CPU: 19;  
GST-PERF INFO -->  Timestamp: 0:12:38.060585805; Bps: 776; fps: 60.0; CPU: 19;  
GST-PERF INFO -->  Timestamp: 0:12:39.060628072; Bps: 776; fps: 60.0; CPU: 18;


1080p 60fps capture to display (in-place=false)

Example pipeline

gst-launch-1.0 nvcamerasrc queue-size=10 sensor-id=0 fpsRange='60 60' ! "video/x-raw(memory:NVMM),width=1920,height=1080,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=1920,height=1080,format=I420,framerate=60/1" ! cudafilter in-place=false location=./gray-scale-filter.so ! nvvidconv ! perf print-arm-load=true ! nvoverlaysink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:05:46.167015649; Bps: 776; fps: 60.0; CPU: 20;  
GST-PERF INFO -->  Timestamp: 0:05:47.167023874; Bps: 776; fps: 60.0; CPU: 18;  
GST-PERF INFO -->  Timestamp: 0:05:48.183394748; Bps: 763; fps: 60.3; CPU: 19;  
GST-PERF INFO -->  Timestamp: 0:05:49.183590994; Bps: 776; fps: 60.0; CPU: 23;  
GST-PERF INFO -->  Timestamp: 0:05:50.183618490; Bps: 776; fps: 60.0; CPU: 27;  
GST-PERF INFO -->  Timestamp: 0:05:51.184194423; Bps: 776; fps: 60.0; CPU: 45;  
GST-PERF INFO -->  Timestamp: 0:05:52.200942016; Bps: 763; fps: 60.3; CPU: 46;  
GST-PERF INFO -->  Timestamp: 0:05:53.216856380; Bps: 764; fps: 60.9; CPU: 45;  
GST-PERF INFO -->  Timestamp: 0:05:54.217181741; Bps: 776; fps: 60.0; CPU: 46;  
GST-PERF INFO -->  Timestamp: 0:05:55.217598561; Bps: 776; fps: 60.0; CPU: 46;


4K 60fps capture to fakesink (in-place=false)

Example pipeline

gst-launch-1.0 nvcamerasrc queue-size=10 sensor-id=0 fpsRange='60 60' ! "video/x-raw(memory:NVMM),width=3840,height=2160,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=3840,height=2160,format=I420,framerate=60/1" ! cudafilter in-place=false location=./gray-scale-filter.so ! perf print-arm-load=true ! fakesink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:08:40.062814951; Bps: 12330624; fps: 59.46; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:08:41.074953852; Bps: 12294071; fps: 59.28; CPU: 23;  
GST-PERF INFO -->  Timestamp: 0:08:42.087998326; Bps: 12281934; fps: 59.23; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:08:43.097597957; Bps: 12330624; fps: 59.46; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:08:44.109302715; Bps: 12306231; fps: 59.34; CPU: 25;  
GST-PERF INFO -->  Timestamp: 0:08:45.120250840; Bps: 12318415; fps: 59.40; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:08:46.132807638; Bps: 12294071; fps: 59.28; CPU: 23;  
GST-PERF INFO -->  Timestamp: 0:08:47.144759986; Bps: 12306231; fps: 59.34; CPU: 21;  
GST-PERF INFO -->  Timestamp: 0:08:48.154396985; Bps: 12330624; fps: 59.46; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:08:49.167064442; Bps: 12294071; fps: 59.28; CPU: 23;  
GST-PERF INFO -->  Timestamp: 0:08:50.178082366; Bps: 12306231; fps: 59.34; CPU: 23;


720p 60fps videotestsrc to display (in-place=false)

Example pipeline

gst-launch-1.0 videotestsrc is-live=true ! "video/x-raw,width=1280,height=720,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=1280,height=720,format=I420,framerate=60/1" ! cudafilter in-place=false location=./gray-scale-filter.so ! nvvidconv ! perf print-arm-load=true ! nvoverlaysink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:16:38.724108163; Bps: 763; fps: 60.3; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:16:39.724682234; Bps: 776; fps: 60.0; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:16:40.740983855; Bps: 763; fps: 60.3; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:16:41.740991843; Bps: 776; fps: 60.0; CPU: 11;  
GST-PERF INFO -->  Timestamp: 0:16:42.757944147; Bps: 763; fps: 60.3; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:16:43.758090059; Bps: 776; fps: 60.0; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:16:44.774079094; Bps: 764; fps: 60.9; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:16:45.774631002; Bps: 776; fps: 60.0; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:16:46.774633540; Bps: 776; fps: 60.0; CPU: 13;  
GST-PERF INFO -->  Timestamp: 0:16:47.791021283; Bps: 763; fps: 60.3; CPU: 12;


HW accelerated memcpy CUDA library algorithm

1080p 60fps capture to display (in-place=true)

Example pipeline

gst-launch-1.0 nvcamerasrc queue-size=10 sensor-id=0 fpsRange='60 60' ! "video/x-raw(memory:NVMM),width=1920,height=1080,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=1920,height=1080,format=I420,framerate=60/1" ! cudafilter in-place=true location=./memcpy.so ! perf print-arm-load=true ! nvoverlaysink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:19:39.222044712; Bps: 763; fps: 60.3; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:19:40.222362703; Bps: 776; fps: 60.0; CPU: 11;  
GST-PERF INFO -->  Timestamp: 0:19:41.222364533; Bps: 776; fps: 60.0; CPU: 12;  
GST-PERF INFO -->  Timestamp: 0:19:42.238761022; Bps: 763; fps: 60.3; CPU: 11;  
GST-PERF INFO -->  Timestamp: 0:19:43.255579257; Bps: 763; fps: 60.3; CPU: 10;  
GST-PERF INFO -->  Timestamp: 0:19:44.255680715; Bps: 776; fps: 60.0; CPU: 9;  
GST-PERF INFO -->  Timestamp: 0:19:45.272253134; Bps: 763; fps: 60.3; CPU: 8;  
GST-PERF INFO -->  Timestamp: 0:19:46.288675431; Bps: 763; fps: 60.3; CPU: 8;  
GST-PERF INFO -->  Timestamp: 0:19:47.288955264; Bps: 776; fps: 60.0; CPU: 7;  
GST-PERF INFO -->  Timestamp: 0:19:48.305432418; Bps: 763; fps: 60.3; CPU: 7;


4K 60fps capture to display (in-place=true)

Example pipeline

gst-launch-1.0 nvcamerasrc queue-size=10 sensor-id=0 fpsRange='60 60' ! "video/x-raw(memory:NVMM),width=3840,height=2160,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=3840,height=2160,format=I420,framerate=60/1" ! cudafilter in-place=true location=./memcpy.so ! perf print-arm-load=true ! nvoverlaysink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:21:09.056777389; Bps: 771; fps: 60.63; CPU: 17;  
GST-PERF INFO -->  Timestamp: 0:21:10.057380551; Bps: 776; fps: 60.0; CPU: 13;  
GST-PERF INFO -->  Timestamp: 0:21:11.058196962; Bps: 776; fps: 60.0; CPU: 16;  
GST-PERF INFO -->  Timestamp: 0:21:12.074104172; Bps: 764; fps: 60.9; CPU: 16;  
GST-PERF INFO -->  Timestamp: 0:21:13.074630372; Bps: 776; fps: 60.0; CPU: 15;  
GST-PERF INFO -->  Timestamp: 0:21:14.091400223; Bps: 763; fps: 60.3; CPU: 15;  
GST-PERF INFO -->  Timestamp: 0:21:15.097895519; Bps: 771; fps: 59.64; CPU: 14;  
GST-PERF INFO -->  Timestamp: 0:21:16.110965925; Bps: 766; fps: 59.23; CPU: 14;  
GST-PERF INFO -->  Timestamp: 0:21:17.121792522; Bps: 768; fps: 59.40; CPU: 14;  
GST-PERF INFO -->  Timestamp: 0:21:18.132254616; Bps: 768; fps: 59.40; CPU: 13;


720p 60fps videotestsrc to display (in-place=true)

Example pipeline

gst-launch-1.0 videotestsrc is-live=true ! "video/x-raw,width=1280,height=720,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=1280,height=720,format=I420,framerate=60/1" ! cudafilter in-place=true location=./memcpy.so ! perf print-arm-load=true ! nvoverlaysink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:22:07.386021069; Bps: 764; fps: 64.3; CPU: 20;  
GST-PERF INFO -->  Timestamp: 0:22:08.386441053; Bps: 776; fps: 60.0; CPU: 20;  
GST-PERF INFO -->  Timestamp: 0:22:09.386539808; Bps: 776; fps: 60.0; CPU: 18;  
GST-PERF INFO -->  Timestamp: 0:22:10.403048527; Bps: 763; fps: 60.3; CPU: 20;  
GST-PERF INFO -->  Timestamp: 0:22:11.419435652; Bps: 763; fps: 60.3; CPU: 20;  
GST-PERF INFO -->  Timestamp: 0:22:12.436397894; Bps: 763; fps: 60.3; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:22:13.436511097; Bps: 776; fps: 60.0; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:22:14.452705935; Bps: 763; fps: 60.3; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:22:15.453137400; Bps: 776; fps: 60.0; CPU: 21;  
GST-PERF INFO -->  Timestamp: 0:22:16.469405139; Bps: 763; fps: 60.3; CPU: 21;


1080p 60fps capture to display (in-place=false)

Example pipeline

gst-launch-1.0 nvcamerasrc queue-size=10 sensor-id=0 fpsRange='60 60' ! "video/x-raw(memory:NVMM),width=1920,height=1080,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=1920,height=1080,format=I420,framerate=60/1" ! cudafilter in-place=false location=./memcpy.so ! nvvidconv ! perf print-arm-load=true ! nvoverlaysink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:23:01.138137454; Bps: 767; fps: 59.34; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:23:02.154873022; Bps: 763; fps: 60.3; CPU: 26;  
GST-PERF INFO -->  Timestamp: 0:23:03.171479180; Bps: 763; fps: 60.3; CPU: 29;  
GST-PERF INFO -->  Timestamp: 0:23:04.188158165; Bps: 763; fps: 60.3; CPU: 25;  
GST-PERF INFO -->  Timestamp: 0:23:05.188244497; Bps: 776; fps: 60.0; CPU: 21;  
GST-PERF INFO -->  Timestamp: 0:23:06.188254958; Bps: 776; fps: 60.0; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:23:07.204520450; Bps: 763; fps: 60.3; CPU: 19;  
GST-PERF INFO -->  Timestamp: 0:23:08.204789584; Bps: 776; fps: 60.0; CPU: 20;  
GST-PERF INFO -->  Timestamp: 0:23:09.204948578; Bps: 776; fps: 60.0; CPU: 20;  
GST-PERF INFO -->  Timestamp: 0:23:10.221653172; Bps: 763; fps: 60.3; CPU: 20;


4K 60fps capture to fakesink (in-place=false)

Example pipeline

gst-launch-1.0 nvcamerasrc queue-size=10 sensor-id=0 fpsRange='60 60' ! "video/x-raw(memory:NVMM),width=3840,height=2160,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=3840,height=2160,format=I420,framerate=60/1" ! cudafilter in-place=false location=./memcpy.so ! perf print-arm-load=true ! fakesink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:24:09.089973138; Bps: 12294071; fps: 64.22; CPU: 26;  
GST-PERF INFO -->  Timestamp: 0:24:10.101478081; Bps: 12306231; fps: 59.34; CPU: 21;  
GST-PERF INFO -->  Timestamp: 0:24:11.113397407; Bps: 12306231; fps: 59.34; CPU: 20;  
GST-PERF INFO -->  Timestamp: 0:24:12.124119254; Bps: 12318415; fps: 59.40; CPU: 21;  
GST-PERF INFO -->  Timestamp: 0:24:13.135918813; Bps: 12306231; fps: 59.34; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:24:14.147912287; Bps: 12306231; fps: 59.34; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:24:15.158284015; Bps: 12318415; fps: 59.40; CPU: 22;  
GST-PERF INFO -->  Timestamp: 0:24:16.170463292; Bps: 12294071; fps: 59.28; CPU: 24;  
GST-PERF INFO -->  Timestamp: 0:24:17.180258276; Bps: 12330624; fps: 59.46; CPU: 24;  
GST-PERF INFO -->  Timestamp: 0:24:18.193795065; Bps: 12281934; fps: 59.23; CPU: 21;


720p 60fps videotestsrc to display (in-place=false)

Example pipeline

gst-launch-1.0 videotestsrc is-live=true ! "video/x-raw,width=1280,height=720,format=I420,framerate=60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=1280,height=720,format=I420,framerate=60/1" ! cudafilter in-place=false location=./memcpy.so ! nvvidconv ! perf print-arm-load=true ! nvoverlaysink --gst-debug=0

Performance stats

GST-PERF INFO -->  Timestamp: 0:24:57.867517465; Bps: 763; fps: 60.3; CPU: 18;  
GST-PERF INFO -->  Timestamp: 0:24:58.884439856; Bps: 763; fps: 60.3; CPU: 16;  
GST-PERF INFO -->  Timestamp: 0:24:59.900505960; Bps: 763; fps: 60.3; CPU: 16;  
GST-PERF INFO -->  Timestamp: 0:25:00.900508129; Bps: 776; fps: 60.0; CPU: 16;  
GST-PERF INFO -->  Timestamp: 0:25:01.900516089; Bps: 776; fps: 60.0; CPU: 17;  
GST-PERF INFO -->  Timestamp: 0:25:02.900852285; Bps: 776; fps: 60.0; CPU: 16;  
GST-PERF INFO -->  Timestamp: 0:25:03.917406393; Bps: 763; fps: 60.3; CPU: 17;  
GST-PERF INFO -->  Timestamp: 0:25:04.917408755; Bps: 776; fps: 60.0; CPU: 16;  
GST-PERF INFO -->  Timestamp: 0:25:05.917422898; Bps: 776; fps: 60.0; CPU: 16;  
GST-PERF INFO -->  Timestamp: 0:25:06.934306770; Bps: 763; fps: 60.3; CPU: 17;


Example 1: cudafilter


Home

Example 3: cudadebayer




RidgeRun Resources

Quick Start Client Engagement Process RidgeRun Blog Homepage
Technical and Sales Support RidgeRun Online Store RidgeRun Videos Contact Us

OOjs UI icon message-progressive.svg Contact Us

Visit our Main Website for the RidgeRun Products and Online Store. RidgeRun Engineering informations are available in RidgeRun Professional Services, RidgeRun Subscription Model and Client Engagement Process wiki pages. Please email to support@ridgerun.com for technical questions and contactus@ridgerun.com for other queries. Contact details for sponsoring the RidgeRun GStreamer projects are available in Sponsor Projects page. Ridgerun-logo.svg
RR Contact Us.png