Difference between revisions of "GstCUDA - Example - opencvfilter"
(Add custom kernel properties and examples.) |
|||
Line 36: | Line 36: | ||
* '''dx'''<br/> | * '''dx'''<br/> | ||
− | Derivative order in respect of X.<br/> | + | Derivative order in respect of X (for deriv, sobel and scharr).<br/> |
Type: Integer<br/> | Type: Integer<br/> | ||
Range: 0 - 2<br/> | Range: 0 - 2<br/> | ||
Line 43: | Line 43: | ||
* '''dy'''<br/> | * '''dy'''<br/> | ||
− | Derivative order in respect of Y.<br/> | + | Derivative order in respect of Y (for deriv, sobel and scharr).<br/> |
Type: Integer<br/> | Type: Integer<br/> | ||
Range: 0 - 2<br/> | Range: 0 - 2<br/> | ||
Line 50: | Line 50: | ||
* '''scale'''<br/> | * '''scale'''<br/> | ||
− | Optional scale factor for the computed values.<br/> | + | Optional scale factor for the computed values (for deriv, laplacian, sobel and scharr).<br/> |
Type: Integer<br/> | Type: Integer<br/> | ||
Range: 1 - 2147483647<br/> | Range: 1 - 2147483647<br/> | ||
Line 57: | Line 57: | ||
* '''iterations'''<br/> | * '''iterations'''<br/> | ||
− | Number of times for the morphological operations to be applied.<br/> | + | Number of times for the morphological operations to be applied (for morphology).<br/> |
Type: Integer<br/> | Type: Integer<br/> | ||
Range: 1 - 2147483647<br/> | Range: 1 - 2147483647<br/> | ||
Line 64: | Line 64: | ||
* '''morph-op'''<br/> | * '''morph-op'''<br/> | ||
− | Type of morphological operation. | + | Type of morphological operation (for morphology). Available options:<br/> |
− | + | ::'''erode''': Normalized box filter | |
− | + | ::'''dilate''': Maximum filter | |
+ | ::'''open''': Minimum filter | ||
+ | ::'''close''': Vertical 1D box filter | ||
+ | Flags: readable, writable<br/> | ||
+ | Default: "erode" | ||
+ | * '''kernel'''<br/> | ||
+ | -2D matrix of NxM to use as kernel (for linear and morphology filters).<br/> | ||
+ | -2D matrix of 1xM to use as a row kernel (for separable filter).<br/> | ||
+ | Type: GstValueArray of GValues of type GstValueArray<br/> | ||
Flags: readable, writable<br/> | Flags: readable, writable<br/> | ||
− | Default: 0 | + | Default: <<1.0,0.0,0.0>,<0.0,1.0,0.0>,<0.0,0.0,1.0>> |
+ | |||
+ | == Examples == | ||
+ | |||
+ | The following examples pipe will help you apply different types of filters to the input video stream from your camera. These pipes were tested on both, the Nvidia Jetson TX1 and TX2. | ||
− | == | + | === Border Detection === |
− | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
gst-launch-1.0 v4l2src ! nvvidconv ! opencvfilter filter=sobel dx=0 dy=1 size=1 ! queue ! nvvidconv ! autovideosink | gst-launch-1.0 v4l2src ! nvvidconv ! opencvfilter filter=sobel dx=0 dy=1 size=1 ! queue ! nvvidconv ! autovideosink | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | === Linear Filter with Custom Kernel === | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | gst-launch-1.0 v4l2src ! nvvidconv ! opencvfilter filter=linear kernel="<<0.0,0.0, 0.0>,<0.0,0.5,0.0>,<0.0,0.0,0.0>>" ! queue ! nvvidconv ! autovideosink | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === Separable Filter with Custom Row and Column Kernels === | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | gst-launch-1.0 v4l2src ! nvvidconv ! opencvfilter filter=separable kernel="<<0.0,0.5,0.0>>" kernel2="<<0.2,0.2,0.7,0.5>>" ! queue ! nvvidconv ! autovideosink | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | |||
{{GstCUDA/Foot|previous=Example - opencvwarp|next=Performance Profiling}} | {{GstCUDA/Foot|previous=Example - opencvwarp|next=Performance Profiling}} |
Revision as of 12:36, 17 September 2020
![]() |
Contents
Introduction
The opencvfilter element exposes a series of image filters from the popular computer vision framework OpenCV. The following figure shows some of the available filters applied to the same image.
Element properties
- size
The size of the filter. Depending on the filter, it could either be the kernel size or the aperture size. Must be odd.
Type: Integer
Range: 1 - 2147483647
Flags: readable, writable
Default: 3
- filter
Type of the filter to create. Available options:
- box: Normalized box filter
- box-max: Maximum filter
- box-min: Minimum filter
- column-sum: Vertical 1D box filter
- deriv: General deriv filter
- gaussian: Gaussian filter
- laplacian: Laplacian filter
- linear: General linear filter
- morphology: Morphological filter
- row-sum: Horizontal 1D box filter
- scharr: Scharr filter
- separable: Separable linear filter
- sobel: Sobel filter
Flags: readable, writable
Default: "gaussian"
- dx
Derivative order in respect of X (for deriv, sobel and scharr).
Type: Integer
Range: 0 - 2
Flags: readable, writable
Default: 0
- dy
Derivative order in respect of Y (for deriv, sobel and scharr).
Type: Integer
Range: 0 - 2
Flags: readable, writable
Default: 0
- scale
Optional scale factor for the computed values (for deriv, laplacian, sobel and scharr).
Type: Integer
Range: 1 - 2147483647
Flags: readable, writable
Default: 1
- iterations
Number of times for the morphological operations to be applied (for morphology).
Type: Integer
Range: 1 - 2147483647
Flags: readable, writable
Default: 1
- morph-op
Type of morphological operation (for morphology). Available options:
- erode: Normalized box filter
- dilate: Maximum filter
- open: Minimum filter
- close: Vertical 1D box filter
Flags: readable, writable
Default: "erode"
- kernel
-2D matrix of NxM to use as kernel (for linear and morphology filters).
-2D matrix of 1xM to use as a row kernel (for separable filter).
Type: GstValueArray of GValues of type GstValueArray
Flags: readable, writable
Default: <<1.0,0.0,0.0>,<0.0,1.0,0.0>,<0.0,0.0,1.0>>
Examples
The following examples pipe will help you apply different types of filters to the input video stream from your camera. These pipes were tested on both, the Nvidia Jetson TX1 and TX2.
Border Detection
gst-launch-1.0 v4l2src ! nvvidconv ! opencvfilter filter=sobel dx=0 dy=1 size=1 ! queue ! nvvidconv ! autovideosink
Linear Filter with Custom Kernel
gst-launch-1.0 v4l2src ! nvvidconv ! opencvfilter filter=linear kernel="<<0.0,0.0, 0.0>,<0.0,0.5,0.0>,<0.0,0.0,0.0>>" ! queue ! nvvidconv ! autovideosink
Separable Filter with Custom Row and Column Kernels
gst-launch-1.0 v4l2src ! nvvidconv ! opencvfilter filter=separable kernel="<<0.0,0.5,0.0>>" kernel2="<<0.2,0.2,0.7,0.5>>" ! queue ! nvvidconv ! autovideosink