- 1、本文档共12页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
基于V4L2视频驱动开发
1、什么是Video4Linux
Video4linux(简称V4L)是linux中关于视频设备的内核驱动,现在已有Video4linux2,还未加入linux内核,使用需自己下载补丁。在Linux中,视频设备是设备文件,可以像访问普通文件一样对其进行读写,摄像头在/dev/video0下。
2、Video4Linux视频编程的流程
打开视频设备
读取设备的信息
更改设备当前的信息(根据自己需要进行修改)
进行视频信息采集,主要两种方法:a、内存映射
b、直接去设备中读取
对采集的数据进行处理
关闭视频设备
为程序定义的数据结构:
typedef struct v4l2_struct
{
int fd;
struct video_capability capability;? //包含设备的基本信息(设备名称、支持的最大最小分辨率、信号源struct video_channel channel[4];?? //关于各个信号源的属性struct video_picture picture;?? //设备采集的图象的各种属性struct video_window window; //包含关于capture area的信息struct video_capture capture;
struct video_buffer buffer;??????//最底层对buffer的描述struct video_mmap mmap; //内存映射相关操作
struct video_mbuf mbuf;??? //利用mmap进行映射的帧的信息unsigned char *map
int frame;
int framestat[2];
}vd
3、Video4linux支持的数据结构及其用途video_capability :包含设备的基本信息(设备名称、支持的最大最小分辨率、信号源信息等),包含的分量Name[32] // 设备名称
Maxwidth,maxheight,minwidth;
Channels // 信号源信息
Type // 是否能capture,彩色还是白色,是否能裁剪等等。
video_picture : 设备采集的图象的各种属性video_channel? : 关于各个信号源的属性Channel //信号源的编号Name
tuners
Type???? VIDEO_TYPE_TV | IDEO_TYPE_CAMERA
Norm 制式
y //y windows 中的坐标.
width //The width of the image capture.
height // The height of the image capture.
chromakey //A host order RGB32 value for the chroma key.
flags // Additional capture flags.
clips // A list of clipping rectangles. (Set only)
clipcount //The number of clipping rectangles. (Set only)
video_mbuf //利用mmap进行映射的帧的信息
size //每帧大小
Frames //最多支持的帧数
Offsets //每帧相对基址的偏移
video_buffer 最底层对buffer的描述
void *baseBase //physical address of the buffer
int height //Height of the frame buffer
int width //Width of the frame buffer
int depth //Depth of the frame buffer
int bytesperline //Number of bytes of memory between the start of two adjacent lines
实际显示的部分一般比它描述的部分小
video_mmap //用于mmap
关闭视频设备
close(”/dev/video0”,vd-fd);
(2)读video_capability 中信息
ioctl(vd-fd, VIDIOCGCAP, (vd-capability))
成功后可读取vd-capability各分量 eg.
(3)读video_picture中信息
ioctl(vd-fd, VIDIO
文档评论(0)