I believe that if depth values are returning as zero then there are a couple of possible causes: (a) the camera cannot perceive 3D detail from what it is looking at and so cannot generate depth coordinates, returning them as zeros. An example of something that would be difficult for the camera to read is a flat surface such as a table top, or a sheet of paper on a table.
Or (b) some objects may have depth coordinates in some parts of them and zeros in other parts. This is normal, as there is simply nothing for the camera to read in the parts where there are zeros.
If you are getting all zeros, and not just partial ones, then that would suggest that the problem is related to possibility (a), a perception issue for the camera.
I am not an expert in the area of writing RealSense depth stream programs unfortunately, though I can read and interpret pre-made scripts quite well. At the risk of being wrong, I suspect that this particular script is just designed to display the depth stream but not project depth coordinates onto the image.
I would recommend a script that uses the ProjectCameraToDepth instruction to project an array of real-world coordinates onto an image. I turned the internet upside down looking for a pre-made C# script for this instruction or for its less efficient equivalent QueryVertices, but found nothing. I'll link RealSense stream programming expert jb455 into this discussion. JB, do you have any pre-made C# scripts for projecting depth coordinates onto an image.
In the meantime, I would try changing your PIXEL_FORMAT_DEPTH_RAW instruction to PIXEL_FORMAT_DEPTH and see if that gets you more refined data in your results.
It may be that the values are all being truncated to zeroes. I think in PixelFormat.PIXEL_FORMAT_DEPTH_RAW, the depth data are all less than 1 so when cast as int they end up as 0. You could either use PixelFormat.PIXEL_FORMAT_DEPTH and keep it as int or use float and depthData.ToFloatArray() and keep it as DEPTH_RAW (or DEPTH_F32).
Thanks muchly JB!
Awesome news, glad that it worked for you! Please come back to the forum any time that you have more questions. Good luck!