我一直试图获取GL纹理并从中生成SurfaceTexture,并提供给Camera目标端,以便我可以在着色器程序中使用Texture进行渲染。
在Camera2 API之前,我可以看到下面的API。 https://developer.android.com/reference/android/hardware/Camera.html#setPreviewTexture(android.graphics.SurfaceTexture)
我一直在寻找Camera2 API的等效API。有人可以提供提示吗?或者任何替代方法,比如使用TextureView的setSurfaceTexture(SurfaceTexture openGLMappedSurfaceTexture)?
答案 0 :(得分:0)
尝试这样的事情:
SurfaceTexture texture = mTextureView.getSurfaceTexture();
assert texture != null;
// We configure the size of default buffer to be the size of camera preview we want.
texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
// This is the output Surface we need to start preview.
Surface surface = new Surface(texture);
// We set up a CaptureRequest.Builder with the output Surface.
mPreviewRequestBuilder
= mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
mPreviewRequestBuilder.addTarget(surface);
请参阅此示例以获得更好的理解: