I am using Unity 5 with Vuforia. I have a business card rated 4 stars by the Target Manager. In the editor using my Webcam the program recognizes the card quickly and easily. When I compile for android and run it does not recognize no matter how close or far it is from the camera. If it is smart enough to recognize objects why isn't it smart enough to focus on this card???
- Sort Posts
- 8 replies
- Last post
Android Camera starts out of focus
Android Camera starts out of focus
What Android Phone are you using? I am having the same focus issues on the Samsung s7. the focus sets once the app is launched, it will re-set if a pause app and point it at a new object and start it up (using the script posted here in the forms) I can not get auto focus to work on the s7, I am going to do a iOS build and see if it works there, and will let you know how that goes.
Android Camera starts out of focus
I have utilised another script (very similar to that one) but it doesn't give me any errors. However, it doesn't seem to be willing to restart if the app comes from sleep mode, but its a start.
</p> <p>private bool mVuforiaStarted = false;</p> <p>// Use this for initialization<br> void Start ()<br> {<br> VuforiaBehaviour qcar = (VuforiaBehaviour)FindObjectOfType(typeof(VuforiaBehaviour));<br> qcar.RegisterVuforiaStartedCallback(OnVuforiaStarted);<br> }</p> <p>private void OnVuforiaStarted()<br> {<br> Debug.Log(" OnVuforiaStarted ");<br> mVuforiaStarted = true;<br> SetAutofocus();<br> }</p> <p>void OnApplicationPause(bool pause)<br> {<br> if (!pause)<br> {<br> // App resumed<br> Debug.Log("App resumed");<br> if (mVuforiaStarted)<br> {<br> // App resumed, and Vuforia already started previously<br> SetAutofocus();<br> }<br> }<br> }</p> <p>private void SetAutofocus()<br> {<br> if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO))<br> {<br> Debug.Log("Autofocus set");<br> }<br> }</p> <p>
(get rid of the HTML tags, lol)
Android Camera starts out of focus
Hello everybody,
I am new with Unity and Vuforia and Android... All the questions and replies were very very helpful!
Thanks! App works great now!
I do get a few errors but it runs fine, being a simple app.
They are below if anyone knows how to fix them. (I went to the Manual page but being a newbie makes it hard to understand the advice given there)
Tank
get_isEditor is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'focusMode' on game object 'ARCamera'. See "Script Serialization" page in the Unity Manual for further details.
FindObjectsOfType is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'focusMode' on game object 'ARCamera'.
See "Script Serialization" page in the Unity Manual for further details.
UnityException: FindObjectsOfType is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'focusMode' on game object 'ARCamera'.
See "Script Serialization" page in the Unity Manual for further details.
Android Camera starts out of focus
Android Camera starts out of focus
Android Camera starts out of focus
Hello,
I'm sorry guys I'm not litarate with code so much, can you tell me please where exactly I can attach this script? My issue is same, camera is running OK in playmode, after that when I compile it and build it for an Adroid, camera is really blurry. I've try almost everything I know - change focal leght, camera clipping, try to integrade some code from other users...
Finaly I've tried to do an export from Vuforia SAMPLEs - and BAm it works.. the problem is where exactly I should attach this script. I can't find Camera.Device there is no such script or asset. Probably if this is connected to AR - camera should be a script to ARcamera, not to the standard - camera into ARcamera object correct?
I will really appreciate any help. Thank you!
Ivaylo
Android Camera starts out of focus
Hi everyone. I have since solved this issue. Here is the code that works best for me.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using Vuforia;
public class focusMode : MonoBehaviour {
bool focusModeSet = CameraDevice.Instance.SetFocusMode(
CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
void Start ()
{
VuforiaBehaviour.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);
VuforiaBehaviour.Instance.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);
}
}
void onEnable(){
//CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO;
if (!focusModeSet) {
Debug.Log("Failed to set focus mode (unsupported mode).");
}
}
}
I hope that helps someone somewhere.
Same Problem. Do you have an solution @QFGlenn