Skip to content

A simple example of how we can detect object in a RTSP stream (Camera) using YOLOv5 and OpenCV.

Notifications You must be signed in to change notification settings

AhmedEssam19/Object-Detection-In-RTSP-Stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object-Detection-In-RTSP-Stream

Description

This project is a simple example of how we can detect object in a RTSP stream (Camera) using YOLOv5 and OpenCV.

Details

The project is divided into three parts:

  1. Simulated RTSP Stream (Camera): Using RTSP Server (mediamtx) and ffmpeg that streams a fixed video on repeat. ffmpeg acts as a RTSP publisher.
  2. Inference Server: A simple Flask server that uses YOLOv5 to detect objects in the RTSP stream and saves the image with detection boxes when receiving GET request. The server acts as a RTSP listener. Additionally, Gunicorn is used as an application server for efficiency.
  3. Client: A simple Python script that sends GET request to the Inference Server to get the path of the saved image.

Solution Design

Usage

  1. Clone the repository.
$ git clone https://github.com/AhmedEssam19/Object-Detection-In-RTSP-Stream.git
$ cd Object-Detection-In-RTSP-Stream
  1. Start the RTSP and inference servers.
$ export HOST_OUTPUT_FOLDER_PATH=[PATH TO DESIRED FOLDER] WEIGHT_FILE=[WEIGHT FILE NAME OF DESIRED VERSION e.g., yolov5xu.pt, yolov5s.pt, ...etc]
$ docker compose up
  1. Run the client code.
$ cd client
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ python3 client.py

Prerequisites

  • Nvidia Drivers
  • Docker
  • Nvidia Container Toolkit
  • python3 with venv

About

A simple example of how we can detect object in a RTSP stream (Camera) using YOLOv5 and OpenCV.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published