Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved AR camera distance measurement

Discussion in 'AR' started by aegiswang, Jan 8, 2021.

  1. aegiswang

    aegiswang

    Joined:
    Jan 8, 2021
    Posts:
    2
    hello!
    I have a question, Could anyone help me please?
    I want to know how to show the distance information(like centermeter...) between AR camera and target object. (Using Smartphone)
    Can I do that in Unity ? Should I use AR Foundation? and with ARcore? How to write code?

    Thank again!
     
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,036
    1. You can use the ARRaycastManager to raycast against detected point clouds or tracked planes. Then can measure the distance between the camera position and raycast intersection with detected landmarks.
    2. Or you use the TryAcquireEnvironmentDepthCpuImage() to get the depth information of each pixel. It is supported on all Android devices and on iOS devices with LiDAR sensor.