Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Autofocus not working on some devices

Discussion in 'Vuforia' started by jariwake, Aug 31, 2018.

  1. jariwake

    jariwake

    Joined:
    Jun 2, 2017
    Posts:
    100
    Hi,

    I noticed that setting the autofocus does not work on some devices, but on some devices it does work. I don't think there is much to do on the Unity side since the SetFocusMode() only returns true or false.
    This makes the application almost unusable on very common devices because image target detection becomes difficult.

    Is this a known issue or a bug?

    Autofocus working:
    • iPhone 7
    • Samsung Galaxy S6
    • Samsung Galaxy S7

    Autofocus not working:
    • Samsung Galaxy S8
    • Samsung Galaxy Note S8
    • Nokia 8
    EDIT: it is actually ARCore beign installed on a device which breaks the autofocus - the version of Vuforia I am using does not support autofocus yet when ARCore is installed (even though ARCore itself has the autofocus support)

    I am using Unity 2018.2.5f1 and Vuforia 7.2.23 with Vuforia Fusion (ARCore 1.4.0 .aar file included in the project)

    My autofocus script looks like this:

    Code (CSharp):
    1. using UnityEngine;
    2. using Vuforia;
    3.  
    4. public class CameraAutofocus : MonoBehaviour
    5. {
    6.     private void Start()
    7.     {
    8.         var vuforia = VuforiaARController.Instance;
    9.         vuforia.RegisterVuforiaStartedCallback(OnVuforiaStarted);
    10.         vuforia.RegisterOnPauseCallback(OnPaused);
    11.     }
    12.  
    13.     private void OnVuforiaStarted()
    14.     {
    15.         SetAutofocus();
    16.     }
    17.  
    18.     private void OnPaused(bool paused)
    19.     {
    20.         if (!paused) // resumed
    21.         {
    22.             // Set autofocus mode again when app is resumed
    23.             SetAutofocus();
    24.         }
    25.     }
    26.  
    27.     public void SetAutofocus()
    28.     {
    29.         bool focusModeSet = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
    30.  
    31.         Debug.Log(focusModeSet ? "Focus mode set to autofocus" : "Failed to set focus mode (unsupported mode)");
    32.     }
    33. }
    I also tried setting the autofocus after 3 second delay, but it didnt work then either.
     
    Last edited: Sep 1, 2018
  2. jariwake

    jariwake

    Joined:
    Jun 2, 2017
    Posts:
    100
    I tried also with a OnePlus 6 which had no ARCore installed. At first the autofocus was successfully set in my app. But after installind ARCore and running my app again the autofocus could not be set anymore. So somehow ARCore breaks the autofocus in Vuforia?

    Edit: It seems that ARCore 1.4 supports autofocus, so it should work in my configuration. But is it so that Vuforia does not yet support autofocus with ARCore?
     
    Last edited: Aug 31, 2018
  3. Vuforia-Strasza

    Vuforia-Strasza

    Official Vuforia Employee Vuforia

    Joined:
    Jun 13, 2017
    Posts:
    548
    ARCore 1.4 does support autofocus, but Vuforia needs to do some work behind the scenes to support this. The next major release will provide this functionality. An announcement will be made on the forums when this version is available.
     
  4. jariwake

    jariwake

    Joined:
    Jun 2, 2017
    Posts:
    100
    Thanks for the reply @Vuforia-Strasza. Is there any rough estimate when the new major release would be out? Is it weeks or months? Or next year?
     
    Last edited: Sep 2, 2018
  5. jariwake

    jariwake

    Joined:
    Jun 2, 2017
    Posts:
    100
    Last edited: Sep 5, 2018
  6. Vuforia-Strasza

    Vuforia-Strasza

    Official Vuforia Employee Vuforia

    Joined:
    Jun 13, 2017
    Posts:
    548
    The current estimate is within the next month or two. We'll make an announcement as soon as there is an official release date.
     
  7. jariwake

    jariwake

    Joined:
    Jun 2, 2017
    Posts:
    100
    Thanks @Vuforia-Strasza.

    I tried to circumvent the problem by calling CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO) when user taps the screen, but that also returns false and does not cause the camera to focus. All other FocusModes also returned false.

    So is it now so, that if ARCore is used, there is no way to focus the camera image? This is a showstopper for us because no ability to focus the camera image even manually makes the whole application unusable.

    Is there any way to directly call some ARCore SDK function to set the focus?
     
    Last edited: Sep 6, 2018
  8. Vuforia-Strasza

    Vuforia-Strasza

    Official Vuforia Employee Vuforia

    Joined:
    Jun 13, 2017
    Posts:
    548
    Unfortunately there is no way to circumvent the issue until the support is added into the next version as the root cause of the issue is ARCore's initial lack of support for auto focus.

    Apologies for the inconvenience.
     
  9. matiasjaure

    matiasjaure

    Joined:
    May 27, 2011
    Posts:
    39
    Any update on this?
     
  10. meedabit

    meedabit

    Official Vuforia Employee Vuforia

    Joined:
    Dec 8, 2016
    Posts:
    266
    Hello @matiasjaure,

    My understanding is that ARCore has added support for continuous autofocus a few releases back.

    Thanks,
    Vuforia Engine Support
     
  11. eon-yogiwp

    eon-yogiwp

    Joined:
    Oct 25, 2018
    Posts:
    2
    @meedabit
    Wondering if continuous autofocus with ARCore has been implemented in latest Vuforia? It wasn't in
    8.3.8, wondering if it's in 8.5.8?
     
  12. mkhlamov

    mkhlamov

    Joined:
    Oct 28, 2015
    Posts:
    1
    Hello, @meedabit.
    Continuous autofocus still not working on neither Android, nor iOS. Unity 2019.3.1f1, Vuforia 8.6.10.
    Any update on this?
     
  13. Sika_MC

    Sika_MC

    Vuforia

    Joined:
    Jul 17, 2019
    Posts:
    96
    Hi @mkhlamov

    Autofocus definetly works on iOS. We had some setbacks with the ARCore Autofocus option. I've tested it with 8.6.10 on a Huawei P20 it works.
    Please make sure that you have ARCore enabled on the device.

    Also you could try the Core Samples apps and check if the Autofocus option works on your device?

    Thank you.
    Vuforia Engine Support
     
    Last edited: Mar 19, 2020