3

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:-

  1. we take focus distance as input from the user in the unit as a centimeter.

  2. 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

  3. 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.

Raymond Chenon
  • 11,482
  • 15
  • 77
  • 110
Vivek Gabadiya
  • 234
  • 2
  • 8
  • Did you find out what the problem was? Maybe you need to cancel previous auto focus, "trigger" the focus request somehow manually or needed to monitor the `CaptureResult.CONTROL_AF_STATE` and possibly lock the focus (should not be necessary)? – hb0 Feb 21 '20 at 09:05

0 Answers0