Autofocus control on camera when using Android vision api's
Asked Answered
D

1

6

I was trying to use Android-vision api's for barcode scanning . Although barcode/QRcode scanning works , but to bring barcode/QRcode in focus you need to move your whole mobile back and forth. There does not look any inbuilt auto-focus mode . CameraSource class which manages native camera does not expose any way to get access to camera object. If auto focus is not performed then user will think that scanning itself is not working.

Also the sample "multi-tracker" app also does not perform any auto-focus.

Is there any way to do auto focus ?

Dagley answered 7/9, 2015 at 11:19 Comment(2)
it looks like there's already a solution posted here #32052473Rosariarosario
Thanks Bidjes for pointing to this.Dagley
H
4

When you create the CameraSource through the Builder, you can pass .setAutoFocusEnabled(true)

mCameraSource = new CameraSource.Builder()
        .setRequestedPreviewSize(640, 480)
        .setFacing(CameraSource.CAMERA_FACING_BACK)
        .setRequestedFps(30.0f)
        .setAutoFocusEnabled(true)
        .build(getApplicationContext(), detector);
Halflife answered 4/1, 2017 at 14:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.