GstCUDA - Example - opencvwarp: Difference between revisions

From RidgeRun Developer Wiki
No edit summary
mNo edit summary
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{GstCUDA/Head|previous=Example: opencv|next=Example - opencvfilter|keywords=GstCUDA Examples,opencvwarp,opencvfilter, opencv examples}}
{{GstCUDA/Head|previous=Example: opencv|next=Example - opencvfilter|metakeywords=GstCUDA Examples, opencvwarp, opencvfilter, opencv examples}}


This page is under construction.
__TOC__
__TOC__


== Introduction ==
== Introduction ==


== Examples ==
The opencvwarp element will modify an image given a 3x3 transformation matrix. If the demo property of the element is enabled, it will apply a transformation that involves a rotation of the image in a 3D space and then a projection back to the image plane like this:
 
=== Demo example ===


=== Custom example ===
[[File:Opencvwarp demo example.gif|500px|frame|center|Figure 1. Opencvwarp demo transformation]]


== Element properties ==
== Element properties ==


* '''name'''<br/>
* '''demo'''<br/>
Name of the object.<br/>
Put the element in demo mode to showcase its capabilities. In this mode, the incoming image will be rotated in the 3D space and projected back to the image plane. Will override the transformation matrix.<br/>
Type: String<br/>
Flags: readable, writable<br/>
Default: "opencvwarp0"
 
* '''parent'''<br/>
The parent of the object.<br/>
Type: GstObject<br/>
Flags: readable, writable<br/>
 
* '''qos'''<br/>
Handle Quality-of-Service events.<br/>
Type: Boolean<br/>
Type: Boolean<br/>
Flags: readable, writable<br/>
Flags: readable, writable<br/>
Default: false
Default: false


* '''m00'''<br/>
* '''m00-m22'''<br/>
Coefficient 0,0 (row, column) of the transform matrix.<br/>
The 9 coefficients of the 3x3 perspective transformation matrix. This matrix may be changed dynamically to animate transformations.<br/>
Type: Double<br/>
Type: Double<br/>
Range: -1,797693e+308 -  1,797693e+308
Range: -1,797693e+308 -  1,797693e+308
Flags: readable, writable<br/>
Flags: readable, writable<br/>
Default: 1
Default: identity matrix


* '''m01'''<br/>
== Examples ==
Coefficient 0,1 (row, column) of the transform matrix.<br/>
The following two examples will provide an introduction to the element and its capabilities. Both examples were tested on '''Nvidia Jetson TX1''' and '''TX2''' connected to a display via HDMI and using a webcam as input video source.
Type: Double<br/>
Range: -1,797693e+308 -  1,797693e+308
Flags: readable, writable<br/>
Default: 0


* '''m02'''<br/>
=== Demo example ===
Coefficient 0,2 (row, column) of the transform matrix.<br/>
This example is meant to show the element capabilities. The image will be rotated in three-dimensional space and projected back to the image plane.
Type: Double<br/>
Range: -1,797693e+308 -   1,797693e+308
Flags: readable, writable<br/>
Default: 0
 
* '''m10'''<br/>
Coefficient 1,0 (row, column) of the transform matrix.<br/>
Type: Double<br/>
Range: -1,797693e+308 -  1,797693e+308
Flags: readable, writable<br/>
Default: 0


* '''m11'''<br/>
By running the following pipeline:
Coefficient 1,1 (row, column) of the transform matrix.<br/>
<syntaxhighlight lang="bash">
Type: Double<br/>
gst-launch-1.0 v4l2src ! nvvidconv ! opencvwarp demo=true ! queue ! nvvidconv ! autovideosink
Range: -1,797693e+308 -   1,797693e+308
</syntaxhighlight>
Flags: readable, writable<br/>
Default: 1


* '''m12'''<br/>
you should obtain the result shown in Figure 1.
Coefficient 1,2 (row, column) of the transform matrix.<br/>
Type: Double<br/>
Range: -1,797693e+308 -  1,797693e+308
Flags: readable, writable<br/>
Default: 0


