Enhancing Stereo Camera Performance: Achieving Target FPS with Local Streaming and Depth Map Saving

Hi everyone,

I utilized the code available at “https://github.com/stereolabs/zed-multi-camera/blob/master/python/multi_camera.py” with modifications to enable local streaming using a specific IP and port. Additionally, I incorporated a function to save the depth map as a text file. Through my modifications, I achieved a consistent FPS range of 10-12 for each camera, which was determined using the method: zed.get_current_fps(). Instead of 30

I have attempted to align my code with the sample provided in the GitHub repository, including the implementation of the depth map saving function using multiprocessing. However, I am open to any suggestions or optimizations that could help me attain the specified FPS consistently. Any insights would be greatly appreciated.

Hi,

What FPS do you achieve with “just” our sample?
Python is a slow language. If you use only the ZED SDK, you’ll have the same speed as with C++, but as soon as you do other operations, you can very easily break the performance. save images, for example. Also, python’s threading is not something reliable, it’s basically fake, using C++ would be a lot safer.

Finally, what hardware and depth mode are you using? Can you share your code maybe?

Hi,

What FPS do you achieve with “just” our sample?
Python is a slow language. If you use only the ZED SDK, you’ll have the same speed as with C++, but as soon as you do other operations, you can very easily break the performance. save images, for example. Also, python’s threading is not something reliable, it’s basically fake, using C++ would be a lot safer.

Finally, what hardware and depth mode are you using? Can you share your code maybe?

[Discourse post]

Antoine Lassagne
Senior Developer - ZED SDK
Stereolabs Support

with your sample only achieving between 24-27 for each camera, required FPS is 30 “only streaming without saving depth map”.
Hardware is jetson orin agx
Depth mode is PERFORMANCE

  1. Can you explain me this “python’s threading is not something reliable, it’s basically fake”?!
  2. Can I send the code via message, please?
  3. Is there a different strategy to increase FPS in Python without the need to switch to C++?
  4. which better C or C++?

@alassagne @system
Kindly assist.

Hi @ashfaq,

  1. Due to Python’s implementation, threading appears to execute code simultaneously, but in the background will only have one thread running, due to the Python Global Interpreter Lock (GIL). For more information, take a look at this guide which explains what the GIL does: What Is the Python Global Interpreter Lock (GIL)? – Real Python
  2. You can send your code to support@stereolabs.com with a link to this post, and we can take a look at it
  3. You can try having multiple processes run the code for each camera, you can do this with the multiprocessing module in Python. You would have to change the multi-camera sample so that the open and grab are done in each process.
  4. The C implementation is a wrapper over the C++ source code, so I would recommend C++ for ease of use if you are more familiar with C++.