Created
November 2, 2018 21:27
-
-
Save owahltinez/5ef491de0aba98d0123bf28e369449d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val cameraManager: CameraManager = ... | |
// Get the two output targets from the activity / fragment | |
val surface1 = ... // from SurfaceView | |
val surface2 = ... // from SurfaceView | |
val dualCamera = findShortLongCameraPair(manager)!! | |
val outputTargets = DualCameraOutputs( | |
null, mutableListOf(surface1), mutableListOf(surface2)) | |
// Here we open the logical camera, configure the outputs and create a session | |
createDualCameraSession(manager, dualCamera, targets = outputTargets) { session -> | |
// Create a single request which will have one target for each physical camera | |
// NOTE: Each target will only receive frames from its associated physical camera | |
val requestTemplate = CameraDevice.TEMPLATE_PREVIEW | |
val captureRequest = session.device.createCaptureRequest(requestTemplate).apply { | |
arrayOf(surface1, surface2).forEach { addTarget(it) } | |
}.build() | |
// Set the sticky request for the session and we are done | |
session.setRepeatingRequest(captureRequest, null, null) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment