Log in or register to post comments

Camera Focus mode - Android - Unity

March 4, 2016 - 9:20pm #1

Hi, good night to everyone!
Im really new in all this Vuforia and RA thing, im using the SDK in Unity, gave my best and made my first basic app that shows a model with animation (yay!)
But im having some bad time with the focus of the camera, saw some scripts here but when i try to create a C# file to fit in the prefabs of the SDK im having no luck. 
Does someone have already made the focus work with the SDK in Unity?
Thanks a lot !
Have a good night!

PS: Im reaaaaaaaaally new in all of this, so please be gentle.
Thanks again!

Camera Focus mode - Android - Unity

October 9, 2018 - 12:29pm #44

Unbelievable. It just worked.

Thanks a bunch. Grazie mille.

Camera Focus mode - Android - Unity

July 24, 2018 - 11:48am #43

Hello @blawson75,

@DanielRubins is correct in that ARCore does not currently support continuous auto-focus. This was an issue similar to ARKit when it was first released, so our expectation is that ARCore will eventually support it.

Note that Vuforia Fusion will attempt to select the best provider (ARKit, ARCore) depending upon the device. I don't see where the LG V10 is listed on ARCore supported devices. Check logging as Vuforia messages should indicated if ARCore is being used or not - you can also use our new currentFusionProvider() API to do the same.

Regardless, Vuforia only calls native OEM APIs to control the camera. Thus, if an OEMs autofocus implementation for a device is not performant, Vuforia will exhibit the same behavior.

Thanks,

Vuforia Engine Support

Camera Focus mode - Android - Unity

July 24, 2018 - 7:30am #42

If you're using vuforia 7.2.2+ with Vuforia Fusion and you've got ARCore activated with it, this may cause a problem as ARCore has no camera focus functionality built in yet. At least that's the problem I've had recently.

Not working for me

July 24, 2018 - 7:12am #41

Still not working for me.  Using Unity 2018.1.9f1 Personal ... Vuforia Engine v7.2.23 .. LG V10 ... Android 6.0

Camera never focuses on anything in the app. 

Camera Focus mode - Android - Unity

June 28, 2018 - 7:20pm #40

To this day still a magical fix... THANK YOU!

Camera Focus mode - Android - Unity

February 21, 2018 - 4:04pm #39

Thank you so much, thats work for me :D

Camera Focus mode - Android - Unity

February 21, 2018 - 4:04pm #38

Thank you so much, thats work for me :D

Camera Focus mode - Android - Unity

January 22, 2018 - 9:14am #37

I know this is a old post, but since I'm having same issues, I will leave here a important topic.

Don't forget to put:

Using Vuforia;

at the begining of your code.

Camera Focus mode - Android - Unity

December 19, 2017 - 4:22am #36

i got error . i'm using unity 5.4.1

AttachmentSize
Image icon Untitled.png15.71 KB

Camera Focus mode - Android - Unity

November 30, 2017 - 4:11pm #35

Hi there!

 

How this is supposed to work on Vuforia 2017.2?

I drag the script to ARCamera and its not working.

Thanks,

Fábio

Camera Focus mode - Android - Unity

November 21, 2017 - 9:24am #34

Perfect ! Merci !!

(focus for an app, on tablette lenovo 3, works perfectly after build)

Camera Focus mode - Android - Unity

October 1, 2017 - 8:54am #33

Many thanks- this was a really simple fix to my first Vuforia build via Unity to Android. Thanks again.

Camera Focus mode - Android - Unity

September 27, 2017 - 2:09pm #32

This did it for me, many thanks!

Camera Focus mode - Android - Unity

September 25, 2017 - 11:08pm #31

HI Guys

This is reply to my previous post.

 

(Yes. Camera Focus mode not working in Unity 2017.1.1f1. Camera is not focusing on night time. Works fine in day light.

Anybody resolved the problem let us know.)

 

In Unity 2017.1.1f1 also the script is working. We need to drag the script to AR Camera => Camera in Hierarchy. Then it will focus. ( Earlier I forgot to do that).

 

