Previous works are handling only single image. Now I consider to apply those shader manipulations on live camera feed in, so that I might achieve a “real-time” filter effect. There is a good example on camera frame mapped to OpenGL texture by Niels Henze. The app can be downloaded from Google Play. However the author just dealt with black-and-white image mapping. To deal with color image really takes much more effort. The main problem to handle in the process is the image format conversion. Since the raw data from the camera is yuv format, rgb format however is required for the gltexture mapping. While pixel manipulation is extremely slow in Java (that’s why we want to use GPU to take the burden off). Here I adopt a piece of native code (from the AndAR project) to perform the yuv to rgb conversion.
Android NDK is required since we need to build lib from native codes. This piece of C++ code below is the conversion from yuv to rgb:
The Android project source code can be pulled from the my github. There are a TextView class I added on, just a test of another app under development of mine. The issue I encountered currently is that texture mapping is not working in my HTC One X with image dimension more than 128x128. So the code might not be working on devices other than Samsung Galaxy S3 (the only device on hand for testing).