* '''m20'''<br/>
=== Custom example ===
Coefficient 2,0 (row, column) of the transform matrix.<br/>
You can also define your own custom matrix, as shown below.
Type: Double<br/>
Range: -1,797693e+308 -  1,797693e+308
Flags: readable, writable<br/>
Default: 0


* '''m21'''<br/>
<syntaxhighlight lang="bash">
Coefficient 2,1 (row, column) of the transform matrix.<br/>
#!/bin/bash
Type: Double<br/>
Range: -1,797693e+308 -  1,797693e+308
Flags: readable, writable<br/>
Default: 0
 
* '''m22'''<br/>
Coefficient 2,2 (row, column) of the transform matrix.<br/>
Type: Double<br/>
Range: -1,797693e+308 -  1,797693e+308
Flags: readable, writable<br/>
Default: 1


* '''demo'''<br/>
m00=0.7071068
Put the element in demo mode to showcase it's capabilities. In this mode the incoming image will be rotated in the 3D space and projected back to the image plane. Will override the transformation matrix.<br/>
m01=-0.7071068
Type: Boolean<br/>
m02=0.0000000
Flags: readable, writable<br/>
m10=0.7071068
Default: false
m11=0.7071068
m12=0.0000000
m20=0.0000000
m21=0.0000000
m22=1.0000000


gst-launch-1.0 v4l2src device=/dev/video1 ! nvvidconv \
! opencvwarp m00=$m00 m01=$m01 m02=$m02 m10=$m10 m11=$m11 m12=$m12 m20=$m20 m21=$m21 m22=$m22 \
! queue ! nvvidconv ! autovideosink
</syntaxhighlight>
{{GstCUDA/Foot|previous=Example: opencv|next=Example - opencvfilter}}
{{GstCUDA/Foot|previous=Example: opencv|next=Example - opencvfilter}}

Latest revision as of 14:32, 10 March 2023


Previous: Example: opencv Index Next: Example - opencvfilter




Introduction

The opencvwarp element will modify an image given a 3x3 transformation matrix. If the demo property of the element is enabled, it will apply a transformation that involves a rotation of the image in a 3D space and then a projection back to the image plane like this:

Figure 1. Opencvwarp demo transformation

Element properties

  • demo

Put the element in demo mode to showcase its capabilities. In this mode, the incoming image will be rotated in the 3D space and projected back to the image plane. Will override the transformation matrix.
Type: Boolean
Flags: readable, writable
Default: false

  • m00-m22

The 9 coefficients of the 3x3 perspective transformation matrix. This matrix may be changed dynamically to animate transformations.
Type: Double
Range: -1,797693e+308 - 1,797693e+308 Flags: readable, writable
Default: identity matrix

Examples

The following two examples will provide an introduction to the element and its capabilities. Both examples were tested on Nvidia Jetson TX1 and TX2 connected to a display via HDMI and using a webcam as input video source.

Demo example

This example is meant to show the element capabilities. The image will be rotated in three-dimensional space and projected back to the image plane.

By running the following pipeline:

gst-launch-1.0 v4l2src ! nvvidconv ! opencvwarp demo=true ! queue ! nvvidconv ! autovideosink

you should obtain the result shown in Figure 1.

Custom example

You can also define your own custom matrix, as shown below.

#!/bin/bash

m00=0.7071068
m01=-0.7071068
m02=0.0000000
m10=0.7071068
m11=0.7071068
m12=0.0000000
m20=0.0000000
m21=0.0000000
m22=1.0000000

gst-launch-1.0 v4l2src device=/dev/video1 ! nvvidconv \
! opencvwarp m00=$m00 m01=$m01 m02=$m02 m10=$m10 m11=$m11 m12=$m12 m20=$m20 m21=$m21 m22=$m22 \
! queue ! nvvidconv ! autovideosink


Previous: Example: opencv Index Next: Example - opencvfilter