I have attached the image file for your reference.

 

 

AttachmentSize
Image icon camfous.JPG73.11 KB

Camera Focus mode - Android - Unity

September 25, 2017 - 10:10pm #30

Yes. Camera Focus mode not working in Unity 2017.1.1f1. Camera is not focusing on night time. Works fine in day light.

Anybody resolved the problem let us know.

Camera Focus mode - Android - Unity

September 25, 2017 - 12:25pm #29

The focus script seems to not work in 2017.1.1f1.

Had it work once, stopped App (samsung S7) re-launched and  focus stopped. Any suggestions?

Camera Focus mode - Android - Unity

August 30, 2017 - 2:01am #28

Thank you!

Camera Focus mode - Android - Unity

August 24, 2017 - 2:57am #27

Many thanks

good job!

Camera Focus mode - Android - Unity

August 24, 2017 - 2:56am #26

Many thanks, its worked well!

two thumbs

regard

 

Camera Focus mode - Android - Unity

August 2, 2017 - 2:11am #25

The script from "CameraFocusController.zip" seems to work well and tested on Unity5.6.

 

Thank you for sharing the workable solution. Cheers! 

Camera Focus mode - Android - Unity

July 19, 2017 - 8:25pm #24

Gracias, funciono perfecto :D

Camera Focus mode - Android - Unity

June 16, 2017 - 2:59am #23

SHAAANKYUUUUUUUUU

Camera Focus mode - Android - Unity

June 13, 2017 - 8:27pm #22

Thankyou, its work for me . thankyou thankyou.

Camera Focus mode - Android - Unity

May 17, 2017 - 11:21am #21

Hi Priyamdey. 

You saved my time, thanks a lot dude.

Camera Focus mode - Android - Unity

March 2, 2017 - 6:42am #20

Hi!

If it still not working make sure that under Vuforia Configuration, the Camera Device Mode is set to MODE_DEFAULT.

For us only this solved the problem! :)

Regards,

evoAR

Camera Focus mode - Android - Unity

February 13, 2017 - 5:22am #19

Thanks! You saved the day!!

Camera Focus mode - Android - Unity

February 2, 2017 - 8:19pm #18

Funciona perfecto GRACIAS!!!

Ojala pues en las próximás  versiones no se les olvide colocar este simple scrip 

Camera Focus mode - Android - Unity

January 24, 2017 - 2:37am #17

Okay. So, I have my Unity version as 5.4.1 (Personal Edition), Vuforia version as 6.2.6. Attach the "CameraFocusController.cs" script (in the zip file) to ARCamera. Now it will be able to autofocus.

 

AttachmentSize
Package icon CameraFocusController.zip726 bytes

Camera Focus mode - Android - Unity

January 19, 2017 - 3:02am #16

Please write the code entirely autofocus

I have no such this lines

