Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    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,148
    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.