openGL not functioning in depth_sensing sample of stereolabs

Hey I am Timo,
I am new to the stereocamera and have only some python experience. I am trying to make a pointcloud of the surface captured by my stereocamera. I used the code provided by stereolabs to create a live point cloud. This code can be found under samples → depth_sensing for python. I have installed all required packages, but the code does not run and gives the below output. I am not very good at python, but how do I fix this issue so that I can retrieve my depth map? Thanks in advance.

PS C:\Users\Timod\Documents\bestanden\TU Delft\zed\Zed python> & C:/Users/Timod/anaconda3/envs/zedpy/python.exe “c:/Users/Timod/Documents/bestanden/TU Delft/zed/Zed python/depth_sensingmap.py”
Running Depth Sensing sample … Press ‘Esc’ to quit
Press ‘s’ to save the point cloud
[Sample] Using default resolution
Traceback (most recent call last):
File “c:\Users\Timod\Documents\bestanden\TU Delft\zed\Zed python\depth_sensingmap.py”, line 121, in
main()
^^^^^^
File “c:\Users\Timod\Documents\bestanden\TU Delft\zed\Zed python\depth_sensingmap.py”, line 90, in main
viewer.init(1, sys.argv, camera_model, res)
File “c:\Users\Timod\Documents\bestanden\TU Delft\zed\Zed python\viewer.py”, line 229, in init
glutInit(_argc, _argv)
File “C:\Users\Timod\anaconda3\envs\zedpy\Lib\site-packages\OpenGL\GLUT\special.py”, line 333, in glutInit
_base_glutInit( ctypes.byref(count), holder )
File “C:\Users\Timod\anaconda3\envs\zedpy\Lib\site-packages\OpenGL\platform\baseplatform.py”, line 423, in call
raise error.NullFunctionError(
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling

Hello @Timo, welcome to the forums!

You may need to update PyOpenGL, you can find the latest versions here.
(I’m mostly quoting this Github answer)

Replace “37” with your Python version (310 for 3.10 for instance), and download:

  • PyOpenGL‑3.1.5‑cp37‑cp37m‑win_amd64.whl
  • PyOpenGL_accelerate‑3.1.5‑cp37‑cp37m‑win_amd64.whl

Then install them (in your env):
python3 -m pip install PyOpenGL_XXXX.whl

Thank you very much for your answer. Unfortunately, I have downloaded the right version of PyOpenGL and I tested this with a friend of mine, but still the same error occurs. How can I check which version I have installed, maybe that way I can double check. If I do have the correct version, is there something else that could be wrong?
Thank you very much,
Timo

@Timo
You can use pip show pyopengl to see the version.

What version of Python are you using?
Also, to confirm, you’re just trying to run the sample from the SDK, unmodified?

Hello,
I checked and the pyopengl version I have is 3.1.7. and the python version that I use is 3.11.8. I am trying to run the SDK sample. The depth_sensing sample I am trying to get working is from the following link: zed-sdk/depth sensing/depth sensing/python at master · stereolabs/zed-sdk · GitHub
I did not modify it or anything. I am only trying to run the unedited file. I have also copied the ogl_viewer file so that is also in the same folder as the code. Hopefully this helps you to understand the problem.
Thank you, hopefully you know what to do next,
Timo

Hello Timo,

I quickly checked on my side and while I don’t have a definite fix, for some reason it works with Python 3.10 but not Python 3.11.
Can you try with a 3.10 version in your environment?

Edit: It could be a freeglut install issue: python - PyOpenGL glutInit NullFunctionError - Stack Overflow

Thank you very much for your help! Using python 3.10 definitely works and I will use that for my experiments.

1 Like