(((

Camera Focus mode - Android - Unity

January 16, 2017 - 2:45am #15

Guys, read the updates from Vuforia for the changes made to Vuforia 6.2 (Including the RegisterVuforiaStartedCallback problem).

https://library.vuforia.com/articles/Training/Changes-to-the-Unity-ARCamera-with-Vuforia-6-2

https://library.vuforia.com/articles/Solution/Migrating-Unity-Projects-to-Vuforia-6-2

 

You just need to change one line in the script provided by mrduncan - 

Change this line - 

VuforiaBehaviour vuforia = (VuforiaBehaviour)FindObjectOfType(typeof(VuforiaBehaviour));

to this line -

VuforiaARController vuforia = VuforiaARController.Instance;

and I think it will work properly.

Thanks

Camera Focus mode - Android - Unity

January 15, 2017 - 5:34am #14

me too too

Camera Focus mode - Android - Unity

January 13, 2017 - 9:51pm #13

me too :(

Camera Focus mode - Android - Unity

January 11, 2017 - 10:47am #12

I updated Vuforia to the last version.. and it happend to me too...

Camera Focus mode - Android - Unity

January 5, 2017 - 1:40am #11

Hello everyone,

after changing to Vuforia Video Playback, the CameraFocusController.cs is not working anymore.

Ihave an error message here, in code line cs:(14,21):

 vuforia.RegisterVuforiaStartedCallback(StartAfterVuforia);

This is the error message:

Assets/Scripts/CameraFocusController.cs(14,21): error CS1061: Type `Vuforia.VuforiaBehaviour' does not contain a definition for `RegisterVuforiaStartedCallback' and no extension method `RegisterVuforiaStartedCallback' of type `Vuforia.VuforiaBehaviour' could be found (are you missing a using directive or an assembly reference?)

 

Does anyone already solved this problem?

thank you in advance.

Cheers

Camera Focus mode - Android - Unity

November 27, 2016 - 6:19pm #10

You're fantastic KaranGoel! Perfect, easy to follow instructions. Worked like a charm.

Camera Focus mode - Android - Unity

November 2, 2016 - 2:41pm #9

Hello everyone.

Since I had a similar problem, and since that problem has been solved by following the instructions mentioned in the previous comments, I would like to thank the people.

In addition, I would like to add the step by step process to do it for people still trying to figure it out.

1. I am supposing that you are making a basic AR App using Vuforia in Unity.

2. I am supposing that you have already followed all the basic steps to make a normal AR App (with the focusing problem).

3. Select ARCamera. On selecting it, you can see the Inspector Window (probably on the right side).

4. Go to the extreme bottom. There is a "Add Component" button. Press it.

5. Go to the extreme bottom of the new Window that opened after you pressed Add Component. There will be a "New Script" option. Click it.

5. Then add a file by the name "CameraFocusController".

6. A new tab appears in the Inspector Window. Edit the script in the new tab.

7. Code is provided in the attachment that you can find in the comment by mrduncan(probably) in the same post.

Camera Focus mode - Android - Unity

October 18, 2016 - 1:28am #8

Did it work? I have been using a very very similar script for my app in Vuforia 6, but it doesn't work once the app has been paused and resumed - the camera just goes blurry until you restart the app

Camera Focus mode - Android - Unity

October 17, 2016 - 2:46am #7

Thank you very much for this! Super helpful :)

Camera Focus mode - Android - Unity

September 4, 2016 - 9:26am #6

Ideally you want to wait for Vuforia to finish initializing before sending it calls. In many cases it won't matter, but as you build up your code in a complex project...eventually you'll get a timing issue.

I've attached the completed file. You just need to attach it, to anything. 

AttachmentSize
Package icon CameraFocusController.zip776 bytes

Camera Focus mode - Android - Unity

September 3, 2016 - 4:42pm #5

Hi There, 

"

Put this in your ARCamera script, in the Start function :

bool focusModeSet = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);

if (!focusModeSet)

{

Debug.Log ("Failed to set focus mode to continusauto (unsupported mode).");

"

For clarity, which ARCamera script are you referring to?  

Camera Focus mode - Android - Unity

March 9, 2016 - 1:06am #4

Hello.

Put this in your ARCamera script, in the Start function : 
 

bool focusModeSet = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
if (!focusModeSet) 
{
Debug.Log ("Failed to set focus mode to continusauto (unsupported mode).");
}
 
The only error I could possibly imagine you could get is that the CameraDevice class isn't recognized. That would mean you simply have to add "using Vuforia;"  (equivalent of importing a package in Java, if you are better versed in Java :) ) on the first lines of your script.

Camera Focus mode - Android - Unity

March 8, 2016 - 7:22pm #3

Hello!
Thanks a lot for the help!
I maybe gonna need a little bit more of help, I try to create a C# Script to put that info, and then attach to the ArCamera in the Unity proyect. 
But when i try to create the script i got tons of erros that i dont really know how to solve ( im doing all this via tutorials, i almost know nothing of C#) 
Maybe if you could be a little more specific , again , thanks a lot for take the time to help me and answer me, and sorry for my little knowledge!

Camera Focus mode - Android - Unity

March 7, 2016 - 8:41pm #2

CameraDevice myCam = CameraDevice.Instance;

myCam.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);

 

Hope it helps !!

Log in or register to post comments