I am currently utilizing Camerax in conjunction with TensorFlow Lite for the purpose of detecting identity cards of users, followed by text extraction using MLKit. However, I am encountering two significant challenges outlined below:
Image Blurr Issue: Upon processing frames obtained through Camerax and passing them to TensorFlow Lite for object detection, a prevalent issue arises wherein a considerable portion of the acquired images exhibit blurriness, significantly impacting data reading accuracy through MLKit.
Camera Focus: Despite implementing camera focus functionality within the application code, the camera's continuous frame capturing during the focusing process presents a hurdle. This presents difficulty in distinguishing frames post-focusing, leading to inconsistent results. Below is a snippet of the implemented code for focusing the camera:
In light of these challenges, I am seeking guidance and potential solutions to enhance the image clarity and focus consistency within the Camerax and MLKit integration framework. Any insights or recommendations from the community would be greatly appreciated.
--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/3d80ac20-c5ae-41ad-bd84-4909fe619e1fn%40android.com.
--
ImageAnalysis returns continuous frames while camera focus, when camera focus completed it also returns blurry image then after 2-3 frames it provides correct imageSample Blurr Image:
ImageAnalysis.Builder builder = new ImageAnalysis.Builder();
new Camera2Interop.Extender<>(builder).setSessionCaptureCallback(
new CameraCaptureSession.CaptureCallback() {
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
@NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
super.onCaptureCompleted(session, request, result);
int afState = result.get(TotalCaptureResult.CONTROL_AF_STATE);
long timestamp = result.get(CaptureResult.SENSOR_TIMESTAMP);
}
});
Map<Long, Integer> afStateMap = new HashMap<>();
new Camera2Interop.Extender<>(builder).setSessionCaptureCallback(
new CameraCaptureSession.CaptureCallback() {
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session,
@NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
super.onCaptureCompleted(session, request, result);
int afState = result.get(TotalCaptureResult.CONTROL_AF_STATE);
long timestamp = result.get(CaptureResult.SENSOR_TIMESTAMP);
afStateMap.put(timestamp, afState);
}
});
imageAnalysis.setAnalyzer(Executors.newSingleThreadExecutor(), image -> {
int afState = afStateMap.remove(image.getImageInfo().getTimestamp());
});
Another issue I have observed is that I set autofocus in Camera2Introp but the camera is not focusing I see blurry preview when I tap on screen then it focus because I have used setOnTouchListner() event on previewView
Camera2Interop.Extender ext = new Camera2Interop.Extender<>(builder1);
ext.setCaptureRequestOption(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO)
ext.setCaptureRequestOption(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO)
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/b26ddab0-e571-4655-a3aa-74921834b09dn%40android.com.