捕获networking摄像头stream与V4L2失败

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

目前我正在使用摄像头做一些testing。 我正在按照这个文档启动,安装工作正常。 我下载并编译了应用程序示例。 问题是video输出,我打电话给可执行文件使用:

# 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 

给出这个输出:

在这里输入图像描述

terminal输出:

 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代码,因为我可以使用networking摄像头Chesse应用程序的摄像头。 任何帮助,非常感激。 非常感谢!

它看起来像是以完全错误的格式显示图像。

当使用v4l2时,你一定要检查“ libv4l ”(在debian中打包,所以也可以在Ubuntu上使用)。 v4l2允许设备以非常大量的视频格式输出帧,其中一些被压缩(例如使用jpeg)。 核心v4l2不提供任何手段将图像转换为您的应用程序支持的给定格式,所以理论上你的应用程序必须支持所有可能的格式。

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

你甚至可以用一些LD_PRELOAD技巧来使用libv4l,以便使它能够在没有libv4l支持的情况下编译的应用程序(只是为了检查我的建议是否合理)