我在Unity中使用 Vuforia 6.2 AR SDK 。但是当我在Android手机中测试应用程序时,相机似乎是模糊。我在Vuforia的开发者网站上搜索并发现了一些相机焦点模式,但我无法实现,因为该指南适用于较旧的Vuforia SDK,我找不到他们在网站上提到的脚本。这是他们的代码示例,但它不起作用。我创建了不同的脚本并在Start()函数上运行此行,但仍无效。
CameraDevice.Instance.SetFocusMode(
CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
答案 0 :(得分:3)
试试这个
void Start ()
{
VuforiaBehaviour.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);
VuforiaBehaviour.Instance.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);
}
}
答案 1 :(得分:0)
此代码是正确的代码。
bool cameramode = false;
public void OnCameraChangeMode()
{
Vuforia.CameraDevice.CameraDirection currentDir = Vuforia.CameraDevice.Instance.GetCameraDirection();
if (!cameramode) {
RestartCamera(Vuforia.CameraDevice.CameraDirection.CAMERA_FRONT);
camBtnTxt.text = "Back Camera";
} else {
RestartCamera(Vuforia.CameraDevice.CameraDirection.CAMERA_BACK);
camBtnTxt.text = "Front Camera";
}
}
private void RestartCamera(Vuforia.CameraDevice.CameraDirection newDir)
{
Vuforia.CameraDevice.Instance.Stop();
Vuforia.CameraDevice.Instance.Deinit();
Vuforia.CameraDevice.Instance.Init(newDir);
Vuforia.CameraDevice.Instance.Start();
}