RPI 5 Example not working

I have the M.2 hat for the pi 5 with a Hailo 8 on it and I am trying to use the examples from GitHub - hailo-ai/hailo-rpi5-examples. If I run it with input resources it works fine, but trying to run it with a camera causes problems. Just running detection.py from the virtual environment with no arguments gives me the following output

hailomuxer name=hmux v4l2src device=/dev/video0 name=src_0 ! video/x-raw, width=640, height=480, framerate=30/1 ! queue name=queue_scale max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=2 ! queue name=queue_src_convert max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 name=src_convert qos=false ! video/x-raw, format=RGB, width=640, height=640, pixel-aspect-ratio=1/1 ! tee name=t ! queue name=bypass_queue max-size-buffers=20 max-size-bytes=0 max-size-time=0 ! hmux.sink_0 t. ! queue name=queue_hailonet max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 ! hailonet hef-path=/home/cmc/hailo-rpi5-examples/basic_pipelines/../resources/yolov6n.hef batch-size=2 nms-score-threshold=0.3 nms-iou-threshold=0.45 output-format-type=HAILO_FORMAT_TYPE_FLOAT32 force-writable=true ! queue name=queue_hailofilter max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hailofilter so-path=/home/cmc/hailo-rpi5-examples/basic_pipelines/../resources/libyolo_hailortpp_post.so  qos=false ! queue name=queue_hmuc max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hmux.sink_1 hmux. ! queue name=queue_hailo_python max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! queue name=queue_user_callback max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! identity name=identity_callback ! queue name=queue_hailooverlay max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hailooverlay ! queue name=queue_videoconvert max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 qos=false ! queue name=queue_hailo_display max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! fpsdisplaysink video-sink=xvimagesink name=hailo_display sync=false text-overlay=False signal-fps-measurements=true 
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

Running it with my custom modelā€™s .hef file gives me

hailomuxer name=hmux v4l2src device=/dev/video0 name=src_0 ! video/x-raw, width=640, height=480, framerate=30/1 ! queue name=queue_scale max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=2 ! queue name=queue_src_convert max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 name=src_convert qos=false ! video/x-raw, format=RGB, width=640, height=640, pixel-aspect-ratio=1/1 ! tee name=t ! queue name=bypass_queue max-size-buffers=20 max-size-bytes=0 max-size-time=0 ! hmux.sink_0 t. ! queue name=queue_hailonet max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 ! hailonet hef-path=hailo_090.hef batch-size=2 nms-score-threshold=0.3 nms-iou-threshold=0.45 output-format-type=HAILO_FORMAT_TYPE_FLOAT32 force-writable=true ! queue name=queue_hailofilter max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hailofilter so-path=/home/cmc/hailo-rpi5-examples/basic_pipelines/../resources/libyolo_hailortpp_post.so  qos=false ! queue name=queue_hmuc max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hmux.sink_1 hmux. ! queue name=queue_hailo_python max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! queue name=queue_user_callback max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! identity name=identity_callback ! queue name=queue_hailooverlay max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hailooverlay ! queue name=queue_videoconvert max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 qos=false ! queue name=queue_hailo_display max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! fpsdisplaysink video-sink=xvimagesink name=hailo_display sync=false text-overlay=False signal-fps-measurements=true 
gst_parse_error: could not link videoconvert0 to hailonet0 (3)
hailomuxer name=hmux v4l2src device=/dev/video0 name=src_0 ! video/x-raw, width=640, height=480, framerate=30/1 ! queue name=queue_scale max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=2 ! queue name=queue_src_convert max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 name=src_convert qos=false ! video/x-raw, format=RGB, width=640, height=640, pixel-aspect-ratio=1/1 ! tee name=t ! queue name=bypass_queue max-size-buffers=20 max-size-bytes=0 max-size-time=0 ! hmux.sink_0 t. ! queue name=queue_hailonet max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 ! hailonet hef-path=hailo_090.hef batch-size=2 nms-score-threshold=0.3 nms-iou-threshold=0.45 output-format-type=HAILO_FORMAT_TYPE_FLOAT32 force-writable=true ! queue name=queue_hailofilter max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hailofilter so-path=/home/cmc/hailo-rpi5-examples/basic_pipelines/../resources/libyolo_hailortpp_post.so  qos=false ! queue name=queue_hmuc max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hmux.sink_1 hmux. ! queue name=queue_hailo_python max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! queue name=queue_user_callback max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! identity name=identity_callback ! queue name=queue_hailooverlay max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hailooverlay ! queue name=queue_videoconvert max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoconvert n-threads=3 qos=false ! queue name=queue_hailo_display max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! fpsdisplaysink video-sink=xvimagesink name=hailo_display sync=false text-overlay=False signal-fps-measurements=true

