I am not able to set a particular focus distance. I have a few sub question here
- how to manually set the focus distance?
I have tried the following code
val characteristics: CameraCharacteristics =
manager!!.getCameraCharacteristics (mCameraDevice!!.id)
var afAvailableAeModes = characteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE)
Log.d(TAG,"AF mode : "+afAvailableAeModes.toString())//a
var focusDistance = characteristics.get(CameraCharacteristics.LENS_INFO_FOCUS_DISTANCE_CALIBRATION)
Log.d(TAG,"Focus Distance Original "+focusDistance.toString())//b
mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE,CaptureRequest.FLASH_MODE_TORCH)
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,CaptureRequest.CONTROL_AE_MODE_ON)
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
mPreviewRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, 30f);
mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(),null,null)
focusDistance = characteristics.get(CameraCharacteristics.LENS_INFO_FOCUS_DISTANCE_CALIBRATION)
Log.d(TAG,"Focus Distance after set "+focusDistance.toString())//c
afAvailableAeModes = characteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE)
Log.d(TAG,"Focus Distance After Change "+afAvailableAeModes.toString())//d
After seeing the log, I have these: a. AF Mode : 10.0 b. Focus Distance Original 2 c. Focus Distance after set 2 d. Focus Distance After Change 10.0 as can be seen, nothing is changed, BUT the FLASH mode changed to TORCH. so I think the setting is changed, but I am not able to change the right parameters, in this case is focus distance.
how to check if the focus distance is set? if the focus distance is changed, please provide the code to confirm the changes
what is the unit of focus distance, is it cm or 100f/(focus_distance) ? As can be seen that the default LENS_INFO_MINIMUM_FOCUS_DISTANCE is 10.0. What is the unit? cm? or the number is coming from a formula, like 100f/(focus_distance)?
I hope that my questions are clear. I tried many answer like :