Created
October 24, 2018 17:41
-
-
Save itome/f4ec07e924be2b038b4f300acffa1022 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
private var captureSession: CameraCaptureSession? = null | |
private fun createCameraPreviewSession() { | |
if (cameraDevice == null) { | |
return | |
} | |
val texture = textureView.surfaceTexture | |
texture.setDefaultBufferSize(640, 480) | |
val surface = Surface(texture) | |
val previewRequestBuilder = cameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW) | |
previewRequestBuilder.addTarget(surface) | |
cameraDevice?.createCaptureSession(listOf(surface), object : CameraCaptureSession.StateCallback() { | |
override fun onConfigured(session: CameraCaptureSession) { | |
captureSession = session | |
captureSession?.setRepeatingRequest(previewRequestBuilder.build(), null, null) | |
} | |
override fun onConfigureFailed(session: CameraCaptureSession) {} | |
}, null) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment