I'm creating an android app that allow user to scan the code on a small card (like yu gi oh card). The problem is that the number I want to read is really small and it's hard to get a good focus to make it clear. So I wanted to set the params to get the best result at closest distance.
At first, I follow this tutorial to create a simple camera preview: https://inducesmile.com/android/android-camera2-api-example-tutorial/
Next I tried to change the camera preview settings to disable auto-focus, it works well, but then I tried to manually set the focus distance, and nothing change.
This is an extract of the code in the camera preview creation methods :
CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
//Disable auto-focus
captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_OFF);
//Try to make it at the shortest distance (do not work)
captureRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, characteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE)
I've tried different parameters on the focus distance, but nothing change. Maybe I'm just making a mistake, and it's not the right way to improve this.