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.
Asked
Active
Viewed 9,960 times
19

mehrdad khosravi
- 2,228
- 9
- 29
- 34

grasshopper
- 191
- 1
- 4
-
2Before you ask, I'm not working on an Android version any time soon. However, someone did port the basics of it to AS3 a couple of months ago: https://github.com/inspirit/GPUImage . The fragment shaders can come across mostly untouched, but the rest is going to require a complete rewrite for Android's camera and supporting OpenGL ES architecture. Also, it'll need to deal with the much wider variety of device hardware for that platform, where I can make certain assumptions about iOS devices and their PowerVR hardware. – Brad Larson Jul 10 '12 at 23:09
-
1I'm currently experimenting with a quick C++ port of GPUImage which can be found on github here: https://github.com/Dexterp37/GPUImage . At the moment it just allows to use the Grayscale filter by loading from a file and Android (through NDK) support is not in just yet, but I plan to start working on that as soon as possible. – Dexter Sep 13 '12 at 11:54
-
1You may want to read a little into [Renderscript](http://developer.android.com/guide/topics/renderscript/compute.html) before getting started. There are intrinsics for image processing in the API. – eternalmatt Dec 19 '12 at 14:50
-
It seems that android library only work on images (no video)? – haythem souissi Apr 29 '13 at 11:36
2 Answers
9
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:
-
-
-
android-gpuimage also works on live preview so I assume that you can somehow manipulate videos with it, too. – ubuntudroid Jul 02 '13 at 11:11
-
@haythemsouissi Where is the difference of processing images and processing many imges (i.e. video)? You will have to deal with re-encoding the video anyways. – Daniel S. Sep 23 '14 at 09:51
-
-
Kind of... but it was hacky. The company I was working for continued on with it and may be releasing it, but not until it is more mature... – jesses.co.tt Dec 16 '15 at 17:57
0
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.

Shubham
- 535
- 5
- 11
-
-
yes i did it, just change the following in GPUImageNativeLibrary.java class, but it will lag for marshmallow. if you can further something else, please let me know. – Shubham Dec 17 '15 at 04:23