Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autofocus control on camera when using Android vision api's

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 ?

like image 947
Tushar Avatar asked Sep 07 '15 11:09

Tushar


1 Answers

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);
like image 123
Fernando Gallego Avatar answered Oct 03 '22 23:10

Fernando Gallego