Difference between revisions of "GStreamer Pan Tilt Zoom and Rotate Element - Demo Tool"

From RidgeRun Developer Connection
Jump to: navigation, search
(Add details of how to use the interactive mode)
m
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{GStreamer Pan Tilt Zoom and Rotate Element Page|  
+
{{GStreamer Pan Tilt Zoom and Rotate Element/Head |previous=Tegra Pipelines|next=Contact Us|metakeywords=GstPTZR demo tool, ptzr test, GstPTZR testing, GstPTZR debug, GstPTZR demo tool}}
[[GStreamer Pan Tilt Zoom and Rotate Element - iMX6 Pipelines|iMX6 Pipelines]]|
+
 
[[GStreamer Pan Tilt Zoom and Rotate Element|Home]]|
 
 
The demo tool is a Python script called {{code|ptzr_test}} located in the {{code|tests/examples}} directory. It can be used to demonstrate and test the different transformations that are possible using the [[GStreamer Pan Tilt Zoom and Rotate Element|GStreamer PTZR element]].
 
The demo tool is a Python script called {{code|ptzr_test}} located in the {{code|tests/examples}} directory. It can be used to demonstrate and test the different transformations that are possible using the [[GStreamer Pan Tilt Zoom and Rotate Element|GStreamer PTZR element]].
  
Line 14: Line 13:
 
It will allow the user to manipulate the different properties of the GstPTZR element in a number of different ways, according to the mode that is selected.
 
It will allow the user to manipulate the different properties of the GstPTZR element in a number of different ways, according to the mode that is selected.
  
To start the script, run it directly in your console:
+
To start the script, start it from the console:
  
 
<syntaxhighlight lang=bash>
 
<syntaxhighlight lang=bash>
 
user@host:~/gst-ptzr$ tests/examples/ptzr_test
 
user@host:~/gst-ptzr$ tests/examples/ptzr_test
 +
</syntaxhighlight>
 +
 +
The script has a detailed help that can be printed by calling the script with the <code>-h</code> or <code>--help</code> switch:
 +
 +
<syntaxhighlight lang=bash>
 +
user@host:~/gst-ptzr$ tests/examples/ptzr_test --help
 +
usage: ptzr_test [-h]
 +
                [--interactive | --cmdline | --demo | --script SCRIPT | --file FILE]
 +
                [--profile PROFILE] [--pipeline-name PIPELINE_NAME]
 +
                [--element-name ELEMENT_NAME] [--device DEVICE]
 +
                [--input-resolution IN_RESOLUTION]
 +
                [--output-resolution OUT_RESOLUTION] [--debug] [--loop]
 +
                [--ip IP] [--port PORT]
 +
 +
PTZR demo app
 +
 +
optional arguments:
 +
  -h, --help            show this help message and exit
 +
  --interactive, -i    Start in interactive mode (default)
 +
  --cmdline, -c        Start in command line mode
 +
  --demo, -D            Start in demo mode
 +
  --script SCRIPT, -s SCRIPT
 +
                        Run the script commands provided and exit. Use
 +
                        multiple times or separate commands with ;
 +
  --file FILE, -f FILE  Read commands from the provided file and exit
 +
  --profile PROFILE, -p PROFILE
 +
                        Selects on of the known profiles when creating the
 +
                        pipeline. Valid values include pc, pc-v4l2, imx6,
 +
                        tegra (default: pc)
 +
  --pipeline-name PIPELINE_NAME, -P PIPELINE_NAME
 +
                        Specify the name of the pipeline to be used (default:
 +
                        p0)
 +
  --element-name ELEMENT_NAME, -E ELEMENT_NAME
 +
                        Specify the name of the element to be used (default:
 +
                        ptzr0)
 +
  --device DEVICE, -v DEVICE
 +
                        Specify the device to use when using a v4l2 profile
 +
                        (default: /dev/video0)
 +
  --input-resolution IN_RESOLUTION, -I IN_RESOLUTION
 +
                        Specify the resolution (width x height) for input
 +
                        caps. (default: 640x480)
 +
  --output-resolution OUT_RESOLUTION, -O OUT_RESOLUTION
 +
                        Specify the resolution (width x height) for output
 +
                        caps. (default: 640x480)
 +
  --debug, -d          Print debug information
 +
  --loop, -l            In script or demo modes, loop the commands. Exit loop
 +
                        with Control-C
 +
  --ip IP, -a IP        Specify the IP address of the host running Gstd
 +
                        (default: localhost)
 +
  --port PORT          Specify the PORT address of the host running Gstd
 +
                        (default: 5000)
 +
 +
user@host:~/gst-ptzr$
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 26: Line 78:
 
=== Interactive ===
 
=== Interactive ===
  
Interactive mode is the default mode. It can be started explicitly by using:
+
Interactive mode is the default mode. It can be started explicitly by using the <code>-i</code> or <code>--interactive</code>:
  
 
<syntaxhighlight lang=bash>
 
<syntaxhighlight lang=bash>
Line 86: Line 138:
 
</html>
 
</html>
  
 +
=== Command line ===
 +
 +
To start the tool in command line mode, use the <code>-c</code> or <code>--cmdline</code> switch. It will start a command-line interface:
 +
 +
<syntaxhighlight lang=bash>
 +
user@host:~/gst-ptzr$ tests/examples/ptzr_test -c
 +
A pipeline is already running, test that it has the right elements.
 +
The current pipeline p0 contains an element ptzr0 that can be used.
 +
Pipeline is now running.
 +
pipe [p0] element [ptzr0]
 +
Welcome to the PTZR tester!
 +
 +
This script can be used to test all the PTZR features by creating a pipeline
 +
that uses the gst-ptzr element. It uses a autovideosrc and caps both input and
 +
output to a 640x480 screen.
 +
PTZR>
 +
</syntaxhighlight>
 +
 +
The command-line interface has support for auto-completion and session history.
 +
 +
<html>
 +
  <center>
 +
  <table class='wikitable'>
 +
    <tr>
 +
      <th>Command</th>
 +
      <th>Action</th>
 +
    </tr>
 +
    <tr>
 +
      <td>pan &lt;nn&gt;<br>pan_delta &lt;nn&gt;</td>
 +
      <td>add nn to pan value</td>
 +
    </tr>
 +
    <tr>
 +
      <td>pan abs &lt;nn&gt;<br>pan_level &lt;nn&gt;</td>
 +
      <td>set pan value to nn</td>
 +
    </tr>
 +
    <tr>
 +
      <td>tilt &lt;nn&gt;<br>tilt_delta &lt;nn&gt;</td>
 +
      <td>add nn to tilt value</td>
 +
    </tr>
 +
    <tr>
 +
      <td>tilt abs &lt;nn&gt;<br>tilt_level &lt;nn&gt;</td>
 +
      <td>set tilt value to nn</td>
 +
    </tr>
 +
    <tr>
 +
      <td>zoom &lt;nn&gt;</td>
 +
      <td>set zoom value to nn</td>
 +
    </tr>
 +
    <tr>
 +
      <td>rotate &lt;nn&gt;<br>rotate_delta &lt;nn&gt;</td>
 +
      <td>add nn to rotate value</td>
 +
    </tr>
 +
    <tr>
 +
      <td>rotate abs &lt;nn&gt;<br>rotate_level &lt;nn&gt;</td>
 +
      <td>set rotate value to nn</td>
 +
    </tr>
 +
    <tr>
 +
      <td>delay &lt;nn&gt;</td>
 +
      <td>wait for nn seconds. Useful for writing scripts</td>
 +
    </tr>
 +
    <tr>
 +
      <td>get_values</td>
 +
      <td>shows the current values of the parameters in JSON mode</td>
 +
    </tr>
 +
    <tr>
 +
      <td>status</td>
 +
      <td>shows the current values of the parameters in readable mode</td>
 +
    </tr>
 +
    <tr>
 +
      <td>restart</td>
 +
      <td>restart the pipeline</td>
 +
    </tr>
 +
    <tr>
 +
      <td>set_output_reference &lt;nn&gt;</td>
 +
      <td>set output-reference mode to nn.<br>Valid values include: <code>false</code>, <code>False</code>, <code>0</code>, <code>true</code>, <code>True</code>, <code>1</code>, <code>enable</code></td>
 +
    </tr>
 +
    <tr>
 +
      <td>set_normalization &lt;nn&gt;</td>
 +
      <td>set normalize-translation mode to nn.<br>Valid values include: <code>false</code>, <code>False</code>, <code>0</code>, <code>true</code>, <code>True</code>, <code>1</code>, <code>enable</code></td>
 +
    </tr>
 +
    <tr>
 +
      <td>defaults</td>
 +
      <td>set all values to default</td>
 +
    </tr>
 +
    <tr>
 +
      <td>demo [loop]</td>
 +
      <td>start demo mode, if loop is specified, runs in an infinite loop. Control-C exits the loop</td>
 +
    </tr>
 +
    <tr>
 +
      <td>interactive</td>
 +
      <td>start interactive mode</td>
 +
    </tr>
 +
    <tr>
 +
      <td>exit<br>EOF</td>
 +
      <td>exit the application. EOF can be input with the Control-D key combination</td>
 +
    </tr>
 +
    <tr>
 +
      <td>help [command]</td>
 +
      <td>show general help. If command is specified, it will print help for the specific command</td>
 +
    </tr>
 +
    <caption>Table 2. Commands available in command-line mode</caption>
 +
  </table>
 +
  </center>
 +
</html>
  
=== Command line ===
 
TBD
 
 
=== Demo ===
 
=== Demo ===
TBD
+
 
 +
To start the tool in demo mode, use the <code>-D</code> or <code>--demo</code> switch. It will start running a series of commands that will make the image rotate in a circle.
 +
 
 +
<syntaxhighlight lang=bash>
 +
user@host:~/gst-ptzr$ tests/examples/ptzr_test -D
 +
A pipeline is already running, test that it has the right elements.
 +
The current pipeline p0 contains an element ptzr0 that can be used.
 +
Pipeline is now running.
 +
pipe [p0] element [ptzr0]
 +
...
 +
</syntaxhighlight>
 +
 
 
=== Script ===
 
=== Script ===
TBD
+
 
 +
To start the tool in script mode, use the <code>-s</code> or <code>--script</code> switch. It will run the command and exit.
 +
 
 +
<syntaxhighlight lang=bash>
 +
user@host:~/gst-ptzr$ tests/examples/ptzr_test --script "zoom 10"
 +
A pipeline is already running, test that it has the right elements.
 +
The current pipeline p0 contains an element ptzr0 that can be used.
 +
Pipeline is now running.
 +
pipe [p0] element [ptzr0]
 +
OK
 +
user@host:~/gst-ptzr$
 +
</syntaxhighlight>
 +
 
 +
Multiple commands can be entered by using multiple instances of <code>-s</code> or by separating the commands with a semi-colon:
 +
 
 +
<syntaxhighlight lang=bash>
 +
user@host:~/gst-ptzr$ tests/examples/ptzr_test -s "zoom 10 ; delay 5 ; zoom 2"
 +
A pipeline is already running, test that it has the right elements.
 +
The current pipeline p0 contains an element ptzr0 that can be used.
 +
Pipeline is now running.
 +
pipe [p0] element [ptzr0]
 +
OK
 +
OK
 +
OK
 +
user@host:~/gst-ptzr$
 +
</syntaxhighlight>
 +
 
 +
=== File ===
 +
 
 +
File mode is a special script mode where the script is read from a file. To start the tool in file mode, use the <code>-f</code> or <code>--file</code> switch. It will read the commands from a file and exit. A sample file is provided.
 +
 
 +
<syntaxhighlight lang=bash>
 +
user@host:~/gst-ptzr$ tests/examples/ptzr_test -f tests/examples/surveillance.txt
 +
A pipeline is already running, test that it has the right elements.
 +
The current pipeline p0 contains an element ptzr0 that can be used.
 +
Pipeline is now running.
 +
pipe [p0] element [ptzr0]
 +
OK
 +
OK
 +
OK
 +
...
 +
OK
 +
user@host:~/gst-ptzr$
 +
</syntaxhighlight>
  
 
== Other options ==
 
== Other options ==
  
=== Debug mode ===
+
=== Debug data ===
  
TBD
+
When debug is enabled, additional information about the system will be shown during the execution, in any mode that is being used. To enable debug, use the <code>-d</code> or <code>--debug</code> switch to enable it:
 +
 
 +
<syntaxhighlight lang=bash>
 +
user@host:~/gst-ptzr$ tests/examples/ptzr_test -s "zoom 10 ; delay 5 ; zoom 2" -d
 +
A pipeline is already running, test that it has the right elements.
 +
The current pipeline p0 contains an element ptzr0 that can be used.
 +
Pipeline is now running.
 +
pipe [p0] element [ptzr0]
 +
zoom 10  ... OK
 +
delay 5  ... OK
 +
zoom 2 ... OK
 +
user@host:~/gst-ptzr$
 +
</syntaxhighlight>
  
 
=== Loop ===
 
=== Loop ===
  
TBD
+
For [[GStreamer_Pan_Tilt_Zoom_and_Rotate_Element_-_Demo_Tool#Script|script]], [[GStreamer_Pan_Tilt_Zoom_and_Rotate_Element_-_Demo_Tool#Demo|demo]] and [[GStreamer_Pan_Tilt_Zoom_and_Rotate_Element_-_Demo_Tool#File|file]] modes, the loop option can be enabled with the <code>-l</code> or <code>--loop</code> switch to repeat the commands specified in a loop. Use Control-C to exit from the loop.
 +
 
 +
=== Remote access ===
 +
 
 +
The demo tool can be run in a remote device that can access the device running gstd via network. In this use case, use the <code>--ip IP</code> and <code>--port PORT</code> to specify the IP address and PORT to use.
 +
 
 +
In this mode, the tool is not able to detect if gstd is running or not, so make sure that the daemon has been started in the remote device.
 +
 
 +
This feature is particularly useful to test the element running on an embedded system while the demo tool is run remotely from a PC.
  
 
== Compatibility ==
 
== Compatibility ==
Line 115: Line 342:
 
psutil
 
psutil
 
</pre>
 
</pre>
}}
+
 
 +
{{GStreamer Pan Tilt Zoom and Rotate Element/Foot|previous=Tegra Pipelines|next=Contact Us}}

Latest revision as of 03:56, 4 March 2023


Previous: Tegra Pipelines Index Next: Contact Us




The demo tool is a Python script called ptzr_test located in the tests/examples directory. It can be used to demonstrate and test the different transformations that are possible using the GStreamer PTZR element.

ptzr_test

The ptzr_test script uses Ridgerun's GStreamer Daemon (gstd) to create a pipeline that can be used to demo the features of GstPTZR. If gstd is not running, it will try to start it.

It will create a pipeline with the name p0 with a GstPTZR element with the name ptzr0. The basic pipeline that will be created will use autovideosrc to pick the first available video source (a webcam, if available; a videotestsrc if not), with some basic caps. If a pipeline with those characteristics already exists, it will use it.

It will allow the user to manipulate the different properties of the GstPTZR element in a number of different ways, according to the mode that is selected.

To start the script, start it from the console:

user@host:~/gst-ptzr$ tests/examples/ptzr_test

The script has a detailed help that can be printed by calling the script with the -h or --help switch:

user@host:~/gst-ptzr$ tests/examples/ptzr_test --help
usage: ptzr_test [-h]
                 [--interactive | --cmdline | --demo | --script SCRIPT | --file FILE]
                 [--profile PROFILE] [--pipeline-name PIPELINE_NAME]
                 [--element-name ELEMENT_NAME] [--device DEVICE]
                 [--input-resolution IN_RESOLUTION]
                 [--output-resolution OUT_RESOLUTION] [--debug] [--loop]
                 [--ip IP] [--port PORT]

PTZR demo app

optional arguments:
  -h, --help            show this help message and exit
  --interactive, -i     Start in interactive mode (default)
  --cmdline, -c         Start in command line mode
  --demo, -D            Start in demo mode
  --script SCRIPT, -s SCRIPT
                        Run the script commands provided and exit. Use
                        multiple times or separate commands with ;
  --file FILE, -f FILE  Read commands from the provided file and exit
  --profile PROFILE, -p PROFILE
                        Selects on of the known profiles when creating the
                        pipeline. Valid values include pc, pc-v4l2, imx6,
                        tegra (default: pc)
  --pipeline-name PIPELINE_NAME, -P PIPELINE_NAME
                        Specify the name of the pipeline to be used (default:
                        p0)
  --element-name ELEMENT_NAME, -E ELEMENT_NAME
                        Specify the name of the element to be used (default:
                        ptzr0)
  --device DEVICE, -v DEVICE
                        Specify the device to use when using a v4l2 profile
                        (default: /dev/video0)
  --input-resolution IN_RESOLUTION, -I IN_RESOLUTION
                        Specify the resolution (width x height) for input
                        caps. (default: 640x480)
  --output-resolution OUT_RESOLUTION, -O OUT_RESOLUTION
                        Specify the resolution (width x height) for output
                        caps. (default: 640x480)
  --debug, -d           Print debug information
  --loop, -l            In script or demo modes, loop the commands. Exit loop
                        with Control-C
  --ip IP, -a IP        Specify the IP address of the host running Gstd
                        (default: localhost)
  --port PORT           Specify the PORT address of the host running Gstd
                        (default: 5000)

user@host:~/gst-ptzr$

Modes of operation

The demo tool can be used in a number of different configurations, according to the application. This section describes the different modes and the ways to interact with the element in each mode.

Interactive

Interactive mode is the default mode. It can be started explicitly by using the -i or --interactive:

user@host:~/gst-ptzr$ tests/examples/ptzr_test -i

It will show a curses UI with all the information you need to control the GstPTZR element.

Error creating thumbnail: Unable to save thumbnail to destination
Interactive mode

The interface is designed for using the keypad for controlling the PTZR element. Most of the controls are available single-handedly on the numeric keypad of a full keyboard. Table 1 shows the controls and the actions that can be done in the interactive mode.

Keys Action
left and right arrows change pan value by the selected step
up and down arrows change tilt value by the selected step
+ and - change zoom value by 0.1x
/ and * change rotate value by 5 degrees counterclockwise or clockwise
d and 0/Ins set all values to default
./DEL toggle output-reference mode
TAB and 5 toggle normalize-translation mode
F9 and F10 decrease and increase step used for pan/tilt from 5 preset values
q or ENTER exit the application
Table 1. Interactive mode controls

Command line

To start the tool in command line mode, use the -c or --cmdline switch. It will start a command-line interface:

user@host:~/gst-ptzr$ tests/examples/ptzr_test -c
A pipeline is already running, test that it has the right elements.
The current pipeline p0 contains an element ptzr0 that can be used.
Pipeline is now running.
pipe [p0] element [ptzr0]
Welcome to the PTZR tester!

This script can be used to test all the PTZR features by creating a pipeline
that uses the gst-ptzr element. It uses a autovideosrc and caps both input and
output to a 640x480 screen.
PTZR>

The command-line interface has support for auto-completion and session history.

Command Action
pan <nn>
pan_delta <nn>
add nn to pan value
pan abs <nn>
pan_level <nn>
set pan value to nn
tilt <nn>
tilt_delta <nn>
add nn to tilt value
tilt abs <nn>
tilt_level <nn>
set tilt value to nn
zoom <nn> set zoom value to nn
rotate <nn>
rotate_delta <nn>
add nn to rotate value
rotate abs <nn>
rotate_level <nn>
set rotate value to nn
delay <nn> wait for nn seconds. Useful for writing scripts
get_values shows the current values of the parameters in JSON mode
status shows the current values of the parameters in readable mode
restart restart the pipeline
set_output_reference <nn> set output-reference mode to nn.
Valid values include: false, False, 0, true, True, 1, enable
set_normalization <nn> set normalize-translation mode to nn.
Valid values include: false, False, 0, true, True, 1, enable
defaults set all values to default
demo [loop] start demo mode, if loop is specified, runs in an infinite loop. Control-C exits the loop
interactive start interactive mode
exit
EOF
exit the application. EOF can be input with the Control-D key combination
help [command] show general help. If command is specified, it will print help for the specific command
Table 2. Commands available in command-line mode

Demo

To start the tool in demo mode, use the -D or --demo switch. It will start running a series of commands that will make the image rotate in a circle.

user@host:~/gst-ptzr$ tests/examples/ptzr_test -D
A pipeline is already running, test that it has the right elements.
The current pipeline p0 contains an element ptzr0 that can be used.
Pipeline is now running.
pipe [p0] element [ptzr0]
...

Script

To start the tool in script mode, use the -s or --script switch. It will run the command and exit.

user@host:~/gst-ptzr$ tests/examples/ptzr_test --script "zoom 10"
A pipeline is already running, test that it has the right elements.
The current pipeline p0 contains an element ptzr0 that can be used.
Pipeline is now running.
pipe [p0] element [ptzr0]
OK
user@host:~/gst-ptzr$

Multiple commands can be entered by using multiple instances of -s or by separating the commands with a semi-colon:

user@host:~/gst-ptzr$ tests/examples/ptzr_test -s "zoom 10 ; delay 5 ; zoom 2"
A pipeline is already running, test that it has the right elements.
The current pipeline p0 contains an element ptzr0 that can be used.
Pipeline is now running.
pipe [p0] element [ptzr0]
OK
OK
OK
user@host:~/gst-ptzr$

File

File mode is a special script mode where the script is read from a file. To start the tool in file mode, use the -f or --file switch. It will read the commands from a file and exit. A sample file is provided.

user@host:~/gst-ptzr$ tests/examples/ptzr_test -f tests/examples/surveillance.txt
A pipeline is already running, test that it has the right elements.
The current pipeline p0 contains an element ptzr0 that can be used.
Pipeline is now running.
pipe [p0] element [ptzr0]
OK
OK
OK
...
OK
user@host:~/gst-ptzr$

Other options

Debug data

When debug is enabled, additional information about the system will be shown during the execution, in any mode that is being used. To enable debug, use the -d or --debug switch to enable it:

user@host:~/gst-ptzr$ tests/examples/ptzr_test -s "zoom 10 ; delay 5 ; zoom 2" -d
A pipeline is already running, test that it has the right elements.
The current pipeline p0 contains an element ptzr0 that can be used.
Pipeline is now running.
pipe [p0] element [ptzr0]
zoom 10  ... OK
delay 5  ... OK
zoom 2 ... OK
user@host:~/gst-ptzr$

Loop

For script, demo and file modes, the loop option can be enabled with the -l or --loop switch to repeat the commands specified in a loop. Use Control-C to exit from the loop.

Remote access

The demo tool can be run in a remote device that can access the device running gstd via network. In this use case, use the --ip IP and --port PORT to specify the IP address and PORT to use.

In this mode, the tool is not able to detect if gstd is running or not, so make sure that the daemon has been started in the remote device.

This feature is particularly useful to test the element running on an embedded system while the demo tool is run remotely from a PC.

Compatibility

ptzr_test has been tested with Python 2.7 and 3.5. If any compatibility issues arise, please report them.

It requires the following Python libraries:

cmd
curses
psutil


Previous: Tegra Pipelines Index Next: Contact Us