Camerax delay in zoom in and out

Viewed 74

This maybe a weird question but I want to ask. I used CameraX in my application and for zoom in-out functionality, I used this code snippet:

val mListener = object :ScaleGestureDetector.SimpleOnScaleGestureListener() {
        override fun onScale(detector: ScaleGestureDetector?): Boolean {
            val currentZoomRatio = cameraInfo.zoomState.value?.zoomRatio ?: 0F
            val delta = detector!!.scaleFactor
            cameraControl.setZoomRatio(currentZoomRatio *delta)
            return true
        }
    }
    scaleDetector = ScaleGestureDetector(context, mListener)

binding.cameraView.setOnTouchListener() {
scaleDetector.onTouchEvent(event)
return true
}

My question is when I zoom in and out, there is a 0-500 ms delay/latency between user touch and camera zoom in/out. Do you think this is the default behaviour of zoom in-out ?

0 Answers
Related