Search Unity

ARFoundation: Detect overlapping and/or intersecting ARPlanes

Discussion in 'AR' started by Christin2015, May 13, 2019.

  1. Christin2015

    Christin2015

    Joined:
    Dec 1, 2015
    Posts:
    48
    Hi all,

    I would like to check if ARPlanes overlap other ARPlanes, or if they are intersected by another ARPlane. Then, in case that the intersection angle between their normals is greater than a certain Euler degree value (let's say 10°), I would like to deactivate the new ARPlane.

    I would also like to deactivate ARPlanes which overlap "older" ARPlanes. For example, if I got an ARPlane on a table surface , but also on the floor underneath that table. How could I detect that the table ARPlane overlaps for example 30% of the surface area of the floor ARPlane?
    As far as I understand,
    BoundedPlane.TryGetBoundary
    would deliver a
    List<Vector3>
    of all border vertices of an ARPlane. I could check against the corners of another ARPlane whether a vertex is positioned between the corners (
    boundedPlane.GetCorners
    ) of the other ARPlane. But, since their shape is not rectangular, how could I determine the size of the overlapping surface area ?
     
  2. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    boundedPlane.Size might be a useful approximation rather than looking at boundary or corner vertices (the corner vertices are computed from the size).

    If you are okay using the "corners", then that shape is rectangular. The corners are simply the width and height rotated into the orientation of the plane. One solution would be to rotate one plane into the space of the other, and then calculate the overlap of two oriented 2d boxes. There's a discussion on gamedev.net on this.

    Another option might be to cast some rays from the upper plane to the lower one and see if they hit using the PlaneWithinPolygon TrackableType. It depends on your use case and how accurate you need the result to be.
     
    Christin2015 likes this.
  3. Christin2015

    Christin2015

    Joined:
    Dec 1, 2015
    Posts:
    48
    Many thanks @tdmowrer for pointing this out! However, as far as I understand, the corners will define a kind of bounding box around the AR plane surface, whereas the Ar plane itself might be non-rectangular. Is this correct?
    And another question: Would it be feasible to run image segmentation (for example using Keras) in the AR scene simultaneously? The idea: use the ARcamera feed, do image segmentation so that the contours and the surface of specific real objects are detected, then use these detected surfaces to mask placed virtual models so that they do not "hide/ overlay" real objects. Do you think it would result in performance issues? (Image segmentation might run at 7-14 fps, I think.)

    BTW, working with ARFoundation is awesome! I am currenlty working on my 4th project. I hope Unity will not suspend it in near future.
     
  4. orgelvarg

    orgelvarg

    Joined:
    May 27, 2019
    Posts:
    15
    Thank you @Christin2015 for asking this question and thank you @tdmowrer for your answer. As you might suspect I was looking for a way to find the intersection of two or more planes!