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
// Set up use case | |
// Step 1. Config | |
val imageCapture = ImageCapture.Builder().setTargetResolution(Size(600, 800)).build() | |
// Step 2. Bind | |
CameraX.bindToLifecycle(lifecycleOwner, cameraSelector, imageCapture) | |
// Step 3. Act | |
imageCapture.takePicture(…) |
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
fun onTouch(x:Float, y:Float) { | |
val meteringPoint = new DisplayOrientedMeteringPointFactory(mSurfaceView.getDisplay(), cameraSelector, mSurfaceView.getWidth(), mSurfaceView.getHeight()).createPoint(x.y); | |
// Prepare focus action to be triggered. | |
val action = FocusMeteringAction.Builder(meteringPoint).build(); | |
// Execute focus action | |
cameraControl.startFocusAndMetering(action); | |
} |
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 scaleDetector = ScaleGestureDetector(context, listener) | |
override fun onTouchEvent(event: MotionEvent) : Boolean { | |
// Let the ScaleGestureDetector inspect all events | |
scaleDetector.onTouchEvent(event) | |
return true | |
} | |
val listener = object : ScaleGestureDetector.SimpleOnScaleGestureListener() { | |
override fun onScale(detector: ScaleGestureDetector): Boolean { |
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
// Zoom slider: linear zoom effect | |
fun updateZoomSlider(percentage: Float) { | |
// percentage [0.0f .. 1.0f] | |
cameraControl.setLinearZoom(percentage) | |
} |