Show a frame from USB camera to Framebuffer

azzido
Hello friends,

I'm trying to get a frame from USB camera and to display it on NEC LCD 3.5"
using Framebuffer. I know the framebuffer can store an image in RGB565
format but how can I read data from /dev/video0 to put in /dev/fb0 ? Using
V4L to read data from /dev/video0 in RGB565 format can help me ?

Thanks.

Vladimir Fonov
Hello,

it really depends on the kind of USB camera that you have. If it is an UVC
type, most likely it will support capturing in YUV and/or MJPG mode. You
will have to convert the frames from this format to RGB565

azzido
Hi

I think my USB camera is UVC, it has Vimicro chip and it's recognized by
GSPA linux driver when is plugged in. Camera works great with the "USB
Camera" application comes as default in qtopia 2.2.0.

The frame stored in /dev/video0 has YUV422P format ? and What is the
resolution ?

I tried to read /dev/video0 using v4l2. I set the pixel format to
V4L2_PIX_FMT_RGB565 and after this to V4L2_PIX_FMT_YUV422P. I realized that
the pixel format was changed to V4L2_PIX_FMT_YUV422P after I have called
ioctl(...) function. I think the camera doesn't support V4L2_PIX_FMT_RGB565
or V4L2_PIX_FMT_YUV422P format. What do you think ?

Using OpenCV I can process the frame without any problem, but again I can't
access data in RGB565.

Thanks so much !

Vladimir Fonov
Hello,

that's not how it works, unfortunately. 
Usually UVC cameras supports  V4L2_PIX_FMT_YUYV format. Even if you specify
something else using VIDIOC_S_FMT ioctl, your program should check the
return value  - showing what format driver is actually going to use.
Resolution depends on the camera, you can use VIDIOC_ENUM_FRAMESIZES ioctl
to see what's available.

azzido
Hi,

I tried to retrieve all formats supported by USB camera using the attached
source code based on VIDIOC_ENUM_FMT. This is the output:

[root@FriendlyARM /home]# ./v4l2-formats /dev/video0
/dev/video0 is a V4L2 device named 'PC Camera'
/dev/video0 is capable of video capture
/dev/video0 is capable of streaming capture
/dev/video0 supports 'JPEG' (compressed format, V4L2_PIX_FMT_JPEG)

It seems to support only JPEG format.

Thanks

azzido
Attachment: v4l2-formats.c (5.73 KB)
I forget to attach the source code.

unknowN
Hi,

how can i install my usb camera? This is a SPC900NC

Thanks