Any OpenGL coders out there? I want to use my GPU to speed up some video processing, but I know very little opengl. Can you tell me where to focus my research efforts? Here's the application...
I want to perform bilinear
demosaicing using the graphics card. I'm pretty sure my algorithm is suitable, since it's all element-wise multiplication and addition of matrices, the stuff that GPUs are supposedly good at. The algorithm goes something like this:
1) get an image from the camera's buffer and send three copies to video memory
2) multiply each copy element-wise by a pre-computed masks of 1s and 0s, so that each "colour matrix" contains only the values of red, green or blue pixels. All other pixels are 0
3) interpolate the missing colour values by averaging the neighboring pixels. This can be done without iteration by adding cropped copies of the colour matrices (element-wise) then doing scalar division.
4) Create a texture from the interpolated colour matrices.
5) Create a 2d primitive to cover the camera's field of view and map the texture to it.
6) Render to screen.
I think I can do 1 with glpushmatrix, and I can probably figure out 4, 5 and 6 (though it looks more difficult than I thought it would be). 2 and 3 are harder to figure out. Any suggestions?
After an afternoon of reading, I thought I might be able to process each colour (and each cropped copy using gltexsubimage2d) as separate textures, then add/multiply them together with multitexturing. But ye gods that looks complicated. Surely there's an easier way?
posted by Talez at 10:53 PM on June 1, 2008