Raspberry Pi 5 Error: gst-resource-error-quark

I get the following error when I try to run the basic_pipelines/detection.py on my Raspberry Pi 5 with the Raspberry Pi AI Kit

Error: gst-resource-error-quark: Failed to allocate required memory. (13), ../sys/v4l2/gstv4l2src.c(976): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV4l2Src:src_0:
Buffer pool activation failed

The error is a bit misleading. The cause of the issue is the video source. The default choice in the script may not work.

Try the following options

When you have a PiCam connected

python basic_pipelines/detection.py -i rpi

With a video file

python basic_pipelines/detection.py -i resources/detection0.mp4

With a USB camera (this may take some trials to find the right video source)

python basic_pipelines/detection.py -i /dev/video0

To add onto this, if you’re using a USB webcam, you may need to try more than just python basic_pipelines/detection.py -i /dev/video0.

The command that worked for me was python basic_pipelines/detection.py -i /dev/video8. You might need to try a bunch of different numbers before getting it right.