Converting YUV to RGB

Joined
Mar 9, 2004
Messages
3,322
Hello, I'm posting this in hopes that you guys will be able to figure this out for me as I dont have lot's of free time to do so. I bought a logitech c310 camera and am using the video for linux 2 api to capture images.

Despite being a decent camera the data I'm getting out is 176x144 in V4L2_PIX_FMT_YUYV format. The output from the capture program is a block of 50688 bytes in this format. I've tried a bunch of different conversion formulas, but nothing looks right. I can get a black / white image if I just output one of the color values, which makes me think that I might have the luminance and chrominance backwards.

Code to capture images: http://pastebin.com/Yu1fxgbF
Code to convert images to bmp: http://pastebin.com/qFBM60M5
Sample Image: http://home.swbell.net/aw2001/frame0
 
Last edited:
Have you tried either using ffmpeg to do the conversion or going through its source code to see how they do YUY2 to RGB conversions?
 
Try this. The V is significant, seems that you have v,y,u,y' for two adjacent pixels packed into 4 bytes, and share the v and u components between those two pixels.
 
Back
Top