GStreamer Daemon - Digital PTZ
← Digital Camera |
⌂ Home |
→ GStreamer Daemon - ROS |
Digital PTZ
Digital PTZ is based on 3 parameters: input resolution, output resolution, and properties (pan, tilt, and zoom). the properties can be described as following:
Zoom
The zoom can reduce the resolution of the output image and the output image can be crop or a complete image, taking the input image as a complete reference. Follow the picture below which explains how it works:

Pan-Tilt
- Pan: Indicates the movement left or right in the image coordinate.
- Tilt: Indicates the movement top or bottom in the image coordinate.
Follow picture explain how works Pan and tilt:

Using Gstd
For the PTZ example, we will use Gstd that allows us to change the values of any property of the elements in the pipeline while the pipeline is running, in our case is very useful that feature. The next example script can move a cropped window around a video playback, also the window can be zoom-in and zoom out.
how to use the example:
* Use A for a left move. * Use D for a right move. * Use W for a up move. * Use S for a down move. * Use Z to zoom-in. * Use X to zoom-out. * Use ESC to exit on the example.
#!/bin/bash
# Graceful cleanup upon CTRL-C
trap "gstd-client pipeline_delete p; exit" SIGHUP SIGINT SIGTERM
# Make sure there is no pipeline with this name already
gstd-client pipeline_delete p
gstd-client pipeline_create p videotestsrc is-live=true ! capsfilter caps=video/x-raw,width=640,height=480 ! videocrop name=crop ! videoscale ! capsfilter caps=video/x-raw,width=320,height=240 ! autovideosink
gstd-client pipeline_play p
bool=true
left_=50
right_=50
up_=50
down_=50
# set the start values for the window cropped
gstd-client element_set p crop right $right_
gstd-client element_set p crop left $left_
gstd-client element_set p crop bottom $down_
gstd-client element_set p crop top $up_
while [ "$bool" = true ];
do read -s -n 1 key # read from the keyboard
case $key in
'a')
echo "left"
# Use "A" key move to the left side
if [ $left_ -gt 0 ]
then
left_=$((left_ - 5))
right_=$((right_ + 5))
gstd-client element_set p crop right $right_
gstd-client element_set p crop left $left_
fi
;;
'd')
echo "right"
# Use "D" key to move to the right side
if [ $right_ -gt 0 ]
then
right_=$((right_ - 5))
left_=$((left_ + 5))
gstd-client element_set p crop right $right_
gstd-client element_set p crop left $left_
fi
;;
's')
echo "down"
# Use "S" key to move to the bottom side
if [ $down_ -gt 0 ]
then
up_=$((up_ + 5))
down_=$((down_ - 5))
gstd-client element_set p crop bottom $down_
gstd-client element_set p crop top $up_
fi
;;
'w')
echo "up"
# Use "W" key to move to the top side
if [ $up_ -gt 0 ]
then
down_=$((down_ + 5))
up_=$((up_ - 5))
gstd-client element_set p crop top $up_
gstd-client element_set p crop bottom $down_
fi
;;
'x')
echo "zoom-out"
# Use "X" key to Zoom out
if [ $up_ -gt 0 ] && [ $down_ -gt 0 ] && [ $left_ -gt 0 ] && [ $right_ -gt 0 ]
then
down_=$((down_ - 5))
up_=$((up_ - 5))
right_=$((right_ - 5))
left_=$((left_ - 5))
gstd-client element_set p crop top $up_
gstd-client element_set p crop bottom $down_
gstd-client element_set p crop right $right_
gstd-client element_set p crop left $left_
fi
;;
'z')
echo "zoom-in"
# Use "Z" key to Zoom in
if [ $up_ -lt 200 ]
then
down_=$((down_ + 5))
up_=$((up_ + 5))
right_=$((right_ + 5))
left_=$((left_ + 5))
gstd-client element_set p crop top $up_
gstd-client element_set p crop bottom $down_
gstd-client element_set p crop right $right_
gstd-client element_set p crop left $left_
fi
;;
$'\e')
echo "Escape"
# Use "ESC" key to exit to the application
break
;;
esac
done
To run the PTZ script type:
./PTZ.sh
← Digital Camera |
⌂ Home |
→ GStreamer Daemon - ROS |
- GStreamer Daemon Basics
- Building GStreamer Daemon
- Quick Start Guide
- Interacting with Pipelines
- Modifying Element Properties
- Sending Events
- Receiving Messages from the Bus
- Receiving Signals
- Enabling the Debug Subsystem
- Low-level Implementation for Applications
- Response Format
- API Reference
- Simple Examples
- Advanced Examples
- Troubleshooting
- Releases
- Licensing
- FAQ
- Contact Us