GStreamer Pan Tilt Zoom and Rotate Element - Rectangle

From RidgeRun Developer Wiki



Previous: Rotate Index Next: Evaluating GstPTZR




This page serves as a reference on how to adjust the rectangle property to define a region of interest on GstPTZR.

Rectangle Generalities

Most computer vision algorithms give a rectangle (region of interest) as an output instead, making pan, tilt and zoom levels not flexible enough. Gst-PTZR provides the rectangle property to set pan, tilt and zoom at the same time and in a more standard way. Consistency between all properties is always maintained, so the user doesn't have to worry about switching between representations. The rotate property is independent and thus it is the only one not being affected by a rectangle change. To change the rectangle the following parameter is used:

rectangle
Comma separated string containing rectangle data: 'x,y,width,height'

The following sections describe in more detail this property.

Rectangle

The rectangle data consists in 4 integers separated by 3 commas. Each integer purpose is self-explanatory: x and y define the upper left point of the rectangle, and width and height it's dimensions. The example of figure 1 shows a rectangle starting on (0,0) of width and height of 300 pixels.

Figure 1. GstPTZR configured with rectangle="0,0,300,300" on Bartok the Dachshund


Coordinates and Limits

coordinate systems

The coordinate systems used around the plugin can be confusing. The coordinates used for pan and tilt are supposed to emulate a PTZ camera behavior. In these cameras the coordinate system is define using the camera as a reference. The reference of the coordinates can also be change between the output and the input image as seen on the pan & tilt wiki page. On the other hand, the rectangle property uses standard image coordinates (starting in the top left corner). The comparison between the two systems can be seen in figure 2 and 3. Panoramic coordinates are used for pan and tilt and they origin in the center of the image. Standard image coordinates are used for rectangle and origin in the top left corner.

Figure 2. Coordinate system used by pan and tilt on Bartok the Dachshund
Figure 3. Coordinate system used by rectangle on Bartok the Dachshund

rectangle limits

Rectangle size is not only limited by the input and output resolution like pan and tilt, but also by the starting coordinate on the image. This means that sometimes a certain size will be legal, but that just changing x and y will cause an error. The general rule for rectangle limits is the same as for pan and tilt. Every pixel of the output image, except when a rotation is applied, must be inside the input image. Rotations allow a little wiggle to this limits, so that sometime black pixels will be shown when a rotation is performed near the border.

Aside from the limits mentioned before, x and y should be positive integer strictly smaller that the input image width and height. The minimum width and height is 1, while the maximum is limited by x, y and image dimensions.

Considerations with Translation Normalization

Translation normalization doesn't make sense when using a rectangle instead of pan and tilt. Because of this, every time a rectangle is set, the translation normalization is turned off. The rectangle parameters (x, y, width and height) always use pixels as unit of measure and they are never normalized.


Previous: Rotate Index Next: Evaluating GstPTZR