Linux V4L2 (webcam) access kinda working.. Help!

BlitzMax Forums/BlitzMax Beginners Area/Linux V4L2 (webcam) access kinda working.. Help!

jondecker76(Posted 2010) [#1]
Hello

It has been several years since I've used BlitzMax. Recently, I wanted to get re-acquainted with the language. I wanted to do some stuff with my webcam on linux. I found an old post where there was indeed a webcam module for linux written, but it was so old it no longer worked (it used the original v4l API)

So far, I have quickly whipped together some code to access 4vl2 devices on a linux system. I am able to open the device and receive images! The problem now lies somewhere in the color pallet. On my webcam (Logitech Quickcam Pro 9000 using the UVC driver), the image is only returned in yuyv format, and of course I need to convert it to RGB. Does anyone have any experience in this type of conversion?



This is my first attempt to import c code into BMX, so please be easy on me :)

thanks all


jondecker76(Posted 2010) [#2]
Maybe some pictures would help....

I will show how the screenshots look using both PF_RGB888 and PF_RGBA8888. Also, I used ClearPixels(255) so that the size of the intended pixmap will be shown colored.


In this first screenshot, i used PF_RGB888 with CreatePixMap()... As you can see, the image kind of repeats over its self a few times, and obviously isn't the correct size...

The returned image seems to be 2/3 the size of the full image. Since the PF_RGB888 is 24 bits, it would seem to indicate that the v4l2 is returning an image that is just 2 bytes per pixel??


in this second screenshot, I used PF_RGBA8888 with CreatePixMap().. As you can see this time, the image shows up repeating again (though not overlapping) in a funky color... Not the correct size either...

The return image seems to be 1/2 the size of the full image. Since the PF_RGBA8888 is 32 bits, it would also seem to indicate that v4l2 is returning an image that is just 2 bytes per pixel. I'm not aware of any pixel format that uses 2 bytes per pixel, so if anyone has any ideas, it would greatly help!



Edit: Thank you to the moderator that edited the post to show me how to include my images!


jondecker76(Posted 2010) [#3]
Nevermind, I finally got it working.
I added a new function in c code to convert from YUYV 4:2:2 to RGB24 into a new buffer, and now its works beautifully!