Giter VIP home page Giter VIP logo

zed-python-api's Introduction

Stereolabs ZED - Python API

This package lets you use the ZED stereo camera in Python 3. 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.

Getting started

Prerequisites

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

For the ZED SDK 3.8 compatible version, use the zedsdk_3.X branch or the 3.8 release tag

Please check your python version with the following command. The result should be 3.7 or higher.

python --version

Cython and Numpy can be installed via pip.

python -m pip install cython numpy

The sample dependencies can also be installed via pip

python -m pip install opencv-python pyopengl

Note: On Linux, it is advised to use the python3 command instead of python which by default point to python 2.7. To do so, the following packages python3-dev and python3-pip need to be installed.

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:

$ cd "/usr/local/zed/"
$ python get_python_api.py
    # The script displays the detected platform versions
    Detected platform: 
        linux_x86_64
        Python 3.11
        ZED SDK 4.0
    # Downloads and install the whl package
    -> Checking if https://download.stereolabs.com/zedsdk/4.0/whl/linux_x86_64/pyzed-4.0-cp311-cp311-linux_x86_64.whl exists and is available
    -> Found ! Downloading python package into /home/user/pyzed-4.0-cp311-cp311-linux_x86_64.whl
    -> Installing necessary dependencies
    ...
    Successfully installed pyzed-4.0

To install it later or on a different environment run :

$ python -m pip install --ignore-installed /home/user/pyzed-4.0-cp311-cp311-linux_x86_64.wh

That's it ! The Python API is now installed.

Use the plugin

Code

Import the packages in your Python terminal or file like this:

import pyzed.sl as sl

Vectors operations like norm, sum, square, dot, cross, distance but also simple operations can be done with Numpy package.

Run the tutorials

The tutorials provide simple projects to show how to use each module of the ZED SDK.

Run the examples

Please refer to the examples README for more informations.

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 :

# On Jetson (aarch64) cython needs to be installed first since numpy needs to be compiled.
python3 -m pip install cython
python3 -m pip install numpy

Compiling the Python API from source (only for developers of the python wrapper)

To compile the ZED SDK Python wrapper go to src folder to get the cython sources and instructions.

Note : This step is not useful for users of the wrapper, it is only meant to be used to extend the wrapper for advanced uses.

Support

If you need assistance go to our Community site at https://community.stereolabs.com/

zed-python-api's People

Contributors

abastie avatar adujardin avatar ajtrask avatar alassagne-sl avatar hiroshi-maybe avatar kctess5 avatar myzhar avatar nesnes avatar p-yver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zed-python-api's Issues

Low FPS issue?

For some reason, the SDK defaults the camera FPS to 4fps for 720P mode and 2fps for 2K mode. This is despite setting the camera_fps flag explicitly. Even if I initialize it without any init parameters, it defaults to a low FPS. What is the reason for this?

Only left Zed camera is displaying image.

Hi,
I was able to capture images only from the left camera.
I tried to change the "PyVIEW.PyVIEW_LEFT" to "PyVIEW.PyVIEW_RIGHT" in camera.pyx file but to no use ( as VIEW_RIGHT was defined ), can you please tell me how to take left and right images, and rectify them using this wrapper .

Use multiple ZED camera with the python Package

Hello,

thanks a lot for your sharing! However, here I still have a quetion when using this python package (not cpp):

when my computer is connected with multiple ZED camera (e.g., two), then how can I access them separately using some identifier as parameter in your code? I just want to use those two ZED cams to take pictures in different directions.

Best regards,
XG

svo_real_time_mode not working

When svo_real_time_mode=True is set on the zcam.PyInitParameters the main grab loop will be unable to fetch frames. Constantly returning Error code: No New Frame

If set to false, everything will work. However the playback will not be in real time.

It works as expected when I use the C++ code

Pre determine SVO length

Hi, I'm trying to follow the read svo example to stream and process an svo I recorded. I want to store all of the depth frames (say in a numpy array). Is there a way to determine the length of an svo without streaming all the way to the end?

Python2 support ?

Hi there,

Thanks for your Python3 wrapper.
For those who developed in Python2, would you please provide a Python2 wrapper?

my zed camera is not detected.

