Examples
(A video capture device is assumed; change V4L2_BUF_TYPE_VIDEO_CAPTURE for other devices; change target to V4L2_SEL_TGT_COMPOSE_* family to configure composing area)
Example: Resetting the cropping parameters #
struct v4l2_selection sel = ;
ret = ;
if
;
sel.target = V4L2_SEL_TGT_CROP;
ret = ;
if
;
Setting a composing area on output of size of at most half of limit placed at a center of a display.
Example: Simple downscaling #
struct v4l2_selection sel = ;
struct v4l2_rect r;
ret = ;
if
;
/* setting smaller compose rectangle */
r.width = sel.r.width / 2;
r.height = sel.r.height / 2;
r.left = sel.r.width / 4;
r.top = sel.r.height / 4;
sel.r = r;
sel.target = V4L2_SEL_TGT_COMPOSE;
sel.flags = V4L2_SEL_FLAG_LE;
ret = ;
if
;
A video output device is assumed; change V4L2_BUF_TYPE_VIDEO_OUTPUT for other devices
Example: Querying for scaling factors #
struct v4l2_selection compose = ;
struct v4l2_selection crop = ;
double hscale, vscale;
ret = ;
if
;
ret = ;
if
;
/* computing scaling factors */
hscale = compose.r.width / crop.r.width;
vscale = compose.r.height / crop.r.height;