Created
August 8, 2020 19:04
-
-
Save magdamiu/ae7fb85471da51ad0a1117be399c8977 to your computer and use it in GitHub Desktop.
Smile, it’s CameraX! [preview and capture] | Capture - Step 1: create ImageCapture reference
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 imageCapture = ImageCapture.Builder().build() | |
// SETUP CAPTURE MODE | |
// to optimize photo capture for quality | |
val captureMode = ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY | |
// to optimize photo capture for latency (default) | |
val captureMode = ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY | |
imageCapture = ImageCapture.Builder() | |
.setCaptureMode(captureMode) | |
.build() | |
// SETUP FLASH MODE | |
// flash will always be used when taking a picture | |
val flashMode = ImageCapture.FLASH_MODE_ON | |
// flash will never be used when taking a picture (default) | |
val flashMode = ImageCapture.FLASH_MODE_OFF | |
// flash will be used according to the camera system's determination | |
val flashMode = ImageCapture.FLASH_MODE_AUTO | |
imageCapture = ImageCapture.Builder() | |
.setFlashMode(flashMode) | |
.build() | |
// SETUP ASPECT RATIO | |
// 16:9 standard aspect ratio | |
val aspectRatio = AspectRatio.RATIO_16_9 | |
// 4:3 standard aspect ratio (default) | |
val aspectRatio = AspectRatio.RATIO_4_3 | |
imageCapture = ImageCapture.Builder() | |
.setTargetAspectRatio(aspectRatio) | |
.build() | |
// SETUP TARGET RESOLUTION | |
val metrics = DisplayMetrics().also { previewView.display.getRealMetrics(it) } | |
val screenSize = Size(metrics.widthPixels, metrics.heightPixels) | |
imageCapture = ImageCapture.Builder() | |
.setTargetResolution(screenSize) | |
.setTargetName("CameraConference") | |
.build() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment