carlos.baez
carlos.baez

Reputation: 1143

Take picture from CameraGLSurfaceView in Android with Opencv

I have implemented the example for apply OpenCL in Android http://docs.opencv.org/trunk/d7/dbd/tutorial_android_ocl_intro.html

It uses a GLSurfaceView and it updates images from the camera in C++. The C++ code uses GL libraries with glReadPixels

My question is, is it possible to take picture (with a photo resolution) with this architecture ? I tried to implement the camera.takePicture and this is my error:

04-28 16:57:18.237   203  9805 E Camera2ClientBase: takePicture: attempt to use a locked camera from a different process (old pid 0, new pid 32146)
--------- beginning of crash
04-28 16:57:18.260 32146 32279 E AndroidRuntime: FATAL EXCEPTION: GLThread 599
04-28 16:57:18.260 32146 32279 E AndroidRuntime: Process: edu.uab.cvc.camera, PID: 32146
04-28 16:57:18.260 32146 32279 E AndroidRuntime: java.lang.RuntimeException: takePicture failed
04-28 16:57:18.260 32146 32279 E AndroidRuntime:    at android.hardware.Camera.native_takePicture(Native Method)
04-28 16:57:18.260 32146 32279 E AndroidRuntime:    at android.hardware.Camera.takePicture(Camera.java:1434)
04-28 16:57:18.260 32146 32279 E AndroidRuntime:    at edu.uab.cvc.camera.MyGLSurfaceView.takePhoto(MyGLSurfaceView.java:165)
04-28 16:57:18.260 32146 32279 E AndroidRuntime:    at edu.uab.cvc.camera.MyGLSurfaceView.onCameraTexture(MyGLSurfaceView.java:139)
04-28 16:57:18.260 32146 32279 E AndroidRuntime:    at org.opencv.android.CameraGLRendererBase.onDrawFrame(CameraGLRendererBase.java:131)
04-28 16:57:18.260 32146 32279 E AndroidRuntime:    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1535)
04-28 16:57:18.260 32146 32279 E AndroidRuntime:    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
04-28 16:57:18.276   779  3430 W ActivityManager:   Force finishing activity edu.uab.cvc.camera/.MainActivity

Upvotes: 0

Views: 1145

Answers (1)

carlos.baez
carlos.baez

Reputation: 1143

Finally, I found the Google example for Camera2. the GLSurfaceView seems an implementation of this project. I compared the two projects and I created the necessary classes to take photo.

Upvotes: 1

Related Questions