GStreamer Daemon - Digital PTZ
← Digital Camera |
⌂ Home |
→ GStreamer Daemon - ROS |
Contents
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.
1 #!/bin/bash
2
3 # Graceful cleanup upon CTRL-C
4
5 trap "gstd-client pipeline_delete p; exit" SIGHUP SIGINT SIGTERM
6
7 # Make sure there is no pipeline with this name already
8 gstd-client pipeline_delete p
9
10 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
11 gstd-client pipeline_play p
12
13 bool=true
14 left_=50
15 right_=50
16 up_=50
17 down_=50
18
19 # set the start values for the window cropped
20 gstd-client element_set p crop right $right_
21 gstd-client element_set p crop left $left_
22 gstd-client element_set p crop bottom $down_
23 gstd-client element_set p crop top $up_
24
25 while [ "$bool" = true ];
26 do read -s -n 1 key # read from the keyboard
27 case $key in
28 'a')
29 echo "left"
30 # Use "A" key move to the left side
31 if [ $left_ -gt 0 ]
32 then
33 left_=$((left_ - 5))
34 right_=$((right_ + 5))
35 gstd-client element_set p crop right $right_
36 gstd-client element_set p crop left $left_
37 fi
38 ;;
39 'd')
40 echo "right"
41 # Use "D" key to move to the right side
42 if [ $right_ -gt 0 ]
43 then
44 right_=$((right_ - 5))
45 left_=$((left_ + 5))
46 gstd-client element_set p crop right $right_
47 gstd-client element_set p crop left $left_
48 fi
49 ;;
50 's')
51 echo "down"
52 # Use "S" key to move to the bottom side
53 if [ $down_ -gt 0 ]
54 then
55 up_=$((up_ + 5))
56 down_=$((down_ - 5))
57 gstd-client element_set p crop bottom $down_
58 gstd-client element_set p crop top $up_
59 fi
60 ;;
61 'w')
62 echo "up"
63 # Use "W" key to move to the top side
64 if [ $up_ -gt 0 ]
65 then
66 down_=$((down_ + 5))
67 up_=$((up_ - 5))
68 gstd-client element_set p crop top $up_
69 gstd-client element_set p crop bottom $down_
70 fi
71 ;;
72 'x')
73 echo "zoom-out"
74 # Use "X" key to Zoom out
75 if [ $up_ -gt 0 ] && [ $down_ -gt 0 ] && [ $left_ -gt 0 ] && [ $right_ -gt 0 ]
76 then
77 down_=$((down_ - 5))
78 up_=$((up_ - 5))
79 right_=$((right_ - 5))
80 left_=$((left_ - 5))
81 gstd-client element_set p crop top $up_
82 gstd-client element_set p crop bottom $down_
83 gstd-client element_set p crop right $right_
84 gstd-client element_set p crop left $left_
85 fi
86 ;;
87 'z')
88 echo "zoom-in"
89 # Use "Z" key to Zoom in
90 if [ $up_ -lt 200 ]
91 then
92 down_=$((down_ + 5))
93 up_=$((up_ + 5))
94 right_=$((right_ + 5))
95 left_=$((left_ + 5))
96 gstd-client element_set p crop top $up_
97 gstd-client element_set p crop bottom $down_
98 gstd-client element_set p crop right $right_
99 gstd-client element_set p crop left $left_
100 fi
101 ;;
102 $'\e')
103 echo "Escape"
104 # Use "ESC" key to exit to the application
105 break
106 ;;
107
108 esac
109 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