Disabling autofocus in android

This is any way to turn off camera autofocus in my application code. I want to check if my scanner is working if the phone doesn't have auto focus, but in my phone I have this feature.

+3


source to share


2 answers


Use FOCUS_MODE_INFINITY

or FOCUS_MODE_FIXED

. You can also use FOCUS_MODE_MACRO

, but this requires holding the phone very close to the scanned object.

On the other hand, the word "scanner" conjures up thoughts of barcodes and QR codes, so if you're not printing them as a full-size page, you might be better off with FOCUS_MODE_MACRO

.



You can set the desired focus mode Camera.Parameters.setFocusMode()

when you open the camera.

+2


source


you can use mCamera.cancelAutoFocus();

Also, if you want to set a macro or other focus mode, write:



Camera.Parameters mParam = mCamera.getParameters();
mParam.setFocusMode(Camera.Parameters.FOCUS_MODE_MACRO);
mCamera.setParameters(mParam);

      

All focus modes and camera options are available here :

+1


source







All Articles