Skip to content Skip to sidebar Skip to footer

What Is The Equivalent Camera2 Api For Setpreviewtexture() Api?

I have been trying to get the GL Texture and generate a SurfaceTexture from it, and provide to the Camera destination end, so that i can use Texture in the shader program to render

Solution 1:

Try something like this:

SurfaceTexturetexture= 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.Surfacesurface=newSurface(texture);

            // We set up a CaptureRequest.Builder with the output Surface.
            mPreviewRequestBuilder
                    = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
            mPreviewRequestBuilder.addTarget(surface);

Please refer this sample for a better understanding:

https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java

Post a Comment for "What Is The Equivalent Camera2 Api For Setpreviewtexture() Api?"