ZED2/Spatial Mapping


Is it possible to create a Mesh like ZED fu in Unity SDK? Because right now, we can not Navigate the 3D map with Unity.

I can see that the Open GL Plugin is available for Unity, have you tried integration of the two?


The spatial mapping inside Unity allows you to generate mesh object just like ZedFu or the spatial mapping sample.
For more informations about spatial mapping in Unity, please refer to our documentation (https://www.stereolabs.com/docs/unity/spatial-mapping-unity/).

Best regards,
Benjamin Vallon

Hi Benjamin,

The issue is that when I build and run, how to enable Meshes? Right Now I can enable it via Zed Manager, but I see no way of doing it while running, even your sample.

What will consume less Memory, Point Cloud, or Spatial Mapping for a really large space,sapy 40m X 40m, I am trying to map huge area.

I am building a Placement Holder app, So I was writing a custom script, like the one provided with AR Foundation.

Can our Helper C# Plane detection script be modified to detect vertical walls, as I will be placing these placement Markers on Walls?


When you are clicking on “Start spatial mapping” in the ZEDManager inspector window, it is calling this function : https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/ZED/SDK/Helpers/Shaders/PlaneDetection/GeometryWirePlane.shader#L30.

You can calling it in the script if you want.

For plane detection, you should look at the plane detection sample and the ZEDPlaneDetectionManager.cs script to start with.
For your project, the spatial mapping option seems to be the better solution.

When calling ZEDCamera.findPlaneAtHit() function (https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/ZED/SDK/NativeInterface/ZEDCamera.cs#L2464), it returns a PlaneData structure that contains all the data you need.
If you are looking for plane detection, you should look at the ZEDPlaneDetectionManager script and the plane detection sample scene.

Best regards,
Benjamin Vallon

Benjamin , Just curious, where is this ZED SpatialMapping Manager Script ?

In MeshRenderer.cs and ZedSpatialMapping.cs , you talk of this script, but I cannot find it anywhere !!

/// Processes the mesh taken from the ZED’s Spatial Mapping feature so it can be used within Unity.
/// Handles the real-time updates as well as the final processing.
/// Note that ZEDSpatialMappingManager is more user-friendly/high-level, designed to hide the complexities of this class. "


Those scripts can be found here : https://github.com/stereolabs/zed-unity/tree/master/ZEDCamera/Assets/ZED/SDK/Helpers/Scripts/SpatialMapping

Regarding the ZEDSpatialMappingManager class, it is also in ZEDSpatialMapping.cs at line 1231 (https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/ZED/SDK/Helpers/Scripts/SpatialMapping/ZEDSpatialMapping.cs#L1231).

Best regards,
Benjamin Vallon

Thnx, I already located these scripts, I was confused that Zed Spatial Mapping Manager is another script.

I figured out Fused Point cloud is most suitable for my application as it shows the actual view of the surroundings, compared to mesh, which generates a 3d textured .obj view.

However, I am not able to run the fused point cloud in Unity, using your fused point cloud. cs and point cloud renderer, Unity crashes and leads to exit !!


We are looking into this issue. It seems to only appear on Linux.
We will let you know once the issue is fixed.

Thanks for your feedbacks on the Linux plugin.

Best regards,
Benjamin Vallon

Just wanted to give a shout-out to your terrific team. We just have two of your Cams ZED-2 and ZED for our 1st Prototype Robot, the support has been overwhelming. You guys have taken the time to respond to every question, no matter, even it was dumb at times too !!

Thank You so much to the Stereo Labs Team for responding so promptly to all the queries !!

Can you download the libsl_unitywrapper.so attached and replace yours by this one in your project.
( the libsl_unitywrapper.so must be copied in Assets/ZED/SDK/Plugins/linux/)
Make sure you close Unity before copying the library otherwise it won’t be taken into account.

If that works, then we will update the official repository.

Note for using fused point cloud.
Your project must simply have :

  • ZED rig mono or stereo
  • a game object with the ZEDFusedPointCloudRenderer script.
    Nothing more is needed.
    For the ZEDFusedPointCloudRenderer settings, make sure that :
  • you set the ZEDManager component to the ZED_Rig_Mono or stereo used.
  • Common settings for size,resolution and range are :
    Point Size = 0.01 (1cm)
    Resolution = 0.05 (5cm)
    Rnage = 5 (5meters)

libsl_unitywrapper.so (1.9 MB)

Working on Both,
The problem

  1. Your default Zed Fused Point Cloud Renderer Resolution is 0.5 and the default point size is 0.001, it looks like the point cloud is not getting generated, changing to your specified values solves the issue.

It only appears in the Scene Window, Not in the game Window. Even after Build and Run, we get, simple Image from the Camera, No point Cloud.

After we stop the Camera, the Point Cloud data is not saved anywhere and disappears from the scene. Can this be saved like, we save a Mesh File? Because what is the use of fused point cloud, when no data is saved, it only maps, while the camera is running.


The point cloud can be seen with difficulty on top of the camera image (naturally because it is the same color), however if you add a “classic” Unity cam, you may see more easily.

There is a SavePointClound() function in ZEDCamera.cs that you can use to save your fusedPointCloud (https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/ZED/SDK/NativeInterface/ZEDCamera.cs#L2249).
It can be saved as OBJ or PLY.

Best regards,
Benjamin Vallon

Ok Thanks BenjaminV.

How can I get a view like the one attached in the screenshot?! You get this through Mesh with texture ? i am unable to regenerate this kind of view in Unity, My mesh is black, all Chunks are black !!

Guys C# API is missing from your website , Pls Update !! I am looking for C++ enum [MESH_TEXTURE_FORMAT] equivalent in C# !! .

As seen above , My mesh in Unity is not having texture !!

Hi Guys, Please respond, our project is getting stuck because of this !!

There is no texture of the real image in my mesh, it’s all-black !!

C# API is missing from your website, Pls Update !! I am looking for C++ enum [MESH_TEXTURE_FORMAT] equivalent in C# !! .

As seen above, My mesh in Unity is not having texture !! Mesh texture enum is there is C++

spatial_mapping_parameters.save_texture = true and map.applyTexture(MESH_TEXTURE_FORMAT::RGB)

Could not find this code in your cs script !!


In Unity, you cannot choose the MESH_TEXTURE_FORMAT because only RGBA is available.

To choose to save the texture or not, you can either check it in the ZEDManager inspector window, or set the “isMappingTextured” in ZEDManager.cs to true (here : https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/ZED/SDK/Helpers/Scripts/ZEDManager.cs#L295).

For the black texture, I fix the issue inside the unity wrapper (see in attachment). Replace yours by this new one and it should work fine.

Best regards,
Benjamin Vallon

libsl_unitywrapper.so (2.0 MB)

Hi again,

please use this lib instead, the previous one is working only on Ubuntu 20.

Best regards,

libsl_unitywrapper.so (1.9 MB)

It is not happening for me, I am either getting a black map or a wire mesh in the scene, I can click the different chunks, but they are all black.

Screenshot from 2021-02-17 09-58-29

As you can see, I can get a shaded wireframe or shaded black structure, cannot get the actual color texture of the scanned place.


Can you tell me if the texture saved (it must be a .png image) is correct or is a black texture ?
If the saved texture is correct, it would help me a lot if you can send me a example that is not working for you so I can do some tests on my side.

Can you also confirm that you created your mesh with Unity and not with a cpp/python program and then imported it in Unity ?

Best regards,
Benjamin Vallon

Hi Benjamin,

I am not writing any external code, i am just activating Spatial Mapping in your Spatial Mapping Example I am trying the spatial Mapping example , it generates 3 files mesh.mlt , mesh_material00_map_Kd.png and mesh.obj