I’ve been working on a custom UI for my OpenFlexure microscope! I made it to take advantage of libcamera (the backend of picamera2) and gather raw 10 bit bayer data for some of the computer vision models I’m working on. It’s got a ways to go still, but I thought I’d share my progress so far.
In the image, you might notice a green tint. That’s just some work I have left to do with white balance. Currently the GPU shader I wrote only does bilinear interpolation for demosaicing and needs some additional tooling for color correction.
2 Likes
That’s very interesting. You’re able to offload the demosaicing onto the GPU? Are these GLSL shaders or is this done a different way?
It’s a GLSL shader I wrote. The 10-bit bayer data is packed into an OpenGL texture by using the red and green bits for even rows and the blue and alpha bits for odd rows. I had to do it this way to preserve the last 2 bits of data. Then in the shader they get converted to floats and that’s where you do the demosaicing, white balance, gamma correction, etc, using 32-bit floats instead of 8-bit data. I did it this way because I’m doing some experimentation with very low lighting. I also expose a GLSL shader editor in case there needs to be customizations.