Unity中vuforia AR镜头聚焦

Unity中vuforia AR镜头聚焦

通过vuforia 开发的AR系统存在镜头模糊的情况,可通过添加脚本的方式让镜头聚焦,通过vuforia官网下载代码:https://library.vuforia.com/articles/Solution/Working-with-the-Camera#Camera-Focus-Modes
也可直接复制代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;

public class AR_camera : 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);
    }
}
}

确认代码无误后,将脚本拖到ARcamera上,打包APK,安装,over!

你可能感兴趣的:(unity,3D问题+解决方法)