使用 V4L2 捕获网络摄像头流失败

标签 c linux ubuntu-10.04 v4l2

我正在 Ubuntu 10.4 上开始使用 V4L2 框架。

目前我正在使用网络摄像头进行一些测试。我正在关注this文档开始,安装工作正常。我下载并编译了应用程序示例。问题是视频输出,我使用以下方式调用可执行文件:

# modprobe -r pwc
# modprobe -v pwc fps=15 compression=3 mbufs=4 fbufs=4 size=vga
# ./capturer_mmap -D /dev/video0 -w 640*480 -p 0 | ./viewer -w 640*480 -p 0 

给出这个输出:

enter image description here

终端输出:

window size 640*480
Video bytespreline = 1280

Display:
Image byte order = LSBFirst
Bitmap unit      = 32
Bitmap bit order = LSBFirst
Bitmap pad       = 32

Window:
Depth            = 24
Red mask         = 0x00ff0000
Green mask       = 0x0000ff00
Blue mask        = 0x000000ff
Bits per R/G/B   = 8
Image byte order = LSBFirst
Bitmap unit      = 32
Bitmap bit order = LSBFirst
Bitmap pad       = 32
Depth            = 24
Red mask         = 0x00ff0000
Green mask       = 0x0000ff00
Blue mask        = 0x000000ff
Bits per pixel   = 32
Bytes per line   = 2560
IsShared         = True
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
      after 431 requests (19 known processed) with 0 events remaining.
root@my-laptop:/home/foo/V4l2_samples-0.4.1# ./capturer_mmap -D /dev/video0 -w 640*480 -p 0  | ./viewer -w 640*480 -p 0
window size 640*480
Video bytespreline = 1280

Display:
Image byte order = LSBFirst
Bitmap unit      = 32
Bitmap bit order = LSBFirst
Bitmap pad       = 32

Window:
Depth            = 24
Red mask         = 0x00ff0000
Green mask       = 0x0000ff00
Blue mask        = 0x000000ff
Bits per R/G/B   = 8
Image byte order = LSBFirst
Bitmap unit      = 32
Bitmap bit order = LSBFirst
Bitmap pad       = 32
Depth            = 24
Red mask         = 0x00ff0000
Green mask       = 0x0000ff00
Blue mask        = 0x000000ff
Bits per pixel   = 32
Bytes per line   = 2560
IsShared         = True
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
      after 101 requests (19 known processed) with 0 events remaining.

我不知道如何解决这个问题。我相信问题出在 C 代码中,因为我可以将网络摄像头与网络摄像头 Chessel 应用程序一起使用。非常感谢任何帮助。非常感谢!

最佳答案

您似乎以完全错误的格式显示图像。

使用 v4l2 时,您一定要查看“libv4l”(在 debian 中打包,因此在 ubuntu 中也可用)。 v4l2 允许设备以大量视频格式中的任何一种输出其帧,其中一些是压缩的(例如使用 jpeg)。 core v4l2 不提供任何方法将图像转换为您的应用程序支持的给定格式,因此理论上您的应用程序必须支持所有可能的格式。

为了避免代码重复(每个支持 v4l2 的应用程序都面临同样的问题!),创建了 libv4l:它允许对设备进行低级访问,但同时保证可以使用少量访问帧标准格式。 例如如果设备仅支持 jpeg 输出并且您的应用程序请求 RGB32 帧,libv4l 将为您透明地转换。

您甚至可以将 libv4l 与一些 LD_PRELOAD 技巧一起使用,以便使其能够与没有 libv4l 支持的情况下编译的应用程序一起使用(只是为了检查我的建议是否有意义)

关于使用 V4L2 捕获网络摄像头流失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9450257/

相关文章:

vim - gVim 警告是什么以及如何消除它?

c - 为什么-O1比-O2快10000倍?

java - VM初始化时出错;无法为对象堆保留足够的空间;无法创建Java虚拟机

python 脚本不从 cron 运行

python - 在各种操作系统中保存日志时的最佳做法是什么?

linux - Ansible sudo 默认提示

linux - 在 ubuntu 机器上需要 "ls -al/"的结果(最好是 10.4)

c - main函数返回导致异常

c - 将文件描述符的整数值写入文件

c++ - 为什么会出现此错误? void* 不是指向对象类型的指针。