Using RTSP stream in Raspberry Pi5

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