Point cloud generation from depth map and pair (left and right) images

I have the left and right images of a scene and the relevant depth map which has been saved with ZED Depth Viewer software. Could you please let me know with these images I can generated the point clouds? Also I was interested to know that why the generated depth map has 4 channels. Thanks

Hi @code_lover
Welcome to the Stereolabs community.

The ZED point cloud contains 32-bit color information in BGRA format to optimize data transfer.

To perform the task that you described you must parse the depth map pixel by pixel and apply the formulas described here.

1 Like

Thanks for your respond. I am encoding depth values from a BGR image using the following formula:

depth = bgr_image[:, :, 0] + bgr_image[:, :, 1] * 256 + bgr_image[:, :, 2] * 256 * 256

I also convert these depth values from millimeters to meters by dividing them by 1000.0. However, I’m uncertain if this approach is accurate or if the depth values are already in meters. Could you please confirm if this method is correct for depth data from ZED 2i camera?

Hello @code_lover,

I think some clarification is needed. If you get the “depth map”, that would be an array or matrix with only the depth, being the “Z” values mentioned in the link @Myzhar put up.
To get the point cloud from that, you would use the formulas he shared on the left image.
You can retrieve these values in Python using retrieve_measure.

  • See the list of possible measures here: MEASURE

Note: From the XYZRGBA measures, you can extract the positions in the first three channels as 32bit float values, and the color from the last channel if you read it as an array of 8bit int/char values (for RGBA values) instead of a 32bit value.

If you saved the point cloud from depth viewer, in PLY or VTK format for example, you can map the color of each pixel of your LEFT image to each position in your point cloud that you’ll find in the file.

Thank you for your respond. The issue is that unfortunately I don’t have access to camera and the depth map and left&right were given to me as PNG images to generate the point clouds. In addition, I am not sure about the camera intrinsic parameters for ZED 2i camera.


You can retrieve the camera’s calibration file using its serial number on this page: Download Calibration File
It contains the intrinsic parameters to use with the formulas, for each resolution.

If the PNG you have for the depth is from Depth Viewer, each pixel should contain only the DEPTH value in millimeters, so a 32bit float. You can retrieve it using your method of choice and use it for the point cloud generation.
(To check pixels value on my image quickly, I personally use GIMP’s Pointer tool.)

1 Like

Thanks a lot for your helpful guidance. I loaded my depth image in GIMP (attached in below) but I found that it is a little bit different from your image. could you please advice whether I can still use this informations still to generate the point clouds?


Would you be able to share the image?
It should be a fully grey image. If you have a screen capture from the depth viewer windows, it will not work.
To save the depth map from depth viewer, open the depth viewer settings, go to the “Camera” tab, and click “Save” next to depth.

1 Like

unfortunately it is not a gray image. here you are it is as below:

How did you get this image?

This looks like a screen capture from depth viewer, it will not help you generate the point cloud.
Please refer to the instructions in my previous message.

1 Like

How did you get this image?

This looks like a screen capture from depth viewer, it will not help you generate the point cloud.
Please refer to the instructions in my previous message.

[Discourse post]

R&D Engineer
Stereolabs Support

1 Like

Hello again,

Thank you very much for your helpful response to my previous inquiry. I am looking to understand the units of X and Y as displayed in the image metadata – are these values in inches? I aim to convert the X and Y coordinates into real-world measurement units. Could you please advise if this is feasible using the available depth map, and if so, how it might be accomplished?

Hi @code_lover,

The units should be in millimeters.
To convert from 2D space (XY and depth) into 3D space, I refer you to the article that Myzhar linked above.