Hi, I am trying to implement cameraX zoom out feature, My device supports zoom out till 0.6x in device camera, but cameraX allows me to set
zoomRatio(1) only, nothing happens if I set it below 1. Also,
cameraInfo.zoomState.value!!.minZoomRatio always returns 1 in every device.
camera_x_version = '1.1.0-alpha04'
NOTE: Zoom in working fine till cameraInfo.zoomState.value!!.maxZoomRatio
Code to perform zoom
private fun setupZoomAndTapToFocus() {
val listener = object : ScaleGestureDetector.SimpleOnScaleGestureListener() {
override fun onScale(detector: ScaleGestureDetector): Boolean {
currentZoomRatio = cameraInfo.zoomState.value?.zoomRatio ?: 1F
delta = detector.scaleFactor
Log.d(TAG, "delta - curRatio:$delta,$currentZoomRatio")
cameraControl.setZoomRatio(currentZoomRatio * delta)
return true
}
}
val scaleGestureDetector = ScaleGestureDetector(viewFinder?.context, listener)
viewFinder?.setOnTouchListener { _, event ->
scaleGestureDetector.onTouchEvent(event)
if (event.action == MotionEvent.ACTION_DOWN) {
val factory = viewFinder?.meteringPointFactory
val point = factory?.createPoint(event.x, event.y)
val action = FocusMeteringAction.Builder(point!!, FocusMeteringAction.FLAG_AF)
.setAutoCancelDuration(5, TimeUnit.SECONDS)
.build()
cameraControl.startFocusAndMetering(action)
}
true
}
}