Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Smile, it’s CameraX! [preview and capture] | Capture - Step 1: create ImageCapture reference
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
You can’t perform that action at this time.