PTCInc / vuforia-engine

Bug and feedback issue tracker for the Vuforia Engine SDK
https://developer.vuforia.com
20 stars 0 forks source link

Override detection position feature does not allow to change guideview #36

Closed riccardokhm closed 1 year ago

riccardokhm commented 1 year ago

Summarize the bug: On activating the "override detection position" option on a model target, I am not able to change runtime the guideview.

Observed problem On building the application with such functionality on, the guideview change does not seem responsive. On turning on the standard configuration, guideview works perfectly. To change guideview, I initially reset the model target and then change guideview with the provided function (ModelTarget.SetActiveGuideViewIndex (int index) ).

Expected result I would optimize tracking stability by using such features since the guideviews are highly instable with the geometry.

Reproducible steps Steps to reproduce the behavior:

  1. Create a model target
  2. Click on 'override detection position'
  3. Change runtime guideview
  4. See error

Affected Vuforia Engine version: Vuforia Engine 10.15.4

Affected platform:

Affected device:

Workaround I am currently implementing such features only on a single guideview.

ptc-pscheper commented 1 year ago

Hi there, would you be able to share the code which is linked to your "Change View" button?

riccardokhm commented 1 year ago

Yes, here's the code:

#region ' Fields '

[SerializeField] private List<GameObject> _backlightsGOs;
[SerializeField] private TextMeshProUGUI _label;
[SerializeField] private TMP_Dropdown _dropdown;
[SerializeField] private TMP_Text _text;
[SerializeField] private ModelTargetBehaviour _modelTarget;
[SerializeField] private Button _button;

private int _backlight;
private bool _optionsAdded = false;

#endregion

#region ' Methods '

void Start()
{
    _backlight = ArController._dropdownChoice;
    ActivateGO(_backlight);   
    _button.onClick.AddListener(ChangeGuideview);
}

public void ChangeGuideview()
{
    if (_modelTarget.GetActiveGuideViewIndex() == _modelTarget.GetNumGuideViews() - 1)
    {
        _modelTarget.SetActiveGuideViewIndex(0);
        _modelTarget.Reset();
        return;
    }
    int i = _modelTarget.GetActiveGuideViewIndex() + 1;
    bool guideviewActivated = _modelTarget.SetActiveGuideViewIndex(i);
    _modelTarget.Reset();
}
ptc-pscheper commented 1 year ago

Hi there, please note that it's not recommended to change settings through the inspector during Play Mode which might cause the issues you're experienced. Let me try to understand your use-case so I can provide some insights how to better utilize the API, are simply trying to switch the guide view to a different one? I think for that use-case you do not need to set the "override detection position" property.

riccardokhm commented 1 year ago

Hi, thanks for your reply. I know it's not recommended but it was just a way to show you the bug which appears at runtime on my device. Yeah, my ultimate aim is to switch guideview (which I am already able to do), but i understood that override detection position control option could help stabilize the tracking, and thus the choice to activate it. I am trying to optimize tracking initialization by imposing the starting position of the camera in Unity Space by activating this option, is it correct?

ptc-pscheper commented 1 year ago

Mmm, I believe that you might be using the feature not as intended which might cause the issues you are experiencing. First of all, the recommended way to switch between guide views, which I verified, is to use the following code:

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

public class GuideViewChanger : MonoBehaviour
{
    public ModelTargetBehaviour mModelTarget;
    public int guideViewIndexToActivate = 0;

    public void SetGuideView()
    {
        mModelTarget.SetActiveGuideViewIndex(guideViewIndexToActivate);
    }
}

The code above will be able to set the correct guide view, based on the guideViewIndexToActivate integer property. In your code, I don't think you need to invoke .Reset() after setting the guide view.

When the Override Detection Position is set, you cannot change the guide view anymore as it will be overridden. I am unsure if you can override the position during runtime though. When the Override Detection Position is set, you are able to change the guide view by changing the GameObject and attached camera. These changes however are only captured during Model Target Behaviour activation or switching to a different guide view.

In any case overriding the detection position, to my knowledge, does not help stabilize the tracking. The feature is helpful if you want to dynamically change the guide view position without having to re-export the target and create new guide views. For example, during development where you're experimenting with the best angles to detect the object.

riccardokhm commented 1 year ago

Ok now it seems all clear to me! Thanks for your support!

ptc-pscheper commented 1 year ago

Anytime!