Save depth map under new name

Hello, I am trying to make a depth map using python and the stereocamera. The point cloud can be saved as an ply file when hitting s in the sample provided, but if s is hit twice, the first file is overwritten. Is there a way to prevent this, at the moment I just rename the file before saving, but it would be more convenient if the code would do this itself. Anybody knows how to do this?
Thanks in advance Timo

Hi @Timo,

You can change this line of code in the sample: zed-sdk/depth sensing/depth sensing/python/depth_sensing.py at master · stereolabs/zed-sdk · GitHub
to update the name of the point cloud save path.

Thank you for your reply, I am now trying to take several images shortly after each other. But the camera does not update its point cloud. I currently have the below code:

while viewer.is_available():
        if zed.grab() == sl.ERROR_CODE.SUCCESS:
            zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA,sl.MEM.CPU, res)
            viewer.updateData(point_cloud)
            if(viewer.save_data == True):
#we loop 5 times to create 5 images with a time spacing of 5 seconds
                for i in range(2):
                    viewer.updateData(point_cloud)
                    time.sleep(5)
                    point_cloud_to_save = sl.Mat()
                    zed.retrieve_measure(point_cloud_to_save, sl.MEASURE.XYZRGBA, sl.MEM.CPU)
                    err = point_cloud_to_save.write(f'Pointcloud{i}.ply')
                    if(err == sl.ERROR_CODE.SUCCESS):
                        print("Current .ply file saving succeed")
                    else:
                        print("Current .ply file failed")
                    viewer.save_data = False
                    viewer.updateData(point_cloud)
                    time.sleep(5)
    viewer.exit()
    zed.close()

I do get 2 separate .ply files, but I do not manage to get two different files, as the point cloud does not update. Any idea how I can update the point cloud?
Thanks in advance

Hi @Timo,

The point cloud does not update in your script because you must call the zed.grab() method in order to acquire new images from the camera. Internally, the grab method retrieves the ZED data and computes its algorithms such as depth sensing, positional tracking, etc.

Hey Mattrouss,
Thank you very much for your help, that solves the problem!