Topic locked

Blurry camera on Android (no tracking)

August 27, 2021 - 12:25pm #1

Hi, I have a problem with vuforia package in unity. After exporting the apk and installing on my phone (Xiaomi MI9) the camera image is very blurry and can't recognize the objects. Everything works well in unity and on a different Android phone. I found a solution on Vuforia developer forum (code below) but it doesn't work for me.

 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Vuforia;

public class VuforiaFocus : MonoBehaviour {

// Use this for initialization

void Start () {

  var vuforia = VuforiaARController.Instance;

  vuforia.RegisterVuforiaStartedCallback(OnVuforiaStarted);

  vuforia.RegisterOnPauseCallback(OnPaused);

}

private void OnVuforiaStarted(){

  CameraDevice.Instance.SetFocusMode(

  CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);

}

private void OnPaused(bool paused){

   if (!paused) // resumed

   {

    // Set again autofocus mode when app is resumed

    CameraDevice.Instance.SetFocusMode(

    CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);

   }

}

}

I paste the code as instructed but get two errors:

"CS0120: An object reference is required for the non-static field, method, or property 'CameraDevice.FocusMode'"

"CS0176: Member 'FocusMode.FOCUS_MODE_CONTINUOUSAUTO' cannot be accessed with an instance reference; qualify it with a type name instead"

This keeps it from compiling and crashes the app, I'm working in Unity 2020.3.16f1 version. I'd be grateful if anyone can help.

Blurry camera on Android (no tracking)

August 30, 2021 - 6:17am #2

Hey there,

 

CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO does not work anymore for v10.x. It moved to FocusMode.FOCUS_MODE_CONTINUOUSAUTO.  If you're using v10.x and code from another version, I'd recommend going through the migration guide since the API has been changed quite a bit.

Here's the official documentation how to access the camera focus mode.

 

Kind regards,

Patrick Scheper

Technical Community Manager

Topic locked