Hi,
I'm using ZED camera on windows10 and gtx1060.
Now my camera is not recognized by my PC.
So I tried another PC that has USB3.0, but it didn't recognize the ZED camera too.
I want to know if ZED camera is recognized by PC when it is inserted into USB3.0.

Please can anyone help me with this issue?

The speed of depth sensing (zed.retrieve_measure)

I have a problem about processing speed of function(zed.retrieve_measure)
The FPS is unstable and so low , from 4 to 20.
The following is my setting:

init_params.depth_mode = sl.PyDEPTH_MODE.PyDEPTH_MODE_PERFORMANCE
init_params.coordinate_units = sl.PyUNIT.PyUNIT_METER
init_params.camera_resolution = sl.PyRESOLUTION.PyRESOLUTION_HD720
runtime_parameters.sensing_mode = sl.PySENSING_MODE.PySENSING_MODE_STANDARD

Then, I measure the time of the following functions cost is unstable and so long(0.05 to 0.3 second):
# Retrieve left image
zed.retrieve_image(image, sl.PyVIEW.PyVIEW_LEFT)
# Retrieve depth map. Depth is aligned on the left image
zed.retrieve_measure(depth, sl.PyMEASURE.PyMEASURE_DEPTH)
# Retrieve colored point cloud. Point cloud is aligned on the left image.
zed.retrieve_measure(point_cloud, sl.PyMEASURE.PyMEASURE_XYZRGBA)

Third, I open the ZED Depth Viewer using the same device. It runs smoothly and the FPS is above 30.

Would someone answer the questions, thank you very much.
BTW, the environment is based on TX2 ubuntu16.04 and python3.5.

Error while building as per the instructions

Hi,

Unfortunately I am unable to build the python wrappers for my project. Below is the error message:

D:\zed-python-master>python setup.py build
Compiling pyzed/defines.pyx because it changed.
[1/1] Cythonizing pyzed/defines.pyx
Compiling pyzed/types.pyx because it changed.
[1/1] Cythonizing pyzed/types.pyx
Compiling pyzed/core.pyx because it changed.
[1/1] Cythonizing pyzed/core.pyx
Compiling pyzed/mesh.pyx because it changed.
[1/1] Cythonizing pyzed/mesh.pyx
Compiling pyzed/camera.pyx because it changed.
[1/1] Cythonizing pyzed/camera.pyx
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\pyzed
copying pyzed_init_.py -> build\lib.win-amd64-3.5\pyzed
copying pyzed\camera.pxd -> build\lib.win-amd64-3.5\pyzed
copying pyzed\core.pxd -> build\lib.win-amd64-3.5\pyzed
copying pyzed\defines.pxd -> build\lib.win-amd64-3.5\pyzed
copying pyzed\mesh.pxd -> build\lib.win-amd64-3.5\pyzed
copying pyzed\types.pxd -> build\lib.win-amd64-3.5\pyzed
running build_ext
building 'pyzed.defines' extension
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\pyzed
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\Standard\AppData\Local\Programs\Python\Python35\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\ZED SDK\include" "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0/include" -IC:\Users\Standard\AppData\Local\Programs\Python\Python35\include -IC:\Users\Standard\AppData\Local\Programs\Python\Python35\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tppyzed/defines.cpp /Fobuild\temp.win-amd64-3.5\Release\pyzed/defines.obj
defines.cpp
pyzed/defines.cpp(4675): error C2039: 'MEASURE_NORMALS': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4675): error C2065: 'MEASURE_NORMALS': undeclared identifier
pyzed/defines.cpp(4687): error C2039: 'MEASURE_DISPARITY_RIGHT': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4687): error C2065: 'MEASURE_DISPARITY_RIGHT': undeclared identifier
pyzed/defines.cpp(4699): error C2039: 'MEASURE_DEPTH_RIGHT': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4699): error C2065: 'MEASURE_DEPTH_RIGHT': undeclared identifier
pyzed/defines.cpp(4711): error C2039: 'MEASURE_XYZ_RIGHT': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4711): error C2065: 'MEASURE_XYZ_RIGHT': undeclared identifier
pyzed/defines.cpp(4723): error C2039: 'MEASURE_XYZRGBA_RIGHT': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4723): error C2065: 'MEASURE_XYZRGBA_RIGHT': undeclared identifier
pyzed/defines.cpp(4735): error C2039: 'MEASURE_XYZBGRA_RIGHT': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4735): error C2065: 'MEASURE_XYZBGRA_RIGHT': undeclared identifier
pyzed/defines.cpp(4747): error C2039: 'MEASURE_XYZARGB_RIGHT': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4747): error C2065: 'MEASURE_XYZARGB_RIGHT': undeclared identifier
pyzed/defines.cpp(4759): error C2039: 'MEASURE_XYZABGR_RIGHT': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4759): error C2065: 'MEASURE_XYZABGR_RIGHT': undeclared identifier
pyzed/defines.cpp(4771): error C2039: 'MEASURE_NORMALS_RIGHT': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4771): error C2065: 'MEASURE_NORMALS_RIGHT': undeclared identifier
pyzed/defines.cpp(4964): error C2039: 'VIEW_NORMALS': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4964): error C2065: 'VIEW_NORMALS': undeclared identifier
pyzed/defines.cpp(4976): error C2039: 'VIEW_DEPTH_RIGHT': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4976): error C2065: 'VIEW_DEPTH_RIGHT': undeclared identifier
pyzed/defines.cpp(4988): error C2039: 'VIEW_NORMALS_RIGHT': is not a member of 'sl'
C:\Program Files (x86)\ZED SDK\include\sl/defines.hpp(106): note: see declaration of 'sl'
pyzed/defines.cpp(4988): error C2065: 'VIEW_NORMALS_RIGHT': undeclared identifier
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2

