Log in or register to post comments

Blurry camera image

August 24, 2012 - 2:33am #1

Hi,

 

I have a report from customer who has a Droid 4 running Gingerbread. When she loads my app, her camera becomes blurry/unfocused and it is not detecting/tracking the marker. It is blurry even on the screen as she looks at it.

 

When she puts the phone’s camera in regular mode to take pictures/video, it works fine and the image on her screen is clear.

 

We use default camera settings, i.e. we do not set any focus settings.

Is there a known issue?

 

Thanks,

Paulius

Blurry camera image

April 6, 2021 - 9:16am #17

Works Perfectly! Thanks

Blurry camera image

July 25, 2020 - 5:33am #16

That worked, great!

So, the steps are:

  1. Within Unity, create a new C# script called 'VuforiaFocus' *
  2. Double-click the script to open it and paste all code (see attachment); save it
  3. Back in Unity, select 'ARCamera' in your Hierarchy
  4. Add the script as a new component **

That's it, you're done!

  • *   Assets folder > right-click > Create > C# script
  • ** Inspector panel to the right > Add Component > find and click your script ('VuforiaFocus')

 

I tested this on my physical Samsung Galaxy S10+ and it worked. Thank you @RuhanBello, @syalanurag1991 and @NFGames!

AttachmentSize
Plain text icon VuforiaFocus.txt727 bytes

Blurry camera image

December 6, 2017 - 7:34am #15

@syalanurag1991

Try adding the Vuforia namespace

Blurry camera image

November 16, 2017 - 2:50am #14

Hey I am having the same problem. Where do I add this code??



From the documentation given here:

https://library.vuforia.com/articles/Solution/Working-with-the-Camera#How-To-Use-the-Camera-Projection-Matrix

I created a script that looks like this: 



using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class Focus : 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);

     }

}

}



Now unity is giving an error like this:

error CS0103: The name `VuforiaARController' does not exist in the current context

Blurry camera image

September 15, 2017 - 8:47pm #13

Also, remember that if the mode CONTINUOUSAUTO didn't work, try the other modes too!

Another detail: the method "SetFocusMode" returns a boolean that is FALSE if the mode changing didn't succeeded, so you can debug it to see if the error begins there

Blurry camera image

September 15, 2017 - 8:41pm #12

Hi VirenderSingh!



I was having the same problem here building on my Zuk Z2 phone. I fixed it by adding the following line of code:

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

 

As you can see, the Vuforia framework does have an Singleton implementation for the Camera Device, so you can access it using the Instance field.



The CameraDevice does have a method to set the focus mode, which is "SetFocusMode". It receives an ENUM as a parameter, which is defined in "FocusMode".

 

TAKE CARE: do not add that line of code at the very beginning of the application as it can be dangerous. I was adding that line of code at some Awake() code and it didn't work. Then, I moved it out to some coroutine that waits a little BEFORE executing the code line, and now it works! Camera with focus OK!

Blurry camera image

March 21, 2017 - 3:22am #11

I am facing the same problem. I tried on several devices like Nexus 6p and moto g, but they are always out of focus. Normal camera of phone is very good. Anyone has any solution? 

Blurry camera image

August 30, 2012 - 3:22pm #10

The Continuous auto focus feature is only available starting at API level 9. Enabling this feature sometimes can slow down detection because the camera will be focusing. Setting the focus to Infinity works on this device as well. 

I would try explicitly setting infinity focus or macro focus first to fix the issue for you use case. If this doesn't work try setting continuous focus.

Thank you,

-Peter

Blurry camera image

August 30, 2012 - 2:20pm #9

It looks like you have to set API Level to 9, it's not enough for your device be of Android version 2.3.5

Blurry camera image

August 29, 2012 - 1:37am #8

Are there any disatvantages in enabling continuous auto focus mode? Can I get problems on other devices because of that?

 

Blurry camera image

August 28, 2012 - 10:16am #7

Hi Paulius,

I confirmed on this device that initially the image is out of focus. I also confirmed that setting continuous auto focus works on this device. You can set the camera focus mode to continuous which should work on Gingerbread or later devices if available (It doesn't always work on all devices). 

Thank you,

-Peter

Blurry camera image

August 27, 2012 - 11:39am #6

Hi Paulius,

That is correct. This behavior is slightly different on Android than iOS. iOS focus mode is always set to auto by default I think. On Android, different hardware supports different functionality.

Thanks,

-Peter

Blurry camera image

August 27, 2012 - 10:11am #5

@Peter: is that true - do I need to do that manually? I though device would try to autofocus all the time without my intervetion...

Blurry camera image

August 26, 2012 - 12:39pm #4

I'd recommend using the FocusMode settings on the CameraDevice to engage AutoFocus, either interactively or at intervals if continuous autofocus isn't available. Check out the CameraDeviceMenu script w/ the samples for an example of how to use these modes.

Blurry camera image

August 24, 2012 - 11:43pm #3

Thanks, Peter.

Our marker is relativelly small (10x10cm), so focus point can be relatively close to the camera, but I'm not sure how problematic that is for cameras with dynamic-focus.

Blurry camera image

August 24, 2012 - 3:19pm #2

Hi Paulius,

I will look into this but we haven't had any reported issues before with this device. Thank you for reporting.

Thank you,

-Peter

Log in or register to post comments