Faster camera viewing with OpenGL?

Writing an application that takes preview frames from the camera does some conversion to it, and then displays it on the screen.

in

public void onPreviewFrame(byte[] data, Camera camera) {} 

I am taking the yv2rgb do data and some pixel manipulation in JNI in another thread. Then I create a bitmap from an RGB int array and draw it using

 canvas.drawBitmap(bmp, 0, 0, null); 

I get about 15-20FPS on HTC Nexus One at 640x480 and 30+ FPS on Samsung Galaxy S II

I am wondering if I can speed things up with Android OpenGL ES? I will follow this guide: http://obviam.net/index.php/texture-mapping-opengl-android-displaying-images-using-opengl-and-squares/

+4
source share
2 answers

OpenGL ES is implemented and it helps with performance.

+2
source

Are you using SurfaceView for your camera app? The preview frame you receive is a copy of the actual frame that is displayed on the screen. I assume you added another view to display callback preview frames.

I'm not a graphic guy, but why don't you try SurfaceTexture . You can use setpreviewtexture () instead of setpreviewwindow (). Thus, the Camera Service will send buffers directly to the application, instead of making a copy, and also placing it in AndroidNativeWindow. It can improve your performance.

Here's how the Panorama app for Android works. You can find the source code here.

+4
source

All Articles