Linux v4l2 非常简单的例子

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4009439/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 23:46:20  来源:igfitidea点击:

v4l2 very simple example

c++clinuxv4l2v4l

提问by Alex Ivasyuv

I'm looking for a simpleexample for camera access in Linux using V4L2. Where I can find it? As simple, as possible.

我正在寻找一个使用 V4L2 在 Linux 中访问相机的简单示例。我在哪里可以找到它?尽可能简单。

Thanks,

谢谢,

回答by shodanex

In the API specification, there is an example, also downloadable as a C file

在 API 规范中,有一个示例,也可以作为C 文件下载

回答by Raulp

Try the uvccapture code here -> http://staticwave.ca/source/uvccapture/It is very small yet very concreteexample which makes use of all the V4l2 concepts (open,set format, allocate memory, Request Buffer, Dqbuffer and Query-buffer - all intems of ioclts).

在这里尝试 uvccapture 代码 -> http://staticwave.ca/source/uvccapture/这是一个非常小但非常具体的示例,它利用了所有 V4l2 概念(打开、设置格式、分配内存、请求缓冲区、Dqbuffer 和查询-buffer - ioclt 的所有项目)。

uvcgrab() function is the one to look for which makes use of Dqbuffer and Query-buffer.

uvcgrab() 函数是查找使用Dqbuffer 和Query-buffer 的函数。

ioctl (vd->fd, VIDIOC_DQBUF, &vd->buf);

ioctl (vd->fd, VIDIOC_QBUF, &vd->buf)

While Studying it you can keep looking for the ioctl definition in this linkwhich will ease your understanding.

在学习它时,您可以继续在此链接中查找 ioctl 定义,这将有助于您的理解。

回答by ekmungi

I would advice also trying out v4l-utils.

我建议也尝试 v4l-utils。

http://linuxtv.org/downloads/v4l-utils/

http://linuxtv.org/downloads/v4l-utils/

It has some easy to use API calls to v4l devices and there is a qt based example in the source to build a custom interface for video devices.

它有一些易于使用的对 v4l 设备的 API 调用,并且源中有一个基于 qt 的示例,用于为视频设备构建自定义界面。