Created
February 18, 2018 19:51
-
-
Save ashwin-sp/190dc52289d664849a5fb758358d5f56 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
/** | |
* Execute a new capture request within the active session | |
*/ | |
private fun triggerImageCapture() { | |
try { | |
val captureBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE) | |
captureBuilder.addTarget(imageReader.getSurface()) | |
captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON) | |
Log.d(TAG, "Capture request created.") | |
captureSession.capture(captureBuilder.build(), captureCallback, null) | |
} catch (cae: CameraAccessException) { | |
Log.d(TAG, "camera capture exception") | |
} | |
} | |
/** | |
* Callback handling capture session events | |
*/ | |
private val captureCallback = object : CameraCaptureSession.CaptureCallback() { | |
override fun onCaptureProgressed(session: CameraCaptureSession, | |
request: CaptureRequest, | |
partialResult: CaptureResult) { | |
Log.d(TAG, "Partial result") | |
} | |
override fun onCaptureCompleted(session: CameraCaptureSession, | |
request: CaptureRequest, | |
result: TotalCaptureResult) { | |
session.close() | |
captureSession = null | |
Log.d(TAG, "CaptureSession closed") | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment