14

I want to use the OpenGL ES for the Android camera preview and Save the captured Image.

I like to use the OpenGL ES in Android camera to give some effect to the Android camera. So please anyone tell me how to do it?

Christian Rau
  • 45,360
  • 10
  • 108
  • 185
Android_Developer
  • 481
  • 2
  • 7
  • 15

2 Answers2

7

you need to implement the android.hardware.Camera.PreviewCallback interface and override the method

public synchronized void onPreviewFrame(byte[] data, Camera camera) {
                        myOpenGLObject.receiveFrames(data);
        }

to read the frames received from the camera callback. I suggest you to have a look into the andar source http://code.google.com/p/andar/. Especially the class CameraPreviewHandler.java.

I hope this answers your question.

andreasg
  • 1,070
  • 8
  • 8
1

A faster way is to avoid the onPreviewFrame callback and use SurfaceTexture as the texture to which the camera renders the preview. Have a look at the example inside grafika which more or less does the same : https://github.com/google/grafika/blob/master/src/com/android/grafika/CameraCaptureActivity.java

omerjerk
  • 4,090
  • 5
  • 40
  • 57