2

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

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

# 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 

给定这个输出:

在此处输入图像描述

终端输出:

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 代码中,因为我可以将网络摄像头与 Webcam Chesse 应用程序一起使用。非常感谢任何帮助。非常感谢!

4

1 回答 1

2

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

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

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

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

于 2012-07-19T13:21:55.303 回答