Hoping someone can point me in the right direction. I’ve got an Arducam TOF camera connected to a Raspberry Pi 4B, running Raspbian Bullseye 64-bit with Python 3.9.2. I followed the Arducam ToF Camera SDK documentation, built the C++ examples with ./compile.sh, and those all work fine — the windows open and show the depth/preview data normally.
The problem is the Python examples. Both capture_raw.py and preview_depth.py crash with OpenCV highgui errors. capture_raw.py dies at line 18 on cv2.imshow, and preview_depth.py dies at line 63 on cv2.namedWindow. Both end with ‘terminate called without an active exception’ and ‘Aborted’.
Since the C++ examples work, the camera and SDK seem fine — this looks like something specific to the Python/OpenCV side, but I can’t pin it down.
Thanks for the report. Could you paste the full tracebacks from both scripts? The exact OpenCV error code and the line in window.cpp will tell us a lot here — especially whether the message mentions ‘function is not implemented’.
Sure, here’s capture_raw.py first. It fails at line 18 on:
cv2.imshow(“window”, buf.astype(np.float32))
Full output:
Traceback (most recent call last):
File “/home/toffeepi/projects/tof/Arducam_tof_camera/example/python/capture_raw.py”, line 18, in
cv2.imshow(“window”, buf.astype(np.float32))
cv2.error: OpenCV(4.8.1) /tmp/pip-install-9il7ttky/opencv-python_002ce5ffa4984379960fb4ec4387bbd4/opencv/modules/highgui/src/window.cpp:1272: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function ‘cvShowImage’
terminate called without an active exception
Aborted
Traceback (most recent call last):
File “/home/toffeepi/projects/tof/Arducam_tof_camera/example/python/preview_depth.py”, line 63, in
cv2.namedWindow(“preview”, cv2.WINDOW_AUTOSIZE)
cv2.error: OpenCV(4.8.1) /tmp/pip-install-9il7ttky/opencv-python_002ce5ffa4984379960fb4ec4387bbd4/opencv/modules/highgui/src/window.cpp:1255: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function ‘cvNamedWindow’
terminate called without an active exception
Aborted
That error message is the smoking gun. Your OpenCV 4.8.1 highgui module was built without any GUI backend — no GTK, no Cocoa — so any highgui call like cv2.imshow or cv2.namedWindow throws exactly that ‘function is not implemented’ error. The message even tells you the fix direction: rebuild with GTK+ 2.x support, or install libgtk2.0-dev and pkg-config and re-run cmake/configure.
The fact that your C++ examples work confirms the camera/SDK side is healthy — this is purely the Python OpenCV GUI dependency.
How did you install OpenCV on the Python side? That determines the cleanest way forward.
I originally ran their Install_dependencies_python.sh, but the numpy and opencv versions it pulled in were incompatible with each other. So I changed things around:
At this point I’m pretty sure it’s mostly a version compatibility issue. Is there a known-working combination of Raspberry Pi OS version, Python version, numpy and opencv-python (or opencv-contrib-python) that Arducam recommends for these examples? And what’s the right install method — apt, pip, sudo pip, pip3, something else? The docs aren’t clear on that.
Thanks, that’s all really helpful. We need to reproduce the exact error on our side with the same setup before we can give you a definitive version matrix. I’ve passed it to the team and we’ll get back to you once we’ve reproduced it. Bear with us.
One more thing in the meantime — I’ve sent you the Python API reference for the Arducam TOF camera over private message, so you can keep it handy while we investigate. I’ll update this thread as soon as we have more news on reproducing the error.