Log in or register to post comments

Autofocus does not work well with Galaxy Samsung S7

December 15, 2016 - 3:09am #1

I would like to know have anyone come across this issue. Below is my autofocus C# code. I have tested in other phone and it work, however in samsung S7 the focus seems like not working. May I know is there any other way, or anyone have tried to make it work?

void Start() { OnSingleTapped(); } // Update is called once per frame void Update() { // quiting the Application if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } OnSingleTapped(); } private void OnSingleTapped() { TriggerAutoFocus(); } public void TriggerAutoFocus() { StartCoroutine(TriggerAutoFocusAndEnableContinuousFocusIfSet()); } private IEnumerator TriggerAutoFocusAndEnableContinuousFocusIfSet() { yield return new WaitForSeconds(0.5f); CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO); }

your help is highly appreciate. Thanks.

Autofocus does not work well with Galaxy Samsung S7

December 26, 2016 - 8:05am #4

I have an error 

 

Assets/CameraFocusController.cs(18,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 an assembly reference?

Autofocus does not work well with Galaxy Samsung S7

December 15, 2016 - 6:42pm #3

Thanks for your reply. Have tested your code, however the autofocus feature in the phone is still not really good. What I mean here is it does focus however it takes time, and yet the focus is not sharp enough as other tested phone, henceforth the content not able to pop up. I am curious is it the problem of vuforia library itself? Any other help? thanks 

AttachmentSize
Image icon Screenshot_20161216-103533[1].png2.52 MB

Autofocus does not work well with Galaxy Samsung S7

December 15, 2016 - 3:20am #2

Thats interesting, Try with this script which I have been using for my apps without any problems

 

private bool mVuforiaStarted = false;

void Start ()

{

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

  if (vuforia != null)

   vuforia.RegisterVuforiaStartedCallback(StartAfterVuforia);

}

private void StartAfterVuforia()

{

  mVuforiaStarted = true;

  SetAutofocus();

}

void OnApplicationPause(bool pause)

{

  if (!pause)

  {

   // App resumed

   if (mVuforiaStarted)

   {

    // App resumed and vuforia already started

    SetAutofocus();

   }

  }

}

private void SetAutofocus()

{

  if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO))

  {

   Debug.Log("Autofocus set");

  }

  else

  {

   // never actually seen a device that doesn't support this, but just in case

   Debug.Log("this device doesn't support auto focus");

  }

}

Log in or register to post comments