googlesamples / android-vision

Deprecated: The Mobile Vision API is now a part of ML Kit: Check out this repo:
https://github.com/firebase/quickstart-android/tree/master/mlkit
Apache License 2.0
2.92k stars 1.73k forks source link

Autofocus does not work #137

Open tmsnvd opened 8 years ago

tmsnvd commented 8 years ago

Hi,

tested barcode example with Asus tablet, still got no autofocus. Actually the same is with any other example. Included default camera app works fine with autofocus. Added more code to check my devise focus modes, it has two:

        if (mFocusMode != null) {
            Log.i("---", "" + Arrays.toString(parameters.getSupportedFocusModes().toArray()));
            if (parameters.getSupportedFocusModes().contains(mFocusMode)) {

                parameters.setFocusMode(parameters.getSupportedFocusModes().get(1));

            } else {
                Log.i(TAG, "Camera focus mode: " + mFocusMode + " is not supported on this device.");
            }
        }

        mFocusMode = parameters.getFocusMode();
        Log.i("+++", mFocusMode);

Log output: I/---: [infinity, auto] I/+++: auto

Any toughts? :(

spere1 commented 7 years ago

Same here. Samsung Tablet Active Tab 2 using Android 4.4.4 with "compile 'com.google.android.gms:play-services-vision:9.6.1'"

Available modes are: auto, infinity, macro and face recognition. None of them allow the device to perform auto focus and recognize small bar codes.

Also, I have tested the Zxing for Android and the focus worked so it is not a hardware issue.

Any possible workaround for it using the vision library?

matteinn commented 7 years ago

Same here on a Samsung S4 running 4.4.2 with the latest Google Play Services 10.0.1

spere1 commented 7 years ago

Finally I am manually triggering the focus every X seconds. It did the trick.

matteinn commented 7 years ago

@spere1 Actually I solved it by looking again at the sample provided by Google. Didn't notice they were using a custom CameraSource implementation and not the one provided by the SDK. I don't know how but it helped

naveeng915213 commented 7 years ago

@matteinn and @spere1 please can you help with code, how we can achieve autofocus in samsung tablet using vision api.. I couldn't able scan the barcode in my tablet

Mauker1 commented 6 years ago

Same thing happens on my Samsung Galaxy Tab A (2016) with Android 5.1.1.

As a workaround, I trigger the focus event when the user taps on the screen (just like in the camera app).

anril commented 5 years ago

Same thing happens on my Samsung Galaxy Tab A (2016) with Android 5.1.1.

As a workaround, I trigger the focus event when the user taps on the screen (just like in the camera app).

You can also use AutoFocusManager for continuous focus mode