Topic locked

Smartphone camera autofocus

April 14, 2016 - 7:56am #1

Hello..

I had tried to develop AR app on my android phone but stuck at the problem where my phone camera cannot focus on the marker and it appear blurry. How to eliminate this problem?? I have tried to use this script by AlessandroB  below, but no luck because this error appear "Assets/FocusMode.cs(11,17): error CS0246: The type or namespace name `QCARAbstractBehaviour' could not be found. Are you missing a using directive or an assembly reference?"

My android phone is Samsung S3 and I'm still new using this software.. Please help me..

using UnityEngine;
using System.Collections;
using Vuforia;
 
public class FocusMode : MonoBehaviour {
 
    private bool mVuforiaStarted = false;
 
    // Use this for initialization
    void Start () {
        QCARAbstractBehaviour qcar = (QCARAbstractBehaviour)FindObjectOfType( typeof(QCARAbstractBehaviour) );
        if (qcar) {
            qcar.RegisterQCARStartedCallback( OnQCARStarted );
        }
        else {
            Debug.Log ("Failed to find QCARBehaviour in current scene");
        }
    }
 
    private void OnQCARStarted()
    {
        Debug.Log ("Vuforia has started.");
        mVuforiaStarted = true;
 
        // Enable focus mode:
        bool autofocusOK = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
        if (autofocusOK) {
            Debug.Log ("Successfully enabled Continuous Autofocus mode");
        }
        else {
            // set a different focus mode (for example, FOCUS_NORMAL):
            CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_NORMAL);
 
            // Other possible options:
            // CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_MACRO);
            // CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_INFINITY);
        }
    }
}

 

Smartphone camera autofocus

April 15, 2016 - 1:59am #7

You're welcome.

Smartphone camera autofocus

April 15, 2016 - 12:43am #6

Thanks eddieoffermann and AlessandroB . That work just fine.. Thanks for your reply. A really appreciate it.

Smartphone camera autofocus

April 14, 2016 - 5:24pm #5

You may want to check that you installed that Unity update with Android support enabled. I believe the fields to add the SDK will only appear if Unity has been installed in that way. I'd just install again and when it asks you to select which components to install, make sure you check "Android Build Support".

If that doesn't fix it for you, head over to the Unity forums where they can offer help better tuned to those needs since it's a broader Unity problem rather than a Vuforia issue.

Smartphone camera autofocus

April 14, 2016 - 10:45am #4

BTW.. I just now update the Unity3D to version 5.3.4f1.. Now my unity3D didn't detect my Android SDK Manager. Thus, makes me unable to build my app into my android phone.. I tried to change the SDK folder in Preferences > External Tools, but I can only change the Script Editor not SDK.

 

 

AttachmentSize
Image icon fdbdfb.png32.64 KB

Smartphone camera autofocus

April 14, 2016 - 10:44am #3

BTW.. I just now update the Unity3D to version 5.3.4f1.. Now my unity3D didn't detect my Android SDK Manager. Thus, makes me unable to build my app into my android phone.. I tried to change the SDK folder in Preferences > External Tools, but I can only change the Script Editor not SDK.

 

Smartphone camera autofocus

April 14, 2016 - 10:05am #2

If you are using Vuforia 5.x, you need to replace QCARAbstractBehaviour with VuforiaAstractBehaviour and the method RegisterQCARStartedCallback with RegisterVuforiaStartedCallback.

 

Topic locked