This project utilizes the YOLOv5 object detection algorithm and the DeepSORT object tracking algorithm to detect and track people in a video. By analyzing the movement trajectories of each person in the video, the project can calculate their dwell time and other related information.
-
Perform frame-by-frame analysis of the video using the YOLOv5 algorithm to recognize and detect people in the video.
-
Apply the DeepSORT algorithm to track the detected people, assigning a unique ID to each person.
-
Calculate the center point of each person and add it to the tracking trajectory. Trajectories are stored as dictionaries, with the person's ID as the key.
-
Draw bounding boxes and trajectory lines for each person in the video.
-
Periodically save information such as the trajectory length, dwell time, and average speed of the people to a CSV file (e.g., every 10 seconds).
-
Facial Blurring using MHCNN (Multi-Task Hierarchical Convolutional Neural Network) to blur faces for privacy protection. However, if you are using an infrared camera, this step can be skipped.
-
Save images containing the person's trajectory and images containing only the trajectory as image files.
os
: For operating system-related functions.time
: For handling time-related functions.numpy
: For numerical operations and array manipulation.detect
: Custom module for object detection using YOLOv5.cv2
(OpenCV): For image and video processing.csv
: For reading and writing CSV files.deep_sort
: Custom module for object tracking using the DeepSORT algorithm.collections
: For usingdeque
data structure.yaml
: For parsing YAML configuration files.
Camera usage advice:
- 720p Webcam (RGB): Ample outdoor lighting, allowing for capturing full-body shots.
- 120p Infrared Camera (Gray): An indoor environment with low room temperature, or an outdoor environment at night. Avoid brightly lit situations.
- 120p Infrared Camera (Normal): An indoor environment with low or medium room temperature, or an outdoor environment at night. Avoid brightly lit situations
PS:Thanks to George Verghese and Jam Kim for their contributions during the video collection