ioctl VIDIOC_G_SELECTION, VIDIOC_S_SELECTION
&manvol;
VIDIOC_G_SELECTIONVIDIOC_S_SELECTIONGet or set one of the selection rectanglesint ioctlint fdint requeststruct v4l2_selection *argpArgumentsfd&fd;requestVIDIOC_G_SELECTION, VIDIOC_S_SELECTIONargpDescriptionExperimentalThis is an experimental
interface and may change in the future.The ioctls are used to query and configure selection rectangles. To query the cropping (composing) rectangle set
&v4l2-selection;::type to the respective buffer type. Do not
use multiplanar buffers. Use V4L2_BUF_TYPE_VIDEO_CAPTURE
instead of V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
. Use V4L2_BUF_TYPE_VIDEO_OUTPUT instead of
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE . The next step is
setting &v4l2-selection;::target to value
V4L2_SEL_TGT_CROP_ACTIVE (
V4L2_SEL_TGT_COMPOSE_ACTIVE ). Please refer to table or for additional
targets. Fields &v4l2-selection;::flags and
&v4l2-selection;::reserved are ignored and they
must be filled with zeros. The driver fills the rest of the structure or
returns &EINVAL; if incorrect buffer type or target was used. If cropping
(composing) is not supported then the active rectangle is not mutable and it is
always equal to the bounds rectangle. Finally, structure
&v4l2-selection;::r is filled with the current cropping
(composing) coordinates. The coordinates are expressed in driver-dependent
units. The only exception are rectangles for images in raw formats, whose
coordinates are always expressed in pixels. To change the cropping (composing) rectangle set
&v4l2-selection;::type to the respective buffer type. Do not
use multiplanar buffers. Use V4L2_BUF_TYPE_VIDEO_CAPTURE
instead of V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
. Use V4L2_BUF_TYPE_VIDEO_OUTPUT instead of
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE . The next step is
setting &v4l2-selection;::target to value
V4L2_SEL_TGT_CROP_ACTIVE (
V4L2_SEL_TGT_COMPOSE_ACTIVE ). Please refer to table or for additional
targets. Set desired active area into the field
&v4l2-selection;::r . Field
&v4l2-selection;::reserved is ignored and must be filled with
zeros. The driver may adjust the rectangle coordinates. An application may
introduce constraints to control rounding behaviour. Set the field
&v4l2-selection;::flags to one of values:
0 - The driver can adjust the rectangle size freely
and shall choose a crop/compose rectangle as close as possible to the requested
one.V4L2_SEL_FLAG_GE - The driver is not allowed to
shrink the rectangle. The original rectangle must lay inside the adjusted
one.V4L2_SEL_FLAG_LE - The driver is not allowed to
enlarge the rectangle. The adjusted rectangle must lay inside the original
one.V4L2_SEL_FLAG_GE | V4L2_SEL_FLAG_LE - The driver
must choose the size exactly the same as in the requested rectangle.
Please refer to .
The driver may have to adjusts the requested dimensions against hardware
limits and other parts as the pipeline, i.e. the bounds given by the
capture/output window or TV display. The closest possible values of horizontal
and vertical offset and sizes are chosen according to following priority:
Satisfy constraints from &v4l2-selection;::flags.Adjust width, height, left, and top to hardware limits and alignments.Keep center of adjusted rectangle as close as possible to the original one.Keep width and height as close as possible to original ones.Keep horizontal and vertical offset as close as possible to original ones.
On success the field &v4l2-selection;::r contains
the adjusted rectangle. When the parameters are unsuitable the application may
modify the cropping (composing) or image parameters and repeat the cycle until
satisfactory parameters have been negotiated. If constraints flags have to be
violated at then ERANGE is returned. The error indicates that there
exist no rectangle that satisfies the constraints.
Selection targets.
&cs-def;
V4L2_SEL_TGT_CROP_ACTIVE0area that is currently cropped by hardwareV4L2_SEL_TGT_CROP_DEFAULT1suggested cropping rectangle that covers the "whole picture"V4L2_SEL_TGT_CROP_BOUNDS2limits for the cropping rectangleV4L2_SEL_TGT_COMPOSE_ACTIVE256area to which data are composed by hardwareV4L2_SEL_TGT_COMPOSE_DEFAULT257suggested composing rectangle that covers the "whole picture"V4L2_SEL_TGT_COMPOSE_BOUNDS258limits for the composing rectangleV4L2_SEL_TGT_COMPOSE_PADDED259the active area and all padding pixels that are inserted or modified by the hardware
Selection constraint flags
&cs-def;
V4L2_SEL_FLAG_GE0x00000001indicate that adjusted rectangle must contain a rectangle from &v4l2-selection;::rV4L2_SEL_FLAG_LE0x00000002indicate that adjusted rectangle must be inside a rectangle from &v4l2-selection;::r
struct v4l2_selection
&cs-str;
__u32typeType of the buffer (from &v4l2-buf-type;)__u32targetused to select between cropping and composing rectangles __u32flagscontrol over coordinates adjustments, refer to selection flags&v4l2-rect;rselection rectangle__u32reserved[9]Reserved fields for future use
&return-value;
EINVALThe buffer &v4l2-selection;::type
or &v4l2-selection;::target is not supported, or
the &v4l2-selection;::flags are invalid.ERANGEit is not possible to adjust a rectangle
&v4l2-selection;::r that satisfies all contraints from
&v4l2-selection;::flags .EBUSYit is not possible to apply change of selection rectangle at the moment.
Usually because streaming is in progress.