Topic has a solution and is locked
Topic locked

Autofocus script problems

August 24, 2021 - 9:16am #1
Topic solved

Hello

I have been having problems getting the camera autofocus script to work. I'm new to this so all help will be appriciated.

the code i used for the script is from the Vuforia website

void Start()

    {

        VuforiaApplication.Instance.OnVuforiaStarted += OnVuforiaStarted;

        VuforiaApplication.Instance.OnVuforiaPaused += OnPaused;

    }

    private void OnVuforiaStarted()

    {

     VuforiaBehaviour.Instance.CameraDevice.SetFocusMode(FocusMode.FOCUS_MODE_CONTINUOUSAUTO);

     VuforiaBehaviour.Instance.CameraDevice.CameraMode = CameraMode.MODE_DEFAULT;

    }

    private void OnPaused(bool paused)

    {

        if (!paused) // Resumed

        {

            // Set again autofocus mode when app is resumed

            VuforiaBehaviour.Instance.CameraDevice.SetFocusMode(

                FocusMode.FOCUS_MODE_CONTINUOUSAUTO);

        }

    }

 

and i get the error

Property or indexer 'CameraDevice.CameraMode' cannot be assigned to -- it is read only

thanks for ur help in advance

Autofocus script problems

August 31, 2021 - 2:10am #3

I wanted to let you know that based on your feedback the outdated documentation was corrected!

 

Kind regards,

Patrick Scheper

Technical Community Manager

Autofocus script problems

August 26, 2021 - 6:14am #2

Hey there,

 

Thank you for reporting! I expect that VuforiaBehaviour.Instance.CameraDevice.CameraMode is only used when you want to check which mode is currently being used. To set the mode, please use:

VuforiaBehaviour.Instance.CameraDevice.SetCameraMode(Vuforia.CameraMode.MODE_DEFAULT);

That should work, let me know.

 

Kind regards,

Patrick Scheper

Technical Community Manager

Topic locked