2012-02-26 195 views
2

我开始使用Ubuntu 10.4上的V4L2框架。捕获摄像头流与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. 
[email protected]:/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. 

我不知道如何解决这个。我相信probrem是在C代码中,因为我可以使用摄像头Chesse应用程序的摄像头。任何帮助非常感谢。非常感谢!

+0

顺便说一句,有什么问题吗?对于我的回答,我认为你看到的图像并不是你所期望的,但是从你的文章中确实不清楚(例如,当我尝试显示未调节的电视输入时,我看到了类似的图像,这非常合适) – 2012-07-19 13:29:11

回答

2

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

与v4l2一起工作时,你一定要检查出“libv4l”(包装在debian中,所以也可以在Ubuntu上使用)。 v4l2允许设备以非常大量的视频格式输出帧,其中一些被压缩(例如使用jpeg)。 核心v4l2没有提供任何手段将图像转换为您的应用程序支持的给定格式,因此理论上您的应用程序必须支持所有可能的格式。为了避免代码重复(每个具有v4l2功能的应用程序都面临相同的问题!),创建了libv4l:它允许对设备进行低级访问,但同时保证可以使用几种标准格式。 例如如果设备仅支持jpeg-output,并且您的应用请求RGB32帧,则libv4l将为您进行透明转换。

你甚至可以使用libv4l一些LD_PRELOAD技巧,以使其与那些没有libv4l支持编译应用程序的工作(只是为了检查我的建议是否有意义)