Output of dmesg | grep hailo

[    3.736720] hailo: Init module. driver version 4.17.0
[    3.738906] hailo 0000:01:00.0: Probing on: 1e60:2864...
[    3.738915] hailo 0000:01:00.0: Probing: Allocate memory for device extension, 11600
[    3.738933] hailo 0000:01:00.0: enabling device (0000 -> 0002)
[    3.738940] hailo 0000:01:00.0: Probing: Device enabled
[    3.738960] hailo 0000:01:00.0: Probing: mapped bar 0 - 000000005c218efe 16384
[    3.738966] hailo 0000:01:00.0: Probing: mapped bar 2 - 000000006e1c092f 4096
[    3.738971] hailo 0000:01:00.0: Probing: mapped bar 4 - 000000005e3a15ca 16384
[    3.745732] hailo 0000:01:00.0: Probing: Force setting max_desc_page_size to 4096 (recommended value is 16384)
[    3.745748] hailo 0000:01:00.0: Probing: Enabled 64 bit dma
[    3.745751] hailo 0000:01:00.0: Probing: Using userspace allocated vdma buffers
[    3.745757] hailo 0000:01:00.0: Disabling ASPM L0s 
[    3.745761] hailo 0000:01:00.0: Successfully disabled ASPM L0s 
[    3.943270] hailo 0000:01:00.0: Firmware was loaded successfully
[    4.019130] hailo 0000:01:00.0: Probing: Added board 1e60-2864, /dev/hailo0

Output of hailortcli fw-control identify

Executing on device: 0000:01:00.0
Identifying board
Control Protocol Version: 2
Firmware Version: 4.17.0 (release,app,extended context switch buffer)
Logger Version: 0
Board Name: Hailo-8
Device Architecture: HAILO8L
Serial Number: HLDDLBB241901953
Part Number: HM21LB1C2LAE
Product Name: HAILO-8L AI ACC M.2 B+M KEY MODULE EXT TMP

I already checked to make sure the hailort service was running with sudo systemctl status hailort.service but I still restarted it anyway and rebooted the pi, and that didnā€™t fix it.

1 Like

Iā€™m having a similar issue. More or less lifted the gstreamer query from the hailo-rpi5 repo into Rust and having the same issue linking the videoconvert step to the hailonet:

failed to parse pipeline from description: Error { domain: gst_parse_error, code: 3, message: "could not link videoconvert0 to hailonet0" }

Which camera is it? USB, RTSP or Picam?

USB should be the easiest, at least as a checking step. Can you also share the exact command that you execute to get that error?

Typing this command results in the first error
python basic_pipelines/detection.py

Typing this command results in the second error
python basic_pipelines/detection.py --hef-path hailo_090.hef

The camera is plugged directly into the piā€™s camera port, and it works to pipe video into the yolo example with
rpicam-hello -t 0 --post-process-file hailo_yolov6_inference.json --lores-width 640 --lores-height 640

For RPi camera use ā€˜ā€“input rpiā€™
Use the ā€œā€“helpā€ flag for more details

Using a USB camera fixed the first problem, but the custom model is still giving the same error
gst_parse_error: could not link videoconvert0 to hailonet0

Can you check if your camera is capable of outputing VGA (640x480) @30FPS?
You can check that with this command:
gst-device-monitor-1.0
It would give a long output, listing all the available resolutions for each connected camera, but ideally you would see something like that:

It lists raw video at 640 by 480 but it doesnā€™t specify anything else
video/x-raw, format=YUY2, width=640, height=480

Fixing the resolution to match the model fixed that error. Now Iā€™m just dealing with the script since the model isnā€™t one for detection. Iā€™m trying to adapt the script to work with mine but so far, no success.

so youā€™ve switched to a different task? If this the case, need to verify that you have the post processing function.

I was able to get it working with my model after I made a bare-bones post-processing .so file, but itā€™s running really slowly and with about a 4 second latency

@czion please post your solution! :slight_smile:

ā€œcould not link videoconvert0 to hailonet0ā€

how did you solve this issue?

@victor, what solved that problem for me was making sure the scriptā€™s resolution matched the resolution my model was expecting. There is a default resolution in the given script, if your model uses some other resolution, it will give that error. @M_S I canā€™t post my exact code, but if you have questions about the solution Iā€™d be happy to answer them!

this solved the problem:
self.batch_size = 2
self.network_width = 416
self.network_height = 416
self.network_format = ā€œRGBā€
nms_score_threshold = 0.3
nms_iou_threshold = 0.45

now the nms post processing is not workingā€¦