-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summarize the bug:
Camera focus mode fails to revert to FOCUS_MODE_CONTINUOUSAUTO after a touch to focus operation(FOCUS_MODE_TRIGGERAUTO)
Observed problem
I wanted to make the camera operate in FOCUS_MODE_CONTINUOUSAUTO normally, then switch to FOCUS_MODE_TRIGGERAUTO to focus on the tapped area upon a user touch, and then revert back to FOCUS_MODE_CONTINUOUSAUTO after a certain delay.
to do so, i connected SetFocusMode(FocusMode.FOCUS_MODE_CONTINUOUSAUTO) to the OnVuforiaStarted event. I also added code to set the focus region and change the focus mode to FOCUS_MODE_TRIGGERAUTO when a touch input is detected. and then after delay, i set the region back to default and call SetFocusMode(FocusMode.FOCUS_MODE_CONTINUOUSAUTO).
However, while the touch-to-focus itself works fine, continuous autofocus doesn't resume after the delay. The logs show that the focus mode successfully changed back to FOCUS_MODE_CONTINUOUSAUTO, but the camera stays focused on the last tapped area. Strangely, I implemented exposure control the exact same way, and it works perfectly-exposure returns to continuous mode and updates normally. Only the focus is stuck.
Expected result
revert camera focus mode to FOCUS_MODE_CONTINUOUSAUTO after a touch to focus operation(FOCUS_MODE_TRIGGERAUTO)
Other observations
Share any other observations that you made while experiencing the bug.
Reproducible steps
- Initialize with CONTINUOUSAUTO focus mode
- Change focus mode to TRIGGERAUTO by touch
- After delay(2 seconds), set focus region to default and revert focus mode to CONTINUOUSAUTO
- Camera focus remains fixed
Affected Vuforia Engine version:
v11.4.4
Affected platform:
unity: v6000.1.9, v2022.3.58
- Workstation OS: Windows
- Platform: Unity
- Platform version: v6000.1.9, v2022.3.58
Affected device:
- Name: galaxy flip 7
- Model: sm-f766u1
- OS: Android 35
Screenshots / Video Recordings
Share any screenshots or video recordings from the platform or device. You can also use the Session Recorder.
Affected database
If applicable, share your database / dataset which is affected in the issue you're experiecing.
Device or platform logs
Share any logs from the platform or device.
Workaround
Is there currently a workaround that you're using?
Additional comments
Add any other details about the problem here.
this is my code
// Start is called before the first frame update
void Start()
{
VuforiaApplication.Instance.OnVuforiaStarted += StartVuforiaFocus;
}
void Update()
{
if (Input.touchCount > 0)
{
var touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Ended)
{
SetFocusRegion(touch.position, 0.25f);
SetExposureRegion(touch.position, 0.25f);
ShowTouchIndicator(touch.position);
}
}
}
void SetFocusRegion(Vector2 focusPosition, float extent)
{
Debug.Log("Start Focus Region");
var regionOfInterest = new CameraRegionOfInterest(focusPosition, extent);
if (VuforiaBehaviour.Instance.CameraDevice.FocusRegionSupported == true)
{
var success = VuforiaBehaviour.Instance.CameraDevice.SetFocusRegion(regionOfInterest);
if (success)
{
if (revertCoroutine != null)
{
StopCoroutine(revertCoroutine);
}
bool successF = VuforiaBehaviour.Instance.CameraDevice.SetFocusMode(FocusMode.FOCUS_MODE_TRIGGERAUTO);
if (successF)
{
if (getFocusCoroutine != null)
{
StopCoroutine(getFocusCoroutine);
}
getFocusCoroutine = StartCoroutine(GetFocusMode("Region"));
revertCoroutine = StartCoroutine(RevertFocusMode(RevertDelay));
}
}
else
{
Debug.Log("Failed to set Focus Mode for region " + regionOfInterest.ToString());
}
}
else
{
Debug.Log("Focus region supported: " + VuforiaBehaviour.Instance.CameraDevice.FocusRegionSupported);
VuforiaBehaviour.Instance.CameraDevice.SetFocusRegion(CameraRegionOfInterest.Default());
}
}
void SetExposureRegion(Vector2 focusPosition, float extent)
{
var regionOfInterest = new CameraRegionOfInterest(focusPosition, extent);
if (VuforiaBehaviour.Instance.CameraDevice.ExposureRegionSupported == true)
{
var success = VuforiaBehaviour.Instance.CameraDevice.SetExposureRegion(regionOfInterest);
if (success)
{
VuforiaBehaviour.Instance.CameraDevice.SetExposureMode(ExposureMode.EXPOSURE_MODE_TRIGGERAUTO);
}
else
{
Debug.Log("Failed to set Exposure Mode for region " + regionOfInterest.ToString());
}
}
else
{
Debug.Log("Exposure region supported: " + VuforiaBehaviour.Instance.CameraDevice.ExposureRegionSupported);
VuforiaBehaviour.Instance.CameraDevice.SetExposureRegion(CameraRegionOfInterest.Default());
}
}
public void StartVuforiaFocus()
{
VuforiaBehaviour.Instance.CameraDevice.SetFocusMode(FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
Toast.instance.Bake($"Initialize Focus mode : {VuforiaBehaviour.Instance.CameraDevice.FocusMode}");
}
private IEnumerator RevertFocusMode(float delay)
{
Debug.Log("Start Revert Focus to CONTINUOUSAUTO");
yield return new WaitForSeconds(delay);
bool successR = VuforiaBehaviour.Instance.CameraDevice.SetFocusRegion(CameraRegionOfInterest.Default());
bool successF = VuforiaBehaviour.Instance.CameraDevice.SetFocusMode(FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
bool successE = VuforiaBehaviour.Instance.CameraDevice.SetExposureMode(ExposureMode.EXPOSURE_MODE_CONTINUOUSAUTO);
if (successF)
{
if (getFocusCoroutine != null)
{
StopCoroutine(getFocusCoroutine);
}
getFocusCoroutine = StartCoroutine(GetFocusMode("Revert"));
}
}
private IEnumerator GetFocusMode(string mode)
{
yield return new WaitForSeconds(0.5f);
Debug.Log($"[{mode}] Focus mode : {VuforiaBehaviour.Instance.CameraDevice.FocusMode}");
Toast.instance.Bake($"[{mode}] Focus mode : {VuforiaBehaviour.Instance.CameraDevice.FocusMode}");
}and logs
2025-09-16 02:52:31.552 15342 15364 Info Unity ConfigureVideoBackground
2025-09-16 02:52:31.552 15342 15364 Info Unity Vuforia.MonoCameraConfiguration:ConfigureVideoBackground(Matrix4x4)
2025-09-16 02:52:31.552 15342 15364 Info Unity Vuforia.MonoCameraConfiguration:CheckForSurfaceChanges(Matrix4x4)
2025-09-16 02:52:31.552 15342 15364 Info Unity Vuforia.CameraController:UpdateCamera(Matrix4x4)
2025-09-16 02:52:31.552 15342 15364 Info Unity Vuforia.Internal.Core.StateProcessor:ProcessState(IVuState, IDictionary`2, IVideoBackgroundRenderer, ICameraController, IWorldOriginProvider, DeviceObserver)
2025-09-16 02:52:31.552 15342 15364 Info Unity Vuforia.Internal.Core.Engine:UpdateState()
2025-09-16 02:52:31.552 15342 15364 Info Unity System.Reflection.RuntimeMethodInfo:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
2025-09-16 02:52:31.552 15342 15364 Info Unity System.Delegate:DynamicInvokeImpl(Object[])
2025-09-16 02:52:31.552 15342 15364 Info Unity Vuforia.Utility.ExtensionMethods.DelegateHelper:InvokeDelegate(Delegate, Object[])
2025-09-16 02:52:31.552 15342 15364 Info Unity
2025-09-16 02:52:46.522 15342 15364 Info Unity Start Focus Region
2025-09-16 02:52:46.522 15342 15364 Info Unity CameraSetting:SetFocusRegion(Vector2, Single)
2025-09-16 02:52:46.522 15342 15364 Info Unity CameraSetting:Update()
2025-09-16 02:52:46.522 15342 15364 Info Unity
2025-09-16 02:52:46.529 15342 15364 Info Unity Start Revert Focus to CONTINUOUSAUTO
2025-09-16 02:52:46.529 15342 15364 Info Unity <RevertFocusMode>d__13:MoveNext()
2025-09-16 02:52:46.529 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:52:46.529 15342 15364 Info Unity CameraSetting:SetFocusRegion(Vector2, Single)
2025-09-16 02:52:46.529 15342 15364 Info Unity CameraSetting:Update()
2025-09-16 02:52:46.529 15342 15364 Info Unity
2025-09-16 02:52:47.023 15342 15364 Info Unity [Region] Focus mode : FOCUS_MODE_TRIGGERAUTO
2025-09-16 02:52:47.023 15342 15364 Info Unity <GetFocusMode>d__14:MoveNext()
2025-09-16 02:52:47.023 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:52:47.023 15342 15364 Info Unity
2025-09-16 02:52:49.014 15342 15364 Info Unity [Revert] Focus mode : FOCUS_MODE_CONTINUOUSAUTO
2025-09-16 02:52:49.014 15342 15364 Info Unity <GetFocusMode>d__14:MoveNext()
2025-09-16 02:52:49.014 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:52:49.014 15342 15364 Info Unity
2025-09-16 02:52:54.885 15342 15364 Info Unity Start Focus Region
2025-09-16 02:52:54.885 15342 15364 Info Unity CameraSetting:SetFocusRegion(Vector2, Single)
2025-09-16 02:52:54.885 15342 15364 Info Unity CameraSetting:Update()
2025-09-16 02:52:54.885 15342 15364 Info Unity
2025-09-16 02:52:54.888 15342 15364 Info Unity Start Revert Focus to CONTINUOUSAUTO
2025-09-16 02:52:54.888 15342 15364 Info Unity <RevertFocusMode>d__13:MoveNext()
2025-09-16 02:52:54.888 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:52:54.888 15342 15364 Info Unity CameraSetting:SetFocusRegion(Vector2, Single)
2025-09-16 02:52:54.888 15342 15364 Info Unity CameraSetting:Update()
2025-09-16 02:52:54.888 15342 15364 Info Unity
2025-09-16 02:52:55.386 15342 15364 Info Unity [Region] Focus mode : FOCUS_MODE_TRIGGERAUTO
2025-09-16 02:52:55.386 15342 15364 Info Unity <GetFocusMode>d__14:MoveNext()
2025-09-16 02:52:55.386 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:52:55.386 15342 15364 Info Unity
2025-09-16 02:52:57.387 15342 15364 Info Unity [Revert] Focus mode : FOCUS_MODE_CONTINUOUSAUTO
2025-09-16 02:52:57.387 15342 15364 Info Unity <GetFocusMode>d__14:MoveNext()
2025-09-16 02:52:57.387 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:52:57.387 15342 15364 Info Unity
2025-09-16 02:53:06.543 15342 15364 Info Unity Start Focus Region
2025-09-16 02:53:06.543 15342 15364 Info Unity CameraSetting:SetFocusRegion(Vector2, Single)
2025-09-16 02:53:06.543 15342 15364 Info Unity CameraSetting:Update()
2025-09-16 02:53:06.543 15342 15364 Info Unity
2025-09-16 02:53:06.546 15342 15364 Info Unity Start Revert Focus to CONTINUOUSAUTO
2025-09-16 02:53:06.546 15342 15364 Info Unity <RevertFocusMode>d__13:MoveNext()
2025-09-16 02:53:06.546 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:53:06.546 15342 15364 Info Unity CameraSetting:SetFocusRegion(Vector2, Single)
2025-09-16 02:53:06.546 15342 15364 Info Unity CameraSetting:Update()
2025-09-16 02:53:06.546 15342 15364 Info Unity
2025-09-16 02:53:07.043 15342 15364 Info Unity [Region] Focus mode : FOCUS_MODE_TRIGGERAUTO
2025-09-16 02:53:07.043 15342 15364 Info Unity <GetFocusMode>d__14:MoveNext()
2025-09-16 02:53:07.043 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:53:07.043 15342 15364 Info Unity
2025-09-16 02:53:09.045 15342 15364 Info Unity [Revert] Focus mode : FOCUS_MODE_CONTINUOUSAUTO
2025-09-16 02:53:09.045 15342 15364 Info Unity <GetFocusMode>d__14:MoveNext()
2025-09-16 02:53:09.045 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:53:09.045 15342 15364 Info Unity
2025-09-16 02:53:15.833 15342 15364 Info Unity Start Focus Region
2025-09-16 02:53:15.833 15342 15364 Info Unity CameraSetting:SetFocusRegion(Vector2, Single)
2025-09-16 02:53:15.833 15342 15364 Info Unity CameraSetting:Update()
2025-09-16 02:53:15.833 15342 15364 Info Unity
2025-09-16 02:53:15.835 15342 15364 Info Unity Start Revert Focus to CONTINUOUSAUTO
2025-09-16 02:53:15.835 15342 15364 Info Unity <RevertFocusMode>d__13:MoveNext()
2025-09-16 02:53:15.835 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:53:15.835 15342 15364 Info Unity CameraSetting:SetFocusRegion(Vector2, Single)
2025-09-16 02:53:15.835 15342 15364 Info Unity CameraSetting:Update()
2025-09-16 02:53:15.835 15342 15364 Info Unity
2025-09-16 02:53:16.333 15342 15364 Info Unity [Region] Focus mode : FOCUS_MODE_TRIGGERAUTO
2025-09-16 02:53:16.333 15342 15364 Info Unity <GetFocusMode>d__14:MoveNext()
2025-09-16 02:53:16.333 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:53:16.333 15342 15364 Info Unity
2025-09-16 02:53:18.336 15342 15364 Info Unity [Revert] Focus mode : FOCUS_MODE_CONTINUOUSAUTO
2025-09-16 02:53:18.336 15342 15364 Info Unity <GetFocusMode>d__14:MoveNext()
2025-09-16 02:53:18.336 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:53:18.336 15342 15364 Info Unity
2025-09-16 02:53:24.072 15342 15364 Info Unity Start Focus Region
2025-09-16 02:53:24.072 15342 15364 Info Unity CameraSetting:SetFocusRegion(Vector2, Single)
2025-09-16 02:53:24.072 15342 15364 Info Unity CameraSetting:Update()
2025-09-16 02:53:24.072 15342 15364 Info Unity
2025-09-16 02:53:24.075 15342 15364 Info Unity Start Revert Focus to CONTINUOUSAUTO
2025-09-16 02:53:24.075 15342 15364 Info Unity <RevertFocusMode>d__13:MoveNext()
2025-09-16 02:53:24.075 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:53:24.075 15342 15364 Info Unity CameraSetting:SetFocusRegion(Vector2, Single)
2025-09-16 02:53:24.075 15342 15364 Info Unity CameraSetting:Update()
2025-09-16 02:53:24.075 15342 15364 Info Unity
2025-09-16 02:53:24.572 15342 15364 Info Unity [Region] Focus mode : FOCUS_MODE_TRIGGERAUTO
2025-09-16 02:53:24.572 15342 15364 Info Unity <GetFocusMode>d__14:MoveNext()
2025-09-16 02:53:24.572 15342 15364 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
2025-09-16 02:53:24.572 15342 15364 Info Unity
2025-09-16 02:53:25.558 15342 15364 Info Unity Vuforia Stopped
2025-09-16 02:53:25.558 15342 15364 Info Unity Vuforia.Internal.Core.Engine:Stop(Action)
2025-09-16 02:53:25.558 15342 15364 Info Unity Vuforia.Internal.Core.Engine:Pause()
2025-09-16 02:53:25.558 15342 15364 Info Unity System.Reflection.RuntimeMethodInfo:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
2025-09-16 02:53:25.558 15342 15364 Info Unity System.Delegate:DynamicInvokeImpl(Object[])
2025-09-16 02:53:25.558 15342 15364 Info Unity Vuforia.Utility.ExtensionMethods.DelegateHelper:InvokeDelegate(Delegate, Object[])
2025-09-16 02:53:25.558 15342 15364 Info Unity Vuforia.Utility.ExtensionMethods.DelegateHelper:InvokeWithExceptionHandling(Action`1, T)