hailo-ai / hailo-rpi5-examples

MIT License
387 stars 59 forks source link

Unable to run on different input sources #55

Closed Saad-Imtiaz closed 1 month ago

Saad-Imtiaz commented 1 month ago

Hello,

I am trying to run it on a virtual camera source (using RTSP.to-webcam) to make my CCTV Camera output to dev/video8, but its giving me the following error :

hailo-tests/hailo-rpi5-examples $ python basic_pipelines/detection.py --input /dev/video8
v4l2src device=/dev/video8 name=source ! video/x-raw, width=640, height=480 !  queue name=source_scale_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! videoscale name=source_videoscale n-threads=2 ! queue name=source_convert_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! videoconvert n-threads=3 name=source_convert qos=false ! video/x-raw, format=RGB, pixel-aspect-ratio=1/1 !  queue name=inference_wrapper_input_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! hailocropper name=inference_wrapper_crop so-path=/usr/lib/aarch64-linux-gnu/hailo/tappas/post_processes/cropping_algorithms/libwhole_buffer.so function-name=create_crops use-letterbox=true resize-method=inter-area internal-offset=true hailoaggregator name=inference_wrapper_agg inference_wrapper_crop. ! queue name=inference_wrapper_bypass_q leaky=no max-size-buffers=20 max-size-bytes=0 max-size-time=0  ! inference_wrapper_agg.sink_0 inference_wrapper_crop. ! queue name=detection_scale_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! videoscale name=detection_videoscale n-threads=2 qos=false ! queue name=detection_convert_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! video/x-raw, pixel-aspect-ratio=1/1 ! videoconvert name=detection_videoconvert n-threads=2 ! queue name=detection_hailonet_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! hailonet name=detection_hailonet hef-path=/home/elektor/Documents/GitHub/CaptureCount/tests/hailo-tests/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=detection_hailofilter_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! hailofilter name=detection_hailofilter so-path=/usr/lib/aarch64-linux-gnu/hailo/tappas/post_processes/libyolo_hailortpp_post.so   qos=false  ! inference_wrapper_agg.sink_1 inference_wrapper_agg. ! queue name=inference_wrapper_output_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0   ! queue name=identity_callback_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! identity name=identity_callback  ! queue name=hailo_display_hailooverlay_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! hailooverlay name=hailo_display_hailooverlay ! queue name=hailo_display_videoconvert_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! videoconvert name=hailo_display_videoconvert n-threads=2 qos=false ! queue name=hailo_display_q leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0  ! fpsdisplaysink name=hailo_display video-sink=xvimagesink sync=false text-overlay=false signal-fps-measurements=true 
Showing FPS
Error: gst-stream-error-quark: Internal data stream error. (1), ../libs/gst/base/gstbasesrc.c(3132): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:source:
streaming stopped, reason not-negotiated (-4)
Shutting down... Hit Ctrl-C again to force quit.

I tested the camera feed using the

ffplay -f v4l2 /dev/video8

And it is showing the camera feed perfectly fine.

giladnah commented 1 month ago

Hi, I guess the virtual camera cannot negotiate the resolution. You can try to remove the caps for the camera source or change the virtual camera output to 640x480. To remove the caps remove: ' video/x-raw, width=640, height=480 ! ' For additional issue please open a topic in our Community https://community.hailo.ai/

Saad-Imtiaz commented 1 month ago

Okay, so I was able to solve my problem, it was a video format issue, I added the YUY2 format into the hailo_rpi_common.py (changed the lines from 162-166):

 elif source_type == 'usb':
        source_element = (
            f'v4l2src device={video_source} name={name} ! '
            'video/x-raw, format=YUY2, width=640, height=360 ! '
        )

and when starting the stream of my CCTV camera I used this command:

ffmpeg -re -i rtsp://username:password@192.168.1.201:554/stream1 -r 30 -f v4l2 -vcodec rawvideo -pix_fmt yuyv422 /dev/video10