I'm trying to get the camera stream of the "new camera framework" Camera2 into a OpenGL Texture but image stays black.
I'm working with Xamarin (but Java should be very similar) and I'm using the NDK for native rendering.. So I got a GLSurfaceView that created the OpenGL-ES context and I'm able to render stuff from C++.
No checked out the following sample: https://github.com/googlesamples/android-Camera2Basic and from there I would like go on.
instead of adding the TextureView's SurfaceTexture as target to the CaptureRequestBuilder I created a new SurfaceTexture with a new texture handle.
// C++
glActiveTexture(GL_TEXTURE0);
glGenTextures(1, &m_TextureHandle);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, m_TextureHandle);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
// C# (or Java)
_SurfaceTexture = new SurfaceTexture(m_TextureHandle);
_SurfaceTexture.FrameAvailable += SurfaceTextureOnFrameAvailable;
The last line registers for the incoming frames. Here I just dispatched to to my rendering thread and called:
_SurfaceTexture.UpdateTexImage();
Am I missing an important step? I also tried to use the deprecated camera api with the same result.
Thanks Kai
Found the problem.. It was caused by invalid OpenGL parameter :/ While searching for the problem I created a small sample. I uploaded in case somebody is interested: SampleCode (OneDrive)