Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Depth map calculation from Perception

Discussion in 'Computer Vision' started by DarraghLydon, Jun 18, 2021.

  1. DarraghLydon

    DarraghLydon

    Joined:
    Jun 18, 2021
    Posts:
    1
    Hello, I am investigating using Perception for segmentation and depth map calculation simultaneously in a similar fashion to this paper: https://arxiv.org/abs/1910.00541. I was wondering if is possible to get ground truth for depth maps from objects in frame in the simulation? I've probably explained this poorly, but hopefully someone will understand what I mean
     
  2. RuiyuZhang_Unity

    RuiyuZhang_Unity

    Unity Technologies

    Joined:
    Mar 17, 2021
    Posts:
    11
    Hi,

    The depth map you are asking for does not exist in the current perception package yet, we are working on it right now and will include a depth labeler that will output the depth map from the perception SDK in the future. For your purpose, I suggest you use the Unity Simulation Capture Package which provides RGB, Depth, Normals for data capture. It can be added from Window -> Package Manager. And you can find the manual here: https://docs.unity3d.com/Packages/com.unity.simulation.capture@0.0/manual/index.html
     
    Last edited: Jun 24, 2021
  3. d_pepley

    d_pepley

    Joined:
    Oct 2, 2020
    Posts:
    18
    Hello,

    I'm struggling to get depth to work with this package. My project is using URP. I can get he camera grab script to work, but I need depth images. I've found a script called Depth Grab, but haven't found any instructions for the script. The output I am getting from it is a weird yellow color. It appears like the camera clipping plane is short. I don't see any settings letting me set the clipping plane distance, which would be important for translating the image values into depths.
     
  4. d_pepley

    d_pepley

    Joined:
    Oct 2, 2020
    Posts:
    18
    Update on my issue here. My issue using depth grab is weirder than I thought. I've found that actually what is happening is that Depth Grab is generating an image made up of only objects which have a transparent material. That transparent material is captured in full color, suggesting that there is no depth capture happening at all. In the image below you can see I have set one of my materials to transparent (its supposed to be yellow shiny paint). That is the only thing that appears in the image, which is supposed to be a black and white depth image. upload_2021-8-6_10-58-35.png
     
  5. d_pepley

    d_pepley

    Joined:
    Oct 2, 2020
    Posts:
    18
    I found a solution, though I don't know why it works. The issue was the skybox. In the camera component I switched the background type for skybox to default. Suddenly, everything works fine. So my problem is solve. I am curious to know why this fixes things though.
     
  6. BBraitling

    BBraitling

    Joined:
    Jun 11, 2017
    Posts:
    3
    @d_pepley I am no expert, but I am going to work with Perception Tutorials shortly... I appreciate you sharing your experience.

    I know that rendering each frame --processes things in a specific order -- based upon the render pipeline that is selected. Perception Tutorial says we can use URP or HDRP, but I want to work in URP like you are doing.

    In URP, the Base Camera is necessary to set the environment rendering, which is where we find the Skybox toggle... per this link Camera component reference | Universal RP | 10.3.2 (unity3d.com) If it is not set with a skybox or default color...things might get weird.

    But you can stack cameras, adding Overlay cameras...which are easy to control. See that link for more info. I found them very useful in the Machine Learning Tutorials I have done...

    In ML, the Raycast from an Overlay camera was used to detect distance and clipping was easy to control.
    Those tutorials might allow you to explore scripting and settings on cameras and renders. ( I enjoyed the Hummingbird Tutorial)

    Also noted this blog Understanding the Importance of Using Multiple Cameras in Unity (theknightsofunity.com)

    Best Regards.
     
    Last edited: Aug 15, 2021
  7. d_pepley

    d_pepley

    Joined:
    Oct 2, 2020
    Posts:
    18
    I think I have determined why the transparent objects don't work. I believe it has to do with how transparent objects don't write to the Z-Buffer. As a result, they must just rendered normally in whatever process is running the depth image.
     
  8. satyam_jay

    satyam_jay

    Joined:
    Feb 4, 2021
    Posts:
    2
    @d_pepley How did you do it? I am only getting a white image. My Configuration is below. Kindly help. Screenshot 2021-11-06 192642.png Screenshot 2021-11-06 192827.png Screenshot 2021-11-06 192857.png
     
  9. d_pepley

    d_pepley

    Joined:
    Oct 2, 2020
    Posts:
    18
    My best guess is its your clipping planes. I'd guess your far plane should be something much smaller (depends on your scene of course) so try messing with the near far range. Also I'd lower short to like 0.001.

    You are using 8bit here for depth, so for your range you have set (0.3 to 100m). The value of each greyscale color is then (100-0.3)/256. That's fairly low precision. 16bit and 32bit can help improve precision, but you will need a way to translate the raw image into something visible.
     
  10. ibrahim2595

    ibrahim2595

    Joined:
    Oct 8, 2021
    Posts:
    4
    @d_pepley could you please share the camera Grab script? Where did you find it? I am unable to either find that or the Unity Simulation Capture Package @RuiyuZhang_Unity mentioned above.

    I have an interior scene and I am trying to generate the depth map as I fly through. I will save these frames.

    Thank you for the help.
     
  11. FedericoVasile1

    FedericoVasile1

    Joined:
    Oct 18, 2021
    Posts:
    3
    Hi,

    any updates on this? Will the perception package have a depth camera labeler? When?
    I think it is a useful feature in many robotics applications.

    Thank you
     
  12. cameronsun

    cameronsun

    Unity Technologies

    Joined:
    Jan 10, 2020
    Posts:
    21
    Hey there - this request is being tracked on github issues. You can find some info there, along with the contact info of one of our Product Managers who might be able to tell you a bit more.
     
  13. RuiyuZhang_Unity

    RuiyuZhang_Unity

    Unity Technologies

    Joined:
    Mar 17, 2021
    Posts:
    11
    Hey friends,

    We have a depth labeler in the works that can generate 32-bit depth images in EXR format, where each pixel contains the actual distance in Unity units (usually meters) from the camera to the object in the scene.

    If this seems of interest, feel free to drop an email to @shounakmitra (shounak.mitra@unity3d.com) and he can take it from there!