ValueError in ToF camera example getDepthData on Raspberry Pi 4B Python 3.11

Hi, I’ve got the Arducam ToF Camera hooked up to a Raspberry Pi 4B and I’ve been following the online documentation, but it has never worked properly. Every time I run the Python example I hit a ValueError. Has anyone run into this before?

Sorry to hear that. Could you share a bit more about your setup? OS, Python version, how you installed the dependencies, and whether you changed anything in the example code. Also paste the full error output if you can.

I’m on a Raspberry Pi 4B using a Python 3.11 virtual environment. cv2 is installed inside the venv at /home/user/Desktop/projects/env/lib/python3.11/site-packages/cv2. I installed the dependencies from the docs and I have not modified the example code at all.

Thanks. Can you run the example again and paste the complete console output? The exact line that fails and the full error text would help narrow this down.

Here’s what I get. First there’s a Qt plugin warning:

qt.qpa.plugin: Could not find the Qt platform plugin “wayland” in “/home/user/Desktop/projects/env/lib/python3.11/site-packages/cv2/qt/plugins”

Then it fails at this line:

depth_buf = frame.getDepthData()

with:

ValueError: resize only works on single-segment arrays

Also, what does getDepthData() actually do? Is there source code or more documentation for these functions? I can’t find much detail.

The Qt/wayland warning is usually from OpenCV’s GUI parts and probably isn’t what’s killing the script, but keep it in mind. The ValueError is coming from an internal resize on the depth buffer, so it looks like it’s failing inside getDepthData() rather than in your own code. We’re trying to reproduce this on the same setup. In the meantime, can you post the few lines around the failing call so we can see the exact example version you’re running?

Sure, the relevant part of the example is basically:

while True:
frame = tof.getFrame()
depth_buf = frame.getDepthData()
…

I haven’t touched the example at all.

Quick update: we’re still reproducing this, so there’s no confirmed root cause yet. The error suggests the depth data is being passed to a resize operation that doesn’t like the array layout, possibly a shape or stride issue in the buffer, but we haven’t nailed it down. For now, the best reference is the ToF camera SDK documentation, especially the API references for C:

https://docs.arducam.com/Raspberry-Pi-Camera/Tof-camera/Arducam-ToF-Camera-SDK/#api-references-for-c

That covers the SDK/API details for these functions. We’ll update once we have a fix or workaround.