Help regarding this would really be appreciated.

Thanks,
Roy.

Swallowing up memory

I've noticed some memory issues with my ZED. I'm doing a project where I need a camera to run continuously for days or even more than that. But when I run the program it crashes after a 45 minutes. I've discovered that the problem have something to do with the "zed.grab()" function.

I've even tried using your Tutorial: Image capture to test if the same issue happens and it does. If i change the code so it run continuously instead of just taking 50 images then it will continue to eat up memory.

I'm watching the memory by using the linux top command.

Is there a method to clear the memory grab() is using?

Any help is more than welcome!

Using the ZED SDK without an svo file

@obraun-sl Hi Oliver!

Is it possible to pass the right and left images through the ZED SDK as if simulating reading an svo?

I have a situation where I do not have access to the ZED camera itself and some data was recorded on a ZED camera (with known calibration). Left and right image pairs themselves were stored but not in an svo.

PyMat.get_data type conversion error

Hi,

when trying to retrieve the data from a depth map via PyMat.get_data(), the return data type is derived incorrectly. I've traced it down to these lines in pyzed/core.pyx:

391:        if self.mat.getDataType() == MAT_TYPE_8U_C1 or MAT_TYPE_8U_C2 or MAT_TYPE_8U_C3 or MAT_TYPE_8U_C4:
392:            size = self.mat.getHeight()*self.mat.getWidth()*self.mat.getChannels()
393:            dtype = np.uint8
394:        elif self.mat.getDataType() == MAT_TYPE_32F_C1 or MAT_TYPE_32F_C2 or MAT_TYPE_32F_C3 or MAT_TYPE_32F_C4:
395:            size = self.mat.getHeight()*self.mat.getWidth()*self.mat.getChannels()*sizeof(float)
396:            dtype = np.float32

The comparison on line 391 always evaluate to True (the same holds for line 394, but that one is never executed). As a result, the size and type are calculated incorrectly for floating point data.

I suppose that was was really meant, is something like this:

391:        if self.mat.getDataType() in (MAT_TYPE_8U_C1, MAT_TYPE_8U_C2, MAT_TYPE_8U_C3, MAT_TYPE_8U_C4):
            ...
394:        elif self.mat.getDataType() in (MAT_TYPE_32F_C1, MAT_TYPE_32F_C2, MAT_TYPE_32F_C3, MAT_TYPE_32F_C4):
            ...

With this fix, I can retrieve the floating point depth map data correctly.

Best regards,
Eddy

"Error: Unable to find vcvarsall.bat" while building 'pyzed.defines' (Running the setup.py on windows)

Hello,
As mentioned in the title i am trying to run the setup.py and get the error: unable to find vcvarsall.bat. Find the whole log below.

I have already checked/tried/done the following:

  • installed/updated cython
  • installed visual studio 2017

thank you very much in advance
and kind regards


