سؤال

I am getting started with the V4L2 framework on Ubuntu 10.4.

currently I am using an webcam to do some tests. I am following this documentation to start, the installation was worked fine. I downloaded and compiled the application example. The problems is video output,I call the executable using:

# 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 

given this output:

enter image description here

Output on 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.

I have no idea how to fix this. I belive the probrem is in C code because I can to use webcam with Webcam Chesse application. Any help is very appreciated. Thanks a lot!

هل كانت مفيدة؟

المحلول

it looks like you are displaying the image in a completely wrong format.

when working with v4l2, you should definitely check out "libv4l" (packaged in debian, so also available in ubuntu). v4l2 allows a device to output it's frames in any of a very large number of video-formats, some of those are compressed (e.g. using jpeg). core v4l2 does not provide any means to convert the image into a given format your application supports, so in theory your application must support all possible formats.

in order to avoid code duplication (each v4l2-capable application faces the same problem!), libv4l was created: it allows low-level access to the device, but at the sametime guarantees that the frame can be access using a few standard formats. e.g. if the device only supports jpeg-output and your app requests RGB32 frames, libv4l will transparently convert for you.

you can even use libv4l with some LD_PRELOAD tricks, in order to make it work with applications that have been compiled without libv4l-support (just to check whether my suggestion makes sense)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top