0

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

Kai Rohmer
  • 147
  • 1
  • 11

2 Answers2

1

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)

Kai Rohmer
  • 147
  • 1
  • 11
0

Did you also include your new SurfaceTexture in the camera2 capture session creation list of target Surfaces, instead of the TextureView's Surface?

Eddy Talvala
  • 17,243
  • 2
  • 42
  • 47
  • Yes, I added it instead of the TextureView's Surface because in the end I don't want the control at all. – Kai Rohmer Jun 25 '16 at 09:33
  • I also get the event in which I dispatch the UpdateTexImage call pushing it in the event queue of the GLSurfaceView... This call is also done.. – Kai Rohmer Jun 25 '16 at 09:42