Reputation:
How do I make the camera to be focused since it is always out of focus whenever I use ARCore with vuforia library?
Upvotes: 0
Views: 680
Reputation: 1
This is the new method for the focus
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class CameraFocusController : MonoBehaviour
{
void Start()
{
var vuforia = VuforiaApplication.Instance;
vuforia.OnVuforiaStarted += OnVuforiaStarted;
vuforia.OnVuforiaPaused += OnPaused;
}
private void OnVuforiaStarted()
{
VuforiaBehaviour.Instance.CameraDevice.SetFocusMode(
Vuforia.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}
private void OnPaused(bool paused)
{
if (!paused) // resumed
{
// Set again autofocus mode when app is resumed
VuforiaBehaviour.Instance.CameraDevice.SetFocusMode(
Vuforia.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}
}
}
Upvotes: 0
Reputation:
The ARCamera control is taken over by ARCore and we have to manually set the camera to be on autofocus mode. Adding this script to camera object worked to be continous autofocus mode. Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class CameraFocusController : MonoBehaviour
{
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);
}
}
}
Upvotes: 2