Instantly share code, notes, and snippets.

Embed
What would you like to do?
val session: CameraCaptureSession = ... // from CameraCaptureSession.StateCallback
// We will be using the preview capture template for the combined streams, because
// it is optimized for low latency; for high-quality images use
// TEMPLATE_STILL_CAPTURE and for a steady frame rate use
// TEMPLATE_RECORD
val requestTemplate = CameraDevice.TEMPLATE_PREVIEW
val combinedRequest = session.device.createCaptureRequest(requestTemplate)
// Link the Surface targets with the combined request
combinedRequest.addTarget(previewSurface)
combinedRequest.addTarget(imReaderSurface)
// In our simple case the SurfaceView gets updated automatically. ImageReader
// has its own callback that we have to listen to in order to retrieve the frames
// so there is no need to set up a callback for the capture request
session.setRepeatingRequest(combinedRequest.build(), null, null)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment