问题
Has anyone ported this to android
yet? More the framework than
the shaders. Stuff like bringing camera data into openGL
.
I have worked with it on iOS
and it is very fast. Any help is much appreciated.
回答1:
GPUImage for Android Idea from: iOS GPUImage framework
Goal is to have something as similar to GPUImage as possible. Vertex and fragment shaders are exactly the same. That way it makes it easier to port filters from GPUImage iOS to Android.
The link is below:
This lib is implemented using Android OpenGL ES 2.0
回答2:
you can use Gpuimage for video preview and take picture also, just compile the jni file in gpuimage library with ndk and put the method for YuvtoRgb convert in GPUImageNativeLibrary.java class in GPUImageLibrary for android.
public static void YUVtoRBGA(byte[] yuv, int width, int height, int[] rgb) {
final int frameSize = width * height;
int r, g, b, y1192, y, i, uvp, u, v;
for (int j = 0, yp = 0; j < height; j++) {
uvp = frameSize + (j >> 1) * width;
u = 0;
v = 0;
for (i = 0; i < width; i++, yp++) {
y = (0xff & ((int) yuv[yp])) - 16;
if (y < 0)
y = 0;
if ((i & 1) == 0) {
v = (0xff & yuv[uvp++]) - 128;
u = (0xff & yuv[uvp++]) - 128;
}
y1192 = 1192 * y;
r = (y1192 + 1634 * v);
g = (y1192 - 833 * v - 400 * u);
b = (y1192 + 2066 * u);
// Java's functions are faster then 'IFs'
r = Math.max(0, Math.min(r, 262143));
g = Math.max(0, Math.min(g, 262143));
b = Math.max(0, Math.min(b, 262143));
rgb[yp] = 0xff000000 | ((r << 6) & 0xff0000)
| ((g >> 2) & 0xff00) | ((b >> 10) & 0xff);
// rgba, divide 2^10 ( >> 10)
/*
* rgb[yp] = 0xff000000 |((r << 14) & 0xff000000) | ((g << 6) &
* 0xff0000) | ((b >> 2) | 0xff00);
*/
}
}
}
replace the method in GPUImageNativeLibrary.java class's public static Native YUVtoRBGA with this, and you have done.
来源:https://stackoverflow.com/questions/11405207/gpuimage-port-for-android