PDA

View Full Version : Help displaying frames from a webcam to the screen



stealth86
29th June 2007, 16:52
I'm currently capturing video frames from a webcam using the V4L2 library in linux. The frames are encoded in YUY2 (it has a few other names I can't remember). I want to display some of these frames in a window of some sort.

I don't need full motion video, 5 - 10 fps is more than enough.

My thought was just to paint the buffer to a window, but I have no idea how to go about this in Qt. I also suspect I might need to do a conversion from YUY2 to something like RGB.

I'm doing some reading on my own, but I thought I would post here and see if anyone had some ideas.

marcel
29th June 2007, 18:24
You will need to convert the input frame pixel by pixel from YUV( yes, YUV ), to RGB( meaning you store the pixel data to a QImage or QPixmap ).

Information about conversion formulas you can find here:
http://en.wikipedia.org/wiki/YUY2,
http://www.fourcc.org/fccyvrgb.php, and here
http://www.fourcc.org/fccyvrgb.php.

First you need to initialize the QImage to the dimensions of the frame, Next you just process the frame starting from the first pixel, and set the RGB data at the corresponding location in the QImage.

Regards

stealth86
3rd July 2007, 18:48
You will need to convert the input frame pixel by pixel from YUV( yes, YUV ), to RGB( meaning you store the pixel data to a QImage or QPixmap ).

Information about conversion formulas you can find here:
http://en.wikipedia.org/wiki/YUY2,
http://www.fourcc.org/fccyvrgb.php, and here
http://www.fourcc.org/fccyvrgb.php.

First you need to initialize the QImage to the dimensions of the frame, Next you just process the frame starting from the first pixel, and set the RGB data at the corresponding location in the QImage.

Regards

Are there any libraries that perform the conversion between YUY2 and RGB that I could just link in?

nvm: I just found the libavcodec library.