hailo-ai / hailo-rpi5-examples

MIT License
385 stars 59 forks source link

Example scripts force autofocus for all RPi camera types #23

Open jpm-canonical opened 4 months ago

jpm-canonical commented 4 months ago

Using the example on a Raspberry Pi 5, with an old v1.3 camera , the scripts exits with an error. It's clear from the error message that the script forces auto focus on, while not all camera hardware supports this.

(venv_hailo_rpi5_examples) root@jpmeijers-desktop:~/hailo-rpi5-examples# python basic_pipelines/detection.py --labels-json resources/barcode-labels.json --hef resources/yolov8s-hailo8l-barcode.hef -i rpi
hailomuxer name=hmux libcamerasrc name=src_0 auto-focus-mode=2 ! video/x-raw, format=RGB, width=1536, height=864 ! queue name=queue_src_scale max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoscale ! video/x-raw, format=RGB, width=640, height=640, 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=resources/yolov8s-hailo8l-barcode.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=/root/hailo-rpi5-examples/basic_pipelines/../resources/libyolo_hailortpp_post.so  config-path=resources/barcode-labels.json  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 
[17:54:06.775473846] [526]  INFO Camera camera_manager.cpp:313 libcamera v0.3.0+65-6ddd79b5
[17:54:06.793640092] [534]  INFO RPI pisp.cpp:695 libpisp version v1.0.6 b567f0455680 17-06-2024 (10:20:00)
[17:54:06.807988658] [534]  INFO RPI pisp.cpp:1154 Registered camera /base/axi/pcie@120000/rp1/i2c@88000/ov5647@36 to CFE device /dev/media0 and ISP device /dev/media2 using PiSP variant BCM2712_C0
[17:54:06.810803204] [548]  WARN V4L2 v4l2_pixelformat.cpp:344 Unsupported V4L2 pixel format RPBP
[17:54:06.812593729] [548]  INFO Camera camera.cpp:1183 configuring streams: (0) 1536x864-BGR888
[17:54:06.812762655] [534]  INFO RPI pisp.cpp:1450 Sensor: /base/axi/pcie@120000/rp1/i2c@88000/ov5647@36 - Selected sensor format: 1920x1080-SGBRG10_1X10 - Selected CFE format: 1920x1080-PC1g
Error: gst-resource-error-quark: Failed to enable auto focus (13), ../src/gstreamer/gstlibcamerasrc.cpp(666): gst_libcamera_src_task_enter (): /GstPipeline:pipeline0/GstLibcameraSrc:src_0:
AfMode not supported by this camera, please retry with 'auto-focus-mode=AfModeManual'

(venv_hailo_rpi5_examples) root@jpmeijers-desktop:~/hailo-rpi5-examples# python basic_pipelines/pose_estimation.py --input resources/detection0.mp4 -i rpi
hailomuxer name=hmux libcamerasrc name=src_0 auto-focus-mode=2 ! video/x-raw, format=RGB, width=1536, height=864 ! queue name=queue_src_scale max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoscale ! video/x-raw, format=RGB, width=640, height=640, 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=/root/hailo-rpi5-examples/basic_pipelines/../resources/yolov8s_pose_h8l_pi.hef batch-size=2 force-writable=true ! queue name=queue_hailofilter max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hailofilter function-name=filter so-path=/usr/lib/aarch64-linux-gnu/hailo/tappas//post-process/libyolov8pose_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 
[18:05:43.669595474] [720]  INFO Camera camera_manager.cpp:313 libcamera v0.3.0+65-6ddd79b5
[18:05:43.687784167] [728]  INFO RPI pisp.cpp:695 libpisp version v1.0.6 b567f0455680 17-06-2024 (10:20:00)
[18:05:43.702519113] [728]  INFO RPI pisp.cpp:1154 Registered camera /base/axi/pcie@120000/rp1/i2c@88000/ov5647@36 to CFE device /dev/media0 and ISP device /dev/media2 using PiSP variant BCM2712_C0
[18:05:43.707679658] [743]  WARN V4L2 v4l2_pixelformat.cpp:344 Unsupported V4L2 pixel format RPBP
[18:05:43.709851735] [743]  INFO Camera camera.cpp:1183 configuring streams: (0) 1536x864-BGR888
[18:05:43.710073754] [728]  INFO RPI pisp.cpp:1450 Sensor: /base/axi/pcie@120000/rp1/i2c@88000/ov5647@36 - Selected sensor format: 1920x1080-SGBRG10_1X10 - Selected CFE format: 1920x1080-PC1g
Error: gst-resource-error-quark: Failed to enable auto focus (13), ../src/gstreamer/gstlibcamerasrc.cpp(666): gst_libcamera_src_task_enter (): /GstPipeline:pipeline0/GstLibcameraSrc:src_0:
AfMode not supported by this camera, please retry with 'auto-focus-mode=AfModeManual'

