Vuforia SDK---- AR开发vuforia 相机自动对焦代码实现

来源:互联网 发布:全网视频自动采集源码 编辑:程序博客网 时间:2024/06/10 00:18

在使用vuforia sdk制作AR时候有时候会遇到的问题就是相机不对焦,相机对着一个图片时候在屏幕中显示的非常不清晰,之前的文字中也介绍了AR的相机对焦功能。


using UnityEngine;
using System.Collections;
using Vuforia;

public class RC_Tools : MonoBehaviour {

[Space(20)]
public bool AutofocusCamera = true;
public bool HideAndroidToolbar = true;
void Start () {
#if UNITY_ANDROID
if (HideAndroidToolbar) {
DisableSystemUI.Run();
DisableSystemUI.DisableNavUI();
}
#endif

StartCoroutine(Autofocus());
}
private IEnumerator Autofocus()
{
yield return new WaitForSeconds(1.0f);
if(AutofocusCamera) CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}
void onApplicationPause() {
StartCoroutine(Autofocus());
}
}


代码已经说明,然后就是新建一个脚本,如果使用Unity开发直接把脚本放到ARCamera组件上就可以。

0 0
原创粉丝点击