Search Unity

Disable Plane Detection

Discussion in 'AR' started by sheesrivastava, Aug 7, 2018.

  1. sheesrivastava

    sheesrivastava

    Joined:
    Jun 1, 2018
    Posts:
    4
    Hi Guys,

    I want to disable the plane detection after I had detected a plane of certain size, so far I am only able to get list of all planes and selectively disable them.

    What I want to achieve , is that instead of detecting multiple planes , detect only one plane and track it .

    Secondly, i want to check if the plane mesh is of certain size and disable it accordingly.
     
  2. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    You can subscribe to the ARPlaneManager's plane events and disable the instantiated plane if it does not fit your criteria. When you want to disable plane detection entirely, simply disable the ARPlaneManager.
     
  3. WolfBeardedLion

    WolfBeardedLion

    Joined:
    Apr 5, 2013
    Posts:
    27
    I have found that disabling the ARPlaneManager repeatedly during an AR Session will crash iOS devices, and there is also a lot screen flickering that occurs prior to the crash, due to exceeding the iOS limitations on "wakeups".

    Event: wakeups
    Action taken: none
    Wakeups: 45001 wakeups over the last 169 seconds (266 wakeups per second average), exceeding limit of 150 wakeups per second over 300 seconds
    Wakeups limit: 45000
    Limit duration: 300s
    Wakeups caused: 45001
    Duration: 17.01s
    Steps: 18

    I was simply enabling the ARPlaneManager script when the user was touching the screen, and then disabling the script when the user stopped touching the screen. Turning this behavior off stopped the flickering and the crashing, so the problem has to be related to ARKit since my Android builds have no issue with the ARPlaneManager script being toggled on and off.
     
  4. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    Do you have a callstack for the crash?
     
  5. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    I'm not really sure what a "wakeup" event is in this context. It sounds like the notification screen on iOS, but I don't see why that would be related to an ARKit app. Also, if there are 266 such events per second, I wonder if you're disabling/enabling plane detection every frame rather than just on touch begin and end. It'd be great if you could get a callstack for the crash and submit a bug report.
     
  6. zyonneo

    zyonneo

    Joined:
    Apr 13, 2018
    Posts:
    386
  7. leafava

    leafava

    Joined:
    Mar 29, 2020
    Posts:
    2
    Which event should I subscribe to? My code is currently like this:
    Code (CSharp):
    1. private ARPlaneManager planeManager;
    2. private ARPlane plane;
    3.  
    4. void Awake()
    5. {
    6.     planeManager = GetComponent<ARPlaneManager>();
    7.     plane = GetComponent<ARPlane>();
    8. }
    9.  
    10. void OnEnable()
    11. {
    12.     plane.boundaryChanged += OnPlaneBoundaryChanged;
    13. }
    14.  
    15. void OnDisable()
    16. {
    17.     plane.boundaryChanged -= OnPlaneBoundaryChanged;
    18. }
    19.  
    20. void OnPlaneBoundaryChanged(ARPlaneBoundaryChangedEventArgs args)
    21. {
    22.     float planeArea = plane.size.x * plane.size.y;
    23.  
    24.     Debug.Log("Current plane area: " + planeArea);
    25.  
    26.     if (planeArea > 2.5f)
    27.     {
    28.         planeManager.enabled = false;
    29.  
    30.         Debug.Log("Plane manager is " + planeManager.enabled);
    31.     }
    32. }
    Also, how do you disable the plane detection? Like, this?
    Code (CSharp):
    1. planeManager.enabled = false;