Vuforia SDK---- AR开发vuforia 相机自动对焦代码实现
2016-04-07 09:58
435 查看
在使用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组件上就可以。
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组件上就可以。
相关文章推荐
- Spring源代码解析(二):IoC容器在Web容器中的启动
- C#创建不规则窗体-图片
- C#messagebox汇总
- 每天laravel-20160704|CahceHit
- C#像QQ一样隐藏窗体
- 每天laravel-20160703|ClearCommand
- ASP.Net MVC Action重定向跳出Controller和Area
- java多线程之Phaser
- github desktop for mac 上传项目步骤以及注意事项
- Spring源代码解析(一):IOC容器
- 每天laravel-20160703|ClearCommand
- scrapyd的安装
- JAVA的环境的手动安装配置
- Python Requests 基础入门
- Python函数参数默认值的陷阱和原理深究
- 每天laravel-20160702|CacheTableCommand
- php中高级基础知识点
- 每天laravel-20160702|CacheTableCommand
- C# 对象序列化和反序列化
- 蓝桥杯b组c++.8 四平方定理