Using RTSP stream in Raspberry Pi5

I ran image detection from the sample detectio.py file cloned from GitHub - hailo-ai/hailo-rpi5-examples. We have three sources at our disposal - RPi camera, camera USB and file. What file modifications must be made to use the RTSP stream from an IP camera for analysis?

Welcome to the Hailo Community!

I would recommend looking at our Tappas examples

GitHub Tappas Multistream Detection

and our Hailo Application Code Examples

GitHub Hailo Application Code Examples Multistream App

The both also support RTSP. I am not sure how much effort it will take to adapt them but the examples should get you started.

Also check out the other examples in both repositories. I do not know them all in and out.

Let me know if you are still looking for it. I managed to get it working

@sanjoyg If you can spare a moment, please share your findings. They may be of assistance to future users. Thank you.

Unfortunately, I couldn’t get it to work, can you share with us the solution to the problem step by step?

Here are the changes to do

go to basic_pipelines directory

  1. Changes to “hailo_rpi_common.py”

Locate function “get_source_type” and change to following

def get_source_type(input_source):
    # This function will return the source type based on the input source
    # return values can be "file", "mipi" or "usb"
    if input_source.startswith("/dev/video"):
        return 'usb'
    else:
        if input_source.startswith("rpi"):
            return 'rpi'
        elif input_source.startswith("rtsp"):
            return 'rtsp'
        else:
            return 'file'
  1. Go to detection.py

Locate the function get_pipeline_string and add an “elif” after the elif of USB and before the source. The code should look like

 elif self.source_type == "usb":
            source_element = (
                f"v4l2src device={self.video_source} name=src_0 ! "
                "video/x-raw, width=640, height=480, framerate=30/1 ! "
            )
        elif self.source_type == "rtsp":
            source_element = (
                f"rtspsrc location={self.video_source} name=src_0  message-forward=true ! "
                + "rtph264depay !"
                + "queue name=hailo_preprocess_q_0 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! "
                + "decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! "

                " video/x-raw, format=I420 ! "
            )
        else:

Now launch detection.py --i <>

3 Likes

I update files but if use commamnd:

python basic_pipelines/detection.py --input rtsp://admin:pass123@192.168.88.103:554/cam/realmonitor?channel=1&subtype=1

In results is error:

Error: gst-resource-error-quark: Resource not found. (3), ../plugins/elements/gstfilesrc.c(553): gst_file_src_start (): /GstPipeline:pipeline0/GstFileSrc:src_0:
No such file "rtsp://admin:192.168.88.103:554/cam/realmonitor?channel=1"

The URL doest seem right. Hopefully you did include password. Also take the “ out

Thank you! I was also struggling with this but your answer helped me!

OK it work - Thanks :slight_smile: