Error while running get_python_api.py

C:\Windows\System32>pip install PyOpenGL PyOpenGL_accelerate --only-binary :all:
Looking in indexes: Simple index, https://pypi.ngc.nvidia.com
Requirement already satisfied: PyOpenGL in c:\users\tarangmehta\appdata\local\programs\python\python312\lib\site-packages (3.1.6)
Requirement already satisfied: PyOpenGL_accelerate in c:\users\tarangmehta\appdata\local\programs\python\python312\lib\site-packages (3.1.6)

C:\Windows\System32>“C:\Program Files (x86)\ZED SDK\get_python_api.py”
→ Downloading to ‘C:\Windows\System32’
Detected platform:
win_amd64
Python 3.12
ZED SDK 4.1
→ Checking if https://download.stereolabs.com/zedsdk/4.1/whl/win_amd64/pyzed-4.1-cp312-cp312-win_amd64.whl exists and is available
→ Found ! Downloading python package into C:\Windows\System32\pyzed-4.1-cp312-cp312-win_amd64.whl
→ Installing necessary dependencies
Looking in indexes: Simple index, https://pypi.ngc.nvidia.com
Requirement already satisfied: numpy in c:\users\tarangmehta\appdata\local\programs\python\python312\lib\site-packages (1.26.4)
Looking in indexes: Simple index, https://pypi.ngc.nvidia.com
Processing c:\windows\system32\pyzed-4.1-cp312-cp312-win_amd64.whl
Collecting numpy<2.0,>=1.13 (from pyzed==4.1)
Downloading numpy-1.26.4-cp312-cp312-win_amd64.whl.metadata (61 kB)
Collecting cython>=3.0.0 (from pyzed==4.1)
Downloading Cython-3.0.11-cp312-cp312-win_amd64.whl.metadata (3.2 kB)
Downloading Cython-3.0.11-cp312-cp312-win_amd64.whl (2.8 MB)
---------------------------------------- 2.8/2.8 MB 10.1 MB/s eta 0:00:00
Downloading numpy-1.26.4-cp312-cp312-win_amd64.whl (15.5 MB)
---------------------------------------- 15.5/15.5 MB 14.4 MB/s eta 0:00:00
Installing collected packages: numpy, cython, pyzed
Successfully installed cython-3.0.11 numpy-1.26.4 pyzed-4.1
Done
Installing OpenGL dependencies required to run the samples
→ Downloading PyOpenGL-3.1.6-cp312-cp312-win_amd64.whl
Looking in indexes: Simple index, https://pypi.ngc.nvidia.com
Processing c:\windows\system32\pyopengl-3.1.6-cp312-cp312-win_amd64.whl
ERROR: Wheel ‘pyopengl’ located at C:\Windows\System32\PyOpenGL-3.1.6-cp312-cp312-win_amd64.whl is invalid.
→ Downloading PyOpenGL_accelerate-3.1.6-cp312-cp312-win_amd64.whl
Looking in indexes: Simple index, https://pypi.ngc.nvidia.com
Processing c:\windows\system32\pyopengl_accelerate-3.1.6-cp312-cp312-win_amd64.whl
ERROR: Wheel ‘pyopengl-accelerate’ located at C:\Windows\System32\PyOpenGL_accelerate-3.1.6-cp312-cp312-win_amd64.whl is invalid.
Pyzed directory is C:\Users\TarangMehta\AppData\Local\Programs\Python\Python312\Lib\site-packages

Hello All,
I am facing error while running the get_python_api. This error leads to error while running all the codes in sample folders. I can run all the tutorial files and it works.

Can anyone help me?

I also tried pip install PyOpenGL PyOpenGL_accelerate --only-binary :all:
This show that

C:\Windows\System32>pip install PyOpenGL PyOpenGL_accelerate --only-binary :all:
Looking in indexes: Simple index, https://pypi.ngc.nvidia.com
Requirement already satisfied: PyOpenGL in c:\users\tarangmehta\appdata\local\programs\python\python312\lib\site-packages (3.1.6)
Requirement already satisfied: PyOpenGL_accelerate in c:\users\tarangmehta\appdata\local\programs\python\python312\lib\site-packages (3.1.6)

But running get_python_api is giving error.

I am not from coding background so dont know much.

Looking forward to some help.

Regards.

Hi @tmehta,

If you are able to run all of the python scripts normally, then you should not worry too much about this error, the requirement is optional.

Hello @mattrouss
when i changed the python to 3.10 it works without getting error.

But now i am not able to run few examples like body tracking samples or auomatic region of interst etc.

here is the error message for automatic region of interest.
= RESTART: C:\Program Files (x86)\ZED SDK\samples\depth sensing\automatic region of interest\python\automatic_region_of_interest.py
[Sample] Using default resolution
Press ‘a’ to apply the ROI
Press ‘r’ to reset the ROI
Press ‘s’ to save the ROI as image file to reload it later
Press ‘l’ to load the ROI from an image file
Traceback (most recent call last):
File “C:\Program Files (x86)\ZED SDK\samples\depth sensing\automatic region of interest\python\automatic_region_of_interest.py”, line 173, in
main()
File “C:\Program Files (x86)\ZED SDK\samples\depth sensing\automatic region of interest\python\automatic_region_of_interest.py”, line 108, in main
roi_param.auto_apply = True
AttributeError: ‘pyzed.sl.RegionOfInterestParameters’ object has no attribute ‘auto_apply’

Can you please help on why some examples are not working?

Thank you for reporting this, this specific sample has not been updated as the API for RegionOfInterestParameters has changed in 4.1.

The attribute auto_apply has changed to auto_apply_module and is now an enum.

I will log this internally so we can update the sample.

Hello @mattrouss ,
Thank you for the reply will try to change. I have tried the code and get the new error now:
ZED SDK/samples/depth sensing/automatic region of interest/python/automatic_region_of_interest.py"
[Sample] Using default resolution
[2024-08-29 06:55:49 UTC][ZED][INFO] Logging level INFO
[2024-08-29 06:55:50 UTC][ZED][INFO] Using USB input… Switched to default resolution HD720
[2024-08-29 06:55:52 UTC][ZED][INFO] [Init] Depth mode: NEURAL
[2024-08-29 06:55:52 UTC][ZED][INFO] [Init] Camera successfully opened.
[2024-08-29 06:55:52 UTC][ZED][INFO] [Init] Camera FW version: 1523
[2024-08-29 06:55:52 UTC][ZED][INFO] [Init] Video mode: HD720@60
[2024-08-29 06:55:52 UTC][ZED][INFO] [Init] Serial Number: S/N 35084232
Press ‘a’ to apply the ROI
Press ‘r’ to reset the ROI
Press ‘s’ to save the ROI as image file to reload it later
Press ‘l’ to load the ROI from an image file
Traceback (most recent call last):
File “c:\Program Files (x86)\ZED SDK\samples\depth sensing\automatic region of interest\python\automatic_region_of_interest.py”, line 173, in
main()
File “c:\Program Files (x86)\ZED SDK\samples\depth sensing\automatic region of interest\python\automatic_region_of_interest.py”, line 108, in main
roi_param.auto_apply_module = True
File “pyzed\sl.pyx”, line 4072, in pyzed.sl.RegionOfInterestParameters.auto_apply_module.set
TypeError: ‘bool’ object is not iterable

Can you please check for all the sample codes? because maximum are not working. Can you please suggest the what should be changed in them? Or shall I individually report them?

The tutorials are working good.

Looking forward to your reply.

Regards.

The auto_apply_module attribute is now a list of sl.MODULE enums. The following should work:

    roi_param.auto_apply_module = [sl.MODULE.ALL]

We will update the sample accordingly, thank you for the report.

All samples in the latest branch main of our Github repository here: GitHub - stereolabs/zed-sdk: ⚡️The spatial perception framework for rapidly building smart robots and spaces should be functional with the latest version of the ZED SDK

If you find other errors, please share them here.

Hello @mattrouss ,
Still getting error.

PS C:\Program Files (x86)\ZED SDK> & C:/Users/TarangMehta/AppData/Local/Programs/Python/Python310/python.exe “c:/Program Files (x86)/ZED SDK/samples/depth sensing/automatic region of interest/python/automatic_region_of_interest.py”
[Sample] Using default resolution
[2024-08-29 11:12:37 UTC][ZED][INFO] Logging level INFO
[2024-08-29 11:12:38 UTC][ZED][INFO] Using USB input… Switched to default resolution HD720
[2024-08-29 11:12:39 UTC][ZED][INFO] [Init] Depth mode: NEURAL
[2024-08-29 11:12:40 UTC][ZED][INFO] [Init] Camera successfully opened.
[2024-08-29 11:12:40 UTC][ZED][INFO] [Init] Camera FW version: 1523
[2024-08-29 11:12:40 UTC][ZED][INFO] [Init] Video mode: HD720@60
[2024-08-29 11:12:40 UTC][ZED][INFO] [Init] Serial Number: S/N 35084232
Press ‘a’ to apply the ROI
Press ‘r’ to reset the ROI
Press ‘s’ to save the ROI as image file to reload it later
Press ‘l’ to load the ROI from an image file
Traceback (most recent call last):
File “c:\Program Files (x86)\ZED SDK\samples\depth sensing\automatic region of interest\python\automatic_region_of_interest.py”, line 173, in
main()
File “c:\Program Files (x86)\ZED SDK\samples\depth sensing\automatic region of interest\python\automatic_region_of_interest.py”, line 136, in main
cv2.imshow(imWndName, cvImage)
cv2.error: OpenCV(4.10.0) :-1: error: (-5:Bad argument) in function ‘imshow’

Overload resolution failed:

  • mat is not a numpy array, neither a scalar
  • Expected Ptrcv::cuda::GpuMat for argument ‘mat’
  • Expected Ptrcv::UMat for argument ‘mat’

Hello @mattrouss,
Can you please help? Apart from my previous errors, Here are few other errors.

Eg. for Body_tracking and object_detection_birds_view sample examples the error is as following

PS C:\Program Files (x86)\ZED SDK> & C:/Users/TarangMehta/AppData/Local/Programs/Python/Python310/python.exe “c:/Program Files (x86)/ZED SDK/zed-sdk-master/body tracking/body tracking/python/body_tracking.py”
Running Body Tracking sample … Press ‘q’ to quit, or ‘m’ to pause or restart
[Sample] Using default resolution
[2024-08-30 11:45:36 UTC][ZED][INFO] Logging level INFO
[2024-08-30 11:45:38 UTC][ZED][INFO] [Init] Depth mode: ULTRA
[2024-08-30 11:45:39 UTC][ZED][INFO] [Init] Camera successfully opened.
[2024-08-30 11:45:39 UTC][ZED][INFO] [Init] Camera FW version: 1523
[2024-08-30 11:45:39 UTC][ZED][INFO] [Init] Video mode: HD1080@30
[2024-08-30 11:45:39 UTC][ZED][INFO] [Init] Serial Number: S/N 35084232
Traceback (most recent call last):
File “c:\Program Files (x86)\ZED SDK\zed-sdk-master\body tracking\body tracking\python\body_tracking.py”, line 164, in
main()
File “c:\Program Files (x86)\ZED SDK\zed-sdk-master\body tracking\body tracking\python\body_tracking.py”, line 135, in main
cv_viewer.render_2D(image_left_ocv,image_scale, bodies.body_list, body_param.enable_tracking, body_param.body_format)
File “c:\Program Files (x86)\ZED SDK\zed-sdk-master\body tracking\body tracking\python\cv_viewer\tracking_viewer.py”, line 56, in render_2D
cv2.addWeighted(left_display, 0.9, overlay, 0.1, 0.0, left_display)
cv2.error: OpenCV(4.10.0) :-1: error: (-5:Bad argument) in function ‘addWeighted’

Overload resolution failed:

  • src1 is not a numpy array, neither a scalar
  • Expected Ptrcv::UMat for argument ‘src1’

What I see in common is error related to numpy. I have even reinstalled the pip for numpy and have same error.

I want to work further with camera but if i am not able to run the samples it basically hindering my learning. Can you please help?

Regards.

Hi @tmehta,

I believe this is an issue related specifically to Python on Windows, probably with numpy or opencv.

Can you please share the output of: pip freeze
To validate which versions of python packages you are using?

Hello @mattrouss ,

Here is the output of pip freeze,

PS C:\Program Files (x86)\ZED SDK> pip freeze
certifi==2024.7.4
charset-normalizer==3.3.2
colorama==0.4.6
contourpy==1.3.0
cycler==0.12.1
Cython==3.0.11
durationpy==0.7
filelock==3.15.4
fonttools==4.53.1
fsspec==2024.6.1
gpsdclient==1.3.2
idna==3.8
Jinja2==3.1.4
kiwisolver==1.4.5
MarkupSafe==2.1.5
matplotlib==3.9.2
mpmath==1.3.0
networkx==3.3
numpy==1.26.4
opencv-python==4.10.0.84
packaging==24.1
pandas==2.2.2
pillow==10.4.0
psutil==6.0.0
py-cpuinfo==9.0.0
PyOpenGL @ file:///C:/Windows/System32/PyOpenGL-3.1.6-cp310-cp310-win_amd64.whl#sha256=81d07740e83053ba5f896d5898c3ffbf8ad1ce6fbff6ee432e8c939743ca7048
PyOpenGL-accelerate @ file:///C:/Windows/System32/PyOpenGL_accelerate-3.1.6-cp310-cp310-win_amd64.whl#sha256=70ed3e2535677835d4bf0a93b48d2f34345ba9ef19c7b59ad9535fa55126bbdd
pyparsing==3.1.4
python-dateutil==2.9.0.post0
pytz==2024.1
PyYAML==6.0.2
pyzed==1.3.0
requests==2.32.3
scipy==1.14.1
seaborn==0.13.2
six==1.16.0
sympy==1.13.2
torch==2.4.0+cu121
torchaudio==2.4.0+cu121
torchvision==0.19.0+cu121
tqdm==4.66.5
typing_extensions==4.12.2
tzdata==2024.1
ultralytics==8.2.82
ultralytics-thop==2.0.5
urllib3==2.2.2
PS C:\Program Files (x86)\ZED SDK>

Thank you for sharing this information, we will try to reproduce the issue on our end.

In the meantime, could you try downgrading your opencv version to 4.5.4?

Hello @mattrouss ,
this solved the issue for now but i am not able use the Yolo files…

ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
ultralytics 8.2.82 requires opencv-python>=4.6.0, but you have opencv-python 4.5.4.60 which is incompatible.
Successfully installed opencv-python-4.5.4.60

Also i have one issue now. I am attaching the image but usual it should be live feed data. The object detection code doesn’t detect this object and this is my main goal to use such metal object to detect. They can be shiny or can be in gray colour. How do I make it detect? Can you please give some clue?

Because after object detection my next step is finding the depth and in case if it moves then finding a new location of the same object.

sorry for asking silly question but i am new and trying to learn from the example codes.

Regards

Hi @tmehta,

I would suggest trying to upgrade opencv-python to 4.6.0 which should also work with the ZED SDK.

To detect your own object classes for your use case, you will have to “retrain” Yolo, meaning that you can use the existing image analysis capabilities of the original model, and update the last layer(s) of weights so it is adapted to your objects.
To do this you will have to create a dataset with many of your own images of the different objects, and run the training scripts of yolo on this dataset.

Hello @mattrouss ,
Thank you for the help. Will try both the time and hope it works. Will update you later.

Regards.