C:\Users\wdeti\Desktop\ZED\zed-python>python setup.py build
ZED SDK Version: OK
compilation flags:
include dirs: ['Q:\Programs\Python\Python36\lib\site-packages\numpy\core\include', 'C:\Program Files (x86)\ZED SDK/include', 'Q:\NVIDIA\CUDA v9.1\Development/include']
library dirs: ['Q:\Programs\Python\Python36\lib\site-packages\numpy\core\include', 'C:\Program Files (x86)\ZED SDK/lib', 'Q:\NVIDIA\CUDA v9.1\Development/lib/x64']
libraries: ['sl_core64', 'sl_zed64']
Building module: ('pyzed.defines', ['pyzed/defines.pyx'])
Compiling pyzed/defines.pyx because it changed.
[1/1] Cythonizing pyzed/defines.pyx
Building module: ('pyzed.types', ['pyzed/types.pyx'])
Compiling pyzed/types.pyx because it changed.
[1/1] Cythonizing pyzed/types.pyx
Building module: ('pyzed.core', ['pyzed/core.pyx'])
Compiling pyzed/core.pyx because it changed.
[1/1] Cythonizing pyzed/core.pyx
Building module: ('pyzed.mesh', ['pyzed/mesh.pyx'])
Compiling pyzed/mesh.pyx because it changed.
[1/1] Cythonizing pyzed/mesh.pyx
Building module: ('pyzed.camera', ['pyzed/camera.pyx'])
Compiling pyzed/camera.pyx because it changed.
[1/1] Cythonizing pyzed/camera.pyx
running build
running build_py
running build_ext
building 'pyzed.defines' extension
error: Unable to find vcvarsall.bat

Solution for "No module named 'pyzed.camera'"

Win10: build & install are OK.
pyzed can be imported, but importing pyzed.* is failed.
The following solution may be useful (It works for me):

  1. move the setup.py to pyzed folder.
  2. change something in setup.py(delete the 'pyzed' and change 'py_packages = ["."]' and 'package_data = {"." : ["*.pxd"]}').
  3. build and install again.

Error: you must install the ZED SDK.

When I run setup.py build, I got this error.
However, I have installed ZED SDK for severl times. I am sure I installed it successfully because I can run the examples.
Anyon have some ideas? Thanks!
By the way, I am using Win10 and the prerequisites are satisfied.

Recorded SVO random access

Hi, is there a way to access images in the SVO randomly? This is a common use case if I am using a recorded SVO interactively in Jupyter or Ipython.

My current way is to run cam.grab() repeatedly (the required number of times) to move forward and re-load the camera object if I must move back.

Best,
Abhijat

Set Mat Type

Hi,

I'm trying to get a 32 bit depth map in python. To do so, when I initialize my Mat() I set those parameters :

mat = core.PyMat(	
			width = cam.get_resolution().width,
			height = cam.get_resolution().height,
			mat_type = core.PyMAT_TYPE.PyMAT_TYPE_32F_C1,
			memory_type = core.PyMEM.PyMEM_CPU
		)

However, when I run :
print(mat.get_data_type())

I still get PyMAT_TYPE.PyMAT_TYPE_8U_C4

Any ideas why ?

Point Cloud data access

Hi,
I am trying to manipulate some robots using the zed camera and due to this I need the XYZ coordinates with respect to the camera. I am able to retrieve it using the retrieve_measure function but since multiple robots are functioning simultaneouly I need the data to be shared between different processes.

But, unfortunately, the data is not flowing in properly, so I though I would retrieve the data from this variable and store it as a numpy array and share it. My problem is that I am unable to understand the difference between the get_data and get_value_functions i.e.

point_cloud.get_data()[600][400]
array([172, 191, 15, 197], dtype=uint8)
point_cloud.get_value(600,400)
(Error code: Success, array([ -232.36811829, 226.42419434, 3275.38720703, nan]))

The pixel values has to be given as arguments.
What do the get_data and get_value signify, since there is no documentation about get_data fnction in the Mat class of the API documentation?

Regards,
Roy.

Could I share my CUDA context with a PyZEDCamera?

Though the ZED SDK provides a way to share my CUDA context with a ZED camera,
it seems that the current version of its python wrapper lacks it:

  • InitParameters::sdk_cuda_ctx
  • Camera::getCUDAContext

