CameraX does not support zoom out below 1

900 views
Skip to first unread message

Anshul Sharma

unread,
Dec 10, 2021, 1:05:13 AM12/10/21
to Android CameraX Discussion Group
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
}
}

Scott Nien

unread,
Dec 10, 2021, 1:12:12 AM12/10/21
to Anshul Sharma, Android CameraX Discussion Group
Hi Anshul, 
To support <1 zoom requires OEM to implement the smooth zoom via CONTROL_ZOOM_RATIO.  Currently, not every device supports that. 


--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/82626c6f-ea48-4e90-a4eb-5c88531f1808n%40android.com.

Anshul Sharma

unread,
Dec 10, 2021, 1:15:55 AM12/10/21
to Android CameraX Discussion Group, Scott Nien, Android CameraX Discussion Group
@Scott Thanks for the quick response.
Can you please explain this 'OEM process' a little more or any document/link explaining this 'OEM process' to have a better understanding.

Scott Nien

unread,
Dec 10, 2021, 4:13:24 AM12/10/21
to Anshul Sharma, Android CameraX Discussion Group
Sure, see the link here for more information. 



Anshul Sharma

unread,
Dec 12, 2021, 3:04:41 AM12/12/21
to Android CameraX Discussion Group, Scott Nien, Android CameraX Discussion Group
Thanks for this useful link. But I want to implement the zoom out feature in all the devices(Below Android 11 also) in which there is zoom out support in device camera. My device Poco x2 supports zoom out till 0.6x but my Camerax does not allow me to zoom out below 1x. Is there any possible solution for that?

Scott Nien

unread,
Dec 12, 2021, 9:55:49 AM12/12/21
to Anshul Sharma, Android CameraX Discussion Group
That's not feasible currently. You might be able to open the camera id of the wide angle camera,  but it would be very difficult to make it smoothly transition from wide angle camera to normal camera. 
So the best you can do is to have an option to switch the lens (normal or wide angle) and zoom works separately on each lens. 
Reply all
Reply to author
Forward
0 new messages