(venv_hailo_rpi5_examples) root@jpmeijers-desktop:~/hailo-rpi5-examples# python basic_pipelines/instance_segmentation.py -i rpi                          
hailomuxer name=hmux libcamerasrc name=src_0 auto-focus-mode=2 ! video/x-raw, format=RGB, width=1536, height=864 ! queue name=queue_src_scale max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! videoscale ! video/x-raw, format=RGB, width=640, height=640, 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=/root/hailo-rpi5-examples/basic_pipelines/../resources/yolov5n_seg_h8l_mz.hef batch-size=2 force-writable=true ! queue name=queue_hailofilter max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! hailofilter function-name=yolov5seg so-path=/usr/lib/aarch64-linux-gnu/hailo/tappas//post-process/libyolov5seg_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 
[18:08:38.217203739] [1880]  INFO Camera camera_manager.cpp:313 libcamera v0.3.0+65-6ddd79b5
[18:08:38.237661727] [1888]  INFO RPI pisp.cpp:695 libpisp version v1.0.6 b567f0455680 17-06-2024 (10:20:00)
[18:08:38.252052800] [1888]  INFO RPI pisp.cpp:1154 Registered camera /base/axi/pcie@120000/rp1/i2c@88000/ov5647@36 to CFE device /dev/media0 and ISP device /dev/media2 using PiSP variant BCM2712_C0
Config file doesn't exist, using default parameters
[18:08:38.258342604] [1902]  WARN V4L2 v4l2_pixelformat.cpp:344 Unsupported V4L2 pixel format RPBP
[18:08:38.260380681] [1902]  INFO Camera camera.cpp:1183 configuring streams: (0) 1536x864-BGR888
[18:08:38.260549348] [1888]  INFO RPI pisp.cpp:1450 Sensor: /base/axi/pcie@120000/rp1/i2c@88000/ov5647@36 - Selected sensor format: 1920x1080-SGBRG10_1X10 - Selected CFE format: 1920x1080-PC1g
Error: gst-resource-error-quark: Failed to enable auto focus (13), ../src/gstreamer/gstlibcamerasrc.cpp(666): gst_libcamera_src_task_enter (): /GstPipeline:pipeline0/GstLibcameraSrc:src_0:
AfMode not supported by this camera, please retry with 'auto-focus-mode=AfModeManual'
Gordon999 commented 4 months ago

Do what it says...

AfMode not supported by this camera, please retry with 'auto-focus-mode=AfModeManual'

Change auto-focus-mode=2 to auto-focus-mode=AfModeManual

jpm-canonical commented 4 months ago

Forcing this setting to either auto focus or manual focus won't work, as we do not know which camera a user is using. If we leave this setting out, and let libcamera decide, the chance is the highest all Raspberry Pi cameras will work with this example.

Gordon999 commented 4 months ago

OK. Using auto-focus-mode=AfModeManual worked fine with my Pi GS camera but haven't tried others.

Eduk-Kurz commented 4 months ago

Hi,

PI5 GS camera

python basic_pipelines/pose_estimation.py --input rpi

with:

source_element = f"libcamerasrc name=src_0 auto-focus-mode=AfModeManual ! " # auto-focus-mode=2 AfModeManual

source_element += f"video/x-raw, format={self.network_format}, width=1456, height=1088 ! "

only COLORED STRIPES appear?!

But:

rpicam-vid -t 0 --post-process-file ~/rpicam-apps/assets/hailo_yolov8_pose.json --lores-width 640 --lores-height 640 --width 1456 --height 1088

is OK.

Thanks Ed

Gordon999 commented 4 months ago

Agreed width=1456, height=1088 ! Fails... but width=1280, height=960 ! works. I don't know why !!

width=1280 height=1088 ! also works , gives a slightly different field of view

Eduk-Kurz commented 4 months ago

Hi, it works! Thank you very much Ed

Eduk-Kurz commented 4 months ago

 

Hi,  it works!   Thank you very much Ed  

Gesendet: Dienstag, 16. Juli 2024 um 17:01 Uhr Von: "Gordon999" @.> An: "hailo-ai/hailo-rpi5-examples" @.> Cc: "Eduk-Kurz" @.>, "Comment" @.> Betreff: Re: [hailo-ai/hailo-rpi5-examples] Example scripts force autofocus for all RPi camera types (Issue #23)

 

Agreed width=1456, height=1088 ! Fails... but width=1280, height=960 ! works. I don't know why !!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>