From android camera api2, we are trying to set LENS_FOCUS_DISTANCE to achieve manual focus functionality in the app. we are doing the following process for this:-
we take focus distance as input from the user in the unit as a centimeter.
Converting centimeter into diopter using formula 100f/(value in centimeter) where f is for converting it to float. This result value we are passing using LENS_FOCUS_DISTANCE
Code in use
final CaptureRequest.Builder captureBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
captureBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, mLensFocusDistance);
We put one Object in 45 cm but it becomes out of focus if we set LENS_FOCUS_DISTANCE to 45 cm, the focus works ok if the object is at 35 cm distance and we setting LENS_FOCUS_DISTANCE as 45 cm.
We are using Pixel2 phone for this experiment. Any help will be highly appreciated.