I'm currently using CameraX 1.1.0, my usecase is to take photos of documents and the main goal of my application is to acquire a high quality image determined from the analysis of frames using an Analyzer.
It has come to my attention, that some devices do not produce sharp images when taking the documents, some devices produce images that are very sharp in the center of the image but start to become blurry to the edges of the image. Please see the attached example, you can notice how the edges start to get softer as well as the text around it, while the middle of the image is very sharp.
I want to achieve sharpness on the whole document and I'm looking for recommendations on how to do it and or to point me to the correct APIs that can help me.
The device I'm taking as an example is the Pixel 6, the pictures are taken from the back camera which I select based on custom criteria, for the Pixel 6, this is the data from the camera that is selected:
FOCAL LENGTHS: 6.81
HYPERFOCAL DISTANCE: 0.1923077
MINIMUM FOCUS DISTANCE: 0.19230779.523809
CAPABILITIES: BACKWARD_COMPATIBLE, MANUAL_SENSOR, READ_SENSOR_SETTINGS, MANUAL_POST_PROCESSING, BURST_CAPTURE, UNKNOWN, RAW, CONSTRAINED_HIGH_SPEED_VIDEO, LOGICAL_MULTI_CAMERA
FOCUS MODES: OFF, AUTO, MACRO, CONTINUOUS_VIDEO, CONTINUOUS_PICTURE, EDOF
So far, I've tried changing the focus mode, issuing auto-focus routines regularly at the center of the document, changing the LENS_FOCUS_DISTANCE and LENS_FOCUS_LENGTH using CaptureRequestOptions from Camera2CameraControl but to no avail.
The only thing that has worked so far, is to use CameraControl.setZoomRatio() to 1.5 or 2.x so that I'm forced to get the camera farther away from the document which has a better focus, but the image detail decreases and the exposure of the image changes as well.
- Is there any value I can get from the camera that could indicate that the device would have problems focusing for my use case?
- Is there any API I can use to force the camera to focus correctly?
- Could this be a hardware limitation? I've seen the same issue on other devices like Samsung S21, S22, S23 and the list keeps going.
- Is there a workaround for getting sharp images?
I'd be happy to share more details, thank you very much for your time.