Plane detection in Unity AR

In Augmented Reality (AR), plane detection refers to the process of recognizing flat, horizontal/vertical surfaces in the real-world environment using sensor dataInput from camera.. The planes detected include tables, floors, walls, and other level surfaces.

Implementing plane detection

Plane detection is considered a fundamental feature in AR applications as it allows virtual objects to be placed and interact with the real world more realistically. By detecting the planes in the environment, AR applications can position virtual content, ensuring it appears anchored to the detected surfaces. Open Unity Hub and create an AR project.

canvasAnimation-image
1 of 6

AR plane manager

The AR plane manager is a component in Unity's AR foundation framework that helps you work with and manage detected surfaces, commonly referred to as "planes," in an AR environment. AR plane manager has:

Plane prefab:

This refers to a GameObject that represents the visual representation of the detected planes in the AR scene. When the Plane Manager detects a flat, horizontal surface, it instantiates this prefab to display a visual representation of the detected plane in the AR environment. The prefab typically includes a visual mesh or some visual indicators to indicate the position and size of the detected plane.

Detection mode

This is a setting in the plane manager that determines how the AR system detects and updates the detected planes in the environment. There are typically two main detection modes:

  1. Horizontal plane detection: In this mode, the AR system focuses on detecting and tracking flat, horizontal surfaces like floors and tables. It ignores other surfaces that are not horizontally oriented.

  2. Vertical plane detection: In this mode, the AR system detects and tracks vertical surfaces like walls. This is useful for placing virtual objects on walls or aligning AR content with vertical features in the environment.

  3. Everything: This mode detects and tracks both vertical and horizontal surfaces.

In XR origin, add the AR plane manager as a component. Choose the detection mode that best suits your requirements.

AR default plane

For the plane prefab we will be using a default plane. To add an AR default plane go to add > XR > AR default plane.

Leave the default setting for the default plane. Create a prefabs folder and drag the AR default plane there. From there, drag the AR default plane prefab into the plane prefab.

Save the scene. Connect your Android or iOS device. Go to File > Build and Run.

Demonstration

Conclusion

By configuring the plane manager's plane prefab and detection mode, you can create AR experiences that effectively leverage the detected planes in the real-world environment.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved