I am working with the Camera2 API and I am following a tutorial. I have the TextureView set up and I have the SurfaceTextureListener on that TextureView. When the listener is invoked, I use the CameraManager to fetch the camera id I want to use and use the width and height provided to me to set the Preview Size. I also use the CameraManager to open the camera specifying the camera id and the Camera Device State Callback. On the onOpened override method, I invoke a method called startPreview():
private void startPreview() {
SurfaceTexture surfaceTexture = mTextureView.getSurfaceTexture();
surfaceTexture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
Surface previewSurface = new Surface(surfaceTexture);
try {
mCaptureRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
mCaptureRequestBuilder.addTarget(previewSurface);
mCameraDevice.createCaptureSession(Arrays.asList(previewSurface, mImageReader.getSurface()),
new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(CameraCaptureSession session) {
Log.d(TAG, "onConfigured: startPreview");
mPreviewCaptureSession = session;
try {
mPreviewCaptureSession.setRepeatingRequest(mCaptureRequestBuilder.build(),
null, mBackgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
@Override
public void onConfigureFailed(CameraCaptureSession session) {
Log.d(TAG, "onConfigureFailed: startPreview");
}
}, null);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
What is a Capture Request and Capture Session? The Android documentation states createCaptureRequest:
Create a CaptureRequest.Builder for new capture requests
Ok, so what is a CaptureRequest.Builder? The documentation:
A builder for capture requests.
Both definitions reference the others without giving any meaning.