Install the ZED Python API

This section explains how to use the ZED SDK in Python 3 on Windows and Linux platforms.

Getting Started

The Python API is a wrapper around the ZED SDK which is written in C++ optimized code. We make the ZED SDK accessible from external Python code using Cython.

To start using the ZED SDK in Python, you will need to install the following dependencies on your system:

  • ZED SDK (see Installation section)
  • Python 3.5+ (x64)
  • Cython 0.26+
  • Numpy 1.13+
  • OpenCV Python (optional)
  • PyOpenGL (optional)

Make sure to install Python (x64 version) and the pip package manager. Then install the dependencies via pip in a terminal.

python -m pip install cython numpy opencv-python pyopengl

Installing the Python API

A Python script is available in the ZED SDK installation folder and can automatically detect your platform, CUDA and Python version and download the corresponding pre-compiled Python API package.

Running the install script

Windows

The Python install script is located in C:\Program Files (x86)\ZED SDK\.

Make sure you have admin access to run it in the Program Files folder, otherwise, you will have a Permission denied error. You can still copy the file into another location to run it without permissions.

Linux

The Python install script is located in /usr/local/zed/.

Run the script:

$ python get_python_api.py</p>
<pre><code># The script displays the detected platform versions
CUDA 10.0
Platform ubuntu18
ZED 3.1
Python 3.7
# Downloads the whl package
Downloading python package from https://download.stereolabs.com/zedsdk/3.1/ubuntu18/cu100/py37 ...

# Gives instruction on how to install the downloaded package
File saved into pyzed-3.1-cp37-cp37m-linux_x86_64.whl
To install it run :
  python3 -m pip install pyzed-3.1-cp37-cp37m-linux_x86_64.whl
</code></pre>

Now install the downloaded package with pip:

<pre><code>Processing ./pyzed-3.1-cp37-cp37m-linux_x86_64.whl
Installing collected packages: pyzed
Successfully installed pyzed-3.1
</code></pre>

That’s it ! The Python API is now installed. To get started, check out our Tutorials and Code Samples.

Troubleshooting

“Numpy binary incompatiblity”

Traceback (most recent call last):
    ...
    File "__init__.pxd", line 918, in init pyzed.sl
ValueError: numpy.ufunc size changed, may indicate binary incompatiblity. Expected 216 from C header, got 192 from PyObject

This error usually means numpy isn’t installed. To install it, simply run these commands :

<p>python3 -m pip install cython
python3 -m pip install numpy</p>