概述
涉及V4L2的VIDIOC_G_SELECTION和VIDIOC_S_SELECTION的ioctl的使用。这里仅将做资料记录。
- V4l2 ioctl官方文档
https://01.org/linuxgraphics/gfx-docs/drm/media/uapi/v4l/user-func.html - 该ioctl涉及到的参数为struct v4l2_selection,该结构体可选参数
https://01.org/linuxgraphics/gfx-docs/drm/media/uapi/v4l/selections-common.html#v4l2-selections-common - 具体操作以及例子
https://01.org/linuxgraphics/gfx-docs/drm/media/uapi/v4l/selection-api.html#selection-api
一个例子
数据源960480 --> 1280720
struct v4l2_selection crop;
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
crop.target = V4L2_SEL_TGT_CROP_BOUNDS;//给出了可采样区域的左上角坐标范围、宽度和高度。
ioctl(fd, VIDIOC_G_SELECTION, &crop);
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
crop.target = V4L2_SEL_TGT_CROP; //获取到裁剪区域
crop.r.left = 0;
crop.r.top = 0;
crop.r.width = 960; //源大小
crop.r.height = 480;
ioctl(fd, VIDIOC_S_SELECTION, &crop);
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
crop.target = V4L2_SEL_TGT_COMPOSE; //合成
crop.r.left = 0;
crop.r.top = 0;
crop.r.width = 1280; //目的大小
crop.r.height = 720;
ioctl(fd, VIDIOC_S_SELECTION, &crop);