Autofocus control on the camera when using Android Vision api's

I tried to use the Android-vision api to scan barcodes. Although scanning a barcode / QR code works, but in order to bring the barcode / QR code into focus, you need to move your entire mobile phone back and forth. There is no built-in auto focus mode. The CameraSource class, which controls the built-in camera, provides no way to access the camera object. If autofocus is not performed, the user will assume that the scan itself is not working.

In addition, the multi-tracker application also does not perform any auto focus.

Is there a way to do autofocus?

+4
source share
1 answer

When you create CameraSourcethrough Builder, you can transfer.setAutoFocusEnabled(true)

mCameraSource = new CameraSource.Builder()
        .setRequestedPreviewSize(640, 480)
        .setFacing(CameraSource.CAMERA_FACING_BACK)
        .setRequestedFps(30.0f)
        .setAutoFocusEnabled(true)
        .build(getApplicationContext(), detector);
+1
source

Source: https://habr.com/ru/post/1606247/


All Articles