Is there any way to share my context with a PyZEDCamera?
I'm grad if ZED cameras could be used in CUDA applications developed on python.

Compilation error when running python setup.py build

Getting this error when running setup.py build...

pyzed/defines.cpp:507:24: fatal error: sl/types.hpp: No such file or directory
compilation terminated.

ubuntu 16.04
zed sdk 2.2
cython 0.26
cuda 8

All the sdk examples and tools run fine.

error on building the zed sdk for python

I have tried to open the stereo video .svo file in python.
I have download the zed-sdk 2.1(for windows 64x) and then tried to build the zed-python package.
But I got error like as follow.
I think I installed the SDK and I can display the .svo file with zed explorer.exe

E:\work\SVO\zed-python>python` setup.py build
Compiling pyzed/defines.pyx because it changed.
[1/1] Cythonizing pyzed/defines.pyx
Compiling pyzed/types.pyx because it changed.
[1/1] Cythonizing pyzed/types.pyx
Compiling pyzed/core.pyx because it changed.
[1/1] Cythonizing pyzed/core.pyx

Error compiling Cython file:
------------------------------------------------------------

        bool save(types.String filename)
        bool load(types.String filename)


    cdef cppclass SpatialMappingParameters 'sl::SpatialMappingParameters':
        ctypedef pair[float, float] interval
       ^
------------------------------------------------------------

pyzed\camera.pxd:117:8: Expected an identifier, found 'ctypedef'

Error compiling Cython file:
------------------------------------------------------------

        bool save(types.String filename)
        bool load(types.String filename)


    cdef cppclass SpatialMappingParameters 'sl::SpatialMappingParameters':
        ctypedef pair[float, float] interval
                                   ^
------------------------------------------------------------

pyzed\camera.pxd:117:36: Syntax error in C variable declaration

Error compiling Cython file:
------------------------------------------------------------

    def right_cam(self):
        return self.py_right_cam


cdef class PyCameraInformation:
    def __cinit__(self, camera.PyZEDCamera py_camera, PyResolution resizer):
                       ^
------------------------------------------------------------

pyzed\core.pyx:162:24: 'PyZEDCamera' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------

cdef class PyCameraInformation:
    def __cinit__(self, camera.PyZEDCamera py_camera, PyResolution resizer):
        res = Resolution(resizer.width, resizer.height)
        self.py_calib = PyCalibrationParameters()
        self.py_calib.calibration = py_camera.camera.getCameraInformation(res).calibration_parameters
                                                                             ^
------------------------------------------------------------

pyzed\core.pyx:165:78: Cannot convert Python object to 'CalibrationParameters'

Error compiling Cython file:
------------------------------------------------------------

    def __cinit__(self, camera.PyZEDCamera py_camera, PyResolution resizer):
        res = Resolution(resizer.width, resizer.height)
        self.py_calib = PyCalibrationParameters()
        self.py_calib.calibration = py_camera.camera.getCameraInformation(res).calibration_parameters
        self.py_calib_raw = PyCalibrationParameters()
        self.py_calib_raw.calibration = py_camera.camera.getCameraInformation(res).calibration_parameters_raw
                                                                                 ^
------------------------------------------------------------

pyzed\core.pyx:167:82: Cannot convert Python object to 'CalibrationParameters'
Traceback (most recent call last):
  File "setup.py", line 149, in <module>
    extList = cythonize(create_extension(mod[0], mod[1]), compiler_directives=cython_directives)
  File "C:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 915, in cythonize
    cythonize_one(*args)
  File "C:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 1037, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: pyzed/core.pyx 

Inconsistent frame grabbing performance

Hi,
I am using the zed with a jetson TX2, with jetpack 3.2, zed sdk 2.3.3, python 3.5. I have noticed that when using the zed python library, sometimes the camera lags very badly, and the grab() function may take as long as 300 ms to run. Usually from my measurements it takes around 30 ms for the grab function to run, but the time fluctuates a lot and is usually above that. I am using 720p resolution, and performance depth mode. I am trying to track an object in real time with the camera, so this lag from the camera is causing major problems for me. Is there any way to increase the performance of camera and make it more consistent?

Thanks

Can't use with TensorFlow

I would like to be able to use the ZED camera with the TensorFlow libraries in Python but cannot with zed-python because of version support mismatch.

ZED SDK 2.2.1 only supports CUDA 9, though 2.2.0 supports CUDA 8.
TensorFlow only supports CUDA 8.

zed-python can be built with ZED SDK 2.2.0, but when I try to open a pyzed.camera I get the following error:

ZED (Init) >> ERROR: Executable was designed for a newer version of the SDK.
EXE v2.2.1 / installed v2.2.0

Is there any solution?

Import Error : Libcudaart.8.0 not found, when installed on ubuntu 16.04 - CUDA 9.0

Hi,
I have installed CUDA 9.0 , and built the python setup file, by pointing to cuda installed path.(/usr/local/CUDA 9.0/ )
The build was successful, but whn i try to run live_camer.py, following throws up :
" Traceback (most recent call last):
File "live_camera.py", line 27, in
import pyzed.camera as zcam
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory "

I think it is related to CUDA 8 being taken as default cuda version,
can you please check into this, and give some alternative. Thanks in advance

ERROR : Found CUDA 8.0 but the ZED SDK requires 9.0

Hi, I want to use ZED with jetpack3.1. I download the ZED_SDK_Linux_JTX2_v2.3.3_JP3.1run file. When I install the run file, I got the following error:
ERROR : Found CUDA 8.0 but the ZED SDK requires 9.0.
It's wired because I download the run file which support Jetpack 3.1 with cuda 8, how could it requires 9.0?

cl.exe not found

When attempting to install within an Anaconda environment, the script errored out because it could not find cl.exe

I addressed this by:

  1. Launch Anaconda Prompt with administrator privleges
  2. Execute C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat

Leaving this in case anyone else comes across similar issues

AttributeError: module 'pyzed.camera' has no attribute 'PyCameraInformation'

Hi, I want to use the calibration parameters fx and fy of the cameras. I tried to get them through PyCameraInformation class.

import pyzed.camera as zcam
import pyzed.types as tp
def main():
zed = zcam.PyZEDCamera()
init_params = zcam.PyInitParameters()
cam_params = zcam.PyCameraInformation()
init_params.sdk_verbose = False
err = zed.open(init_params)
if err != tp.PyERROR_CODE.PySUCCESS:
exit(1)
zed_serial = zed.get_camera_information().serial_number
print("Hello! This is my serial number: {0}".format(zed_serial))
print("camera parameters",zed.cam_params.py_calib)
zed.close()
if name == "main":
main()

the coded ended with error
ran hello_zed.py example and the code ended with this error
AttributeError: module 'pyzed.camera' has no attribute 'PyCameraInformation' . can you tell how to access the camera parameters, fx and fy of individual left and right camera.

ImportError: No module named camera

Hello, thanks for the project. While I try to execute example and tutorial code, all of them prompt same kind of error. Take positional_tracking as an example:
Traceback (most recent call last):
File "positional_tracking.py", line 21, in <module>
import pyzed.camera as zcam
ImportError: No module named camera

I doubt it is because of different python version(I use python 2.7 and this project require me to use python 3.5+). If it is the reason, I would like to ask is there any method to solve this issue without updating python? If it is not, how could I solve this issue?

Thank you

delay when live_camera.py is run for live video feed (JetsonTX2)

Zed Explorer give fast and real time live video feed but, when we run live_camera python script it gives delayed live video feed which is bad for for my application.
Is there any way I can improve its speed or if I can access the source code of ZED Explorer.
I am running this on JetsonTX2?

Thanks

GPU-CPU sync issues in real time object detection project

Hi there,

I have met some problem when using zed camera in real time object detection projects.
In the project, images are read in and processed with deep neural networks in real time.

The project is based on Nvidia Jetson TX2 board and connect with a zed camera.
It uses cuda 8.0, cudnn 5.1, and tensorflow 1.3

When I run it, some sync problems happen and shows the following error message:

  • Aborted. GPU sync failed.
  • Killed

I would like to know how to apply zed camera in such projects to avoid the GPU- CPU sync
issues.

The main code is as follows:

# Create a PyZEDCamera object
zed = zcam.PyZEDCamera()

# Create a PyInitParameters object and set configuration parameters
init_params = zcam.PyInitParameters(svo_real_time_mode=False)
init_params.camera_resolution = sl.PyRESOLUTION.PyRESOLUTION_VGA
init_params.camera_fps = 1 

# Open the camera
err = zed.open(init_params)
if err != tp.PyERROR_CODE.PySUCCESS:
    print("-----------Cannot open camera---------")
    print(err)
    exit(1)

img = core.PyMat()

while True:
    err = zed.grab(zcam.PyRuntimeParameters()) 
    if err == tp.PyERROR_CODE.PySUCCESS:
        zed.retrieve_image(img, sl.PyVIEW.PyVIEW_LEFT)
        img = img.get_data() # convert to ndarray
        img = img[:, :, :3] 
        print(img.shape)

        # object detection
  ......
    else:
        break

Thanks very much.

Reduced field of view when using retrieve_image

I found that the field of view of the camera is reduced when using retrieve_image when comparing with the direct use of the ZED SDK application. This behavior is also found on the example of live_camera.py.

However, when using OpenCV's VideoCapture I can obtain the image with the full field of view.

Can you help me solve this problem?

error on jetson tx2

Hello,

Did you succeed to install zed-python on Jetson TX2?
When running python3 setup.py build, I get many errors like this one:
error: using typedef-name ‘sl::MeshFilterParameters::FILTER’ after ‘enum’

  • gcc: 5.4.0
  • python: 3.5.2
  • cython: 0.26.1 (tried 0.26.0 but same error)
  • numpy: 1.13.1
  • Ubuntu 16.04

Thanks for your help,
Emmanuel

Found CUDA 9.0 but the ZED SDK requires 8.0

Hi. I am on jetson tx2 with jetpack 3.2. This version of jetpack comes with cuda 9 but when i try to install zed sdk 2.3 version i got an error saying that "Found CUDA 9.0 but the ZED SDK requires 8.0". Isn't this version of zed sdk comes with a support of cuda 9 or am i missing something?

Anyone has ideas? Thanks

Slow Response Time

Hi,
I am currently working on a project that involves using the zed for collision avoidance of an autonomous robot. When I run the example that come with the zed sdk, there is almost no lag in showing the depth image. However when I run the python example for a depth image, there is a noticeable amount of lag between movement and displaying the image. I have the depth mode set to performance, so I am not sure if this is just because running the code in python is slower, or if there is a setting im missing that could improve the response time.

Cannot get depth image using OpenCV API

Hi there,

The following code provided by @adujardin can read images in a light manner. But it cannot get depth image. I just wonder whether we can get the depth image using OpenCV APIs.

It is part of #28, but I opened a new issue since it is a different topic.

import numpy as np
import cv2

cap = cv2.VideoCapture(0) # depending on the ZED ID

while(True):
    ret, frame = cap.read() # Capture SbS frames
    height, width = frame.shape[:2]
    left = frame[0:height,0:int(width*0.5)] # Extract the left img

    # object detection
    .......

# Release the capture
cap.release()
cv2.destroyAllWindows()

Thanks very much.

Spatial Mapping

In spatial mapping, the zed.disable_tracking() command errors out, requiring an argument

Using zed-python on the Jetson TX1 platform conflicts with OpenCV version

Hi,
I would like zed-python on the Jetson TX1 platform, but I can't figure out how.
Jetson TX1 can come with its own optimized OpenCV libraries, and this might one of my problems.

I build the zed-python plugin with Python3.5, which seems to go fine.
I can run the 'hello_zed.py' example and I get the serial number, so everything seems fine.
But, when I try to use the 'live_camera.py'example, python3.5 cant find the cv2 module (the OpenCV python binding).
If I use python2, I can use the cv2 module, but now I can't use the zed-python plug in.
What would be your recommendation on using zed-python plugin, OpenCV and JTX1?
Do I stick to Python2 (and try to build zed-python by Python2)?
Will zed-python work with Python2 (requirements says Python3.5)?
Can I stick with libopencv4tegra / libopencv4tegra-python ? Or do I need to build OpenCV from source ( and loose optimization)?

Error building pthon wrapper on Windows

I have Zed Sdk 2.1 with the following platform:
('64bit', 'WindowsPE')

When I try to run:
python setup.py build

I get the following error:

PS C:\Users\Adam\zed-python> python setup.py build
Compiling pyzed/defines.pyx because it changed.
[1/1] Cythonizing pyzed/defines.pyx
Compiling pyzed/types.pyx because it changed.
[1/1] Cythonizing pyzed/types.pyx
Compiling pyzed/core.pyx because it changed.
[1/1] Cythonizing pyzed/core.pyx

Error compiling Cython file:
------------------------------------------------------------

        bool save(types.String filename)
        bool load(types.String filename)


    cdef cppclass SpatialMappingParameters 'sl::SpatialMappingParameters':
        ctypedef pair[float, float] interval
       ^
------------------------------------------------------------

pyzed\camera.pxd:117:8: Expected an identifier, found 'ctypedef'

Error compiling Cython file:
------------------------------------------------------------

        bool save(types.String filename)
        bool load(types.String filename)


    cdef cppclass SpatialMappingParameters 'sl::SpatialMappingParameters':
        ctypedef pair[float, float] interval
                                   ^
------------------------------------------------------------

pyzed\camera.pxd:117:36: Syntax error in C variable declaration

Error compiling Cython file:
------------------------------------------------------------

    def right_cam(self):
        return self.py_right_cam


cdef class PyCameraInformation:
    def __cinit__(self, camera.PyZEDCamera py_camera, PyResolution resizer):
                       ^
------------------------------------------------------------

pyzed\core.pyx:162:24: 'PyZEDCamera' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------


cdef class PyCameraInformation:
    def __cinit__(self, camera.PyZEDCamera py_camera, PyResolution resizer):
        res = Resolution(resizer.width, resizer.height)
        self.py_calib = PyCalibrationParameters()
        self.py_calib.calibration = py_camera.camera.getCameraInformation(res).calibration_parameters
                                                                             ^
------------------------------------------------------------

pyzed\core.pyx:165:78: Cannot convert Python object to 'CalibrationParameters'

Error compiling Cython file:
------------------------------------------------------------

    def __cinit__(self, camera.PyZEDCamera py_camera, PyResolution resizer):
        res = Resolution(resizer.width, resizer.height)
        self.py_calib = PyCalibrationParameters()
        self.py_calib.calibration = py_camera.camera.getCameraInformation(res).calibration_parameters
        self.py_calib_raw = PyCalibrationParameters()
        self.py_calib_raw.calibration = py_camera.camera.getCameraInformation(res).calibration_parameters_raw
                                                                                 ^
------------------------------------------------------------

pyzed\core.pyx:167:82: Cannot convert Python object to 'CalibrationParameters'
Traceback (most recent call last):
  File "setup.py", line 149, in <module>
    extList = cythonize(create_extension(mod[0], mod[1]), compiler_directives=cython_directives)
  File "C:\Users\Adam\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 915, in cythonize
    cythonize_one(*args)
  File "C:\Users\Adam\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 1037, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: pyzed/core.pyx

Can't build plugin, tried all suggestions

I've been trying to build the python wrapper for the ZED SDK. I've seen other people have similar issues and tried their solutions, but haven't made any progress. Regardless of what I do I get the "Error: you must install the ZED SDK."

Here are the things I've tried:

checked Cython >=.26
checked python.exe is the 64 bit version
uninstalled and reinstalled latest SDK twice

I originally downloaded the plugin to my project folder, so I also tried to:
move location of zed-python to ...\plugins folder of SDK
move location of zed-python to ...\Anaconda3\Lib\site-packages

And every time I ran setup.py, from wherever I ran it, it didn't think that the ZED SDK was installed.

Any ideas? The SDK tools for this camera are cool, but if I can't use the python wrapper it's sort of just an expensive toy...

Running python 3.5 on windows 10 64 bit with CUDA 9.0 and VS 2015

Saving and loading Depth data from FS

I am using the ZED as input for MV algorithm.
I first analyze the RGB image, and then (after quite a while) I get back X, Y values for which I need the Z value (from the depth/point cloud).
What would be the best way to do that? Moreover, if I want to reprocess my data, do I have a way to get the Z value retroactively from a saved depth/point-cloud file, and if so, how would I save my Mat to the FS so that I can retrieve it later?

Thanks!

Ability to set custom range

Using the commands PyRANGE_FAR, MEDIUM, and NEAR result in distances of 2, 1, and 0. I would like to be able to pass in a value. How is this done?

spatial.set_range(range=zcam.PyRANGE.PyRANGE_FAR)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.