This project focuses on detecting and tracking people (therapist and child) in video footage using YOLOv5 and the SORT tracking algorithm. The system assigns unique IDs to individuals and tracks them consistently throughout the video, even if they re-enter the frame or are partially occluded.
- Unique ID Assignment: Each detected person is assigned a unique ID that remains consistent throughout the video.
- Re-entry and Occlusion Handling: The system re-assigns the correct ID to a person who exits and re-enters the frame, or when visibility is partially obscured.
- Efficient Tracking: Utilizes the YOLOv5 object detection model along with the SORT algorithm for real-time tracking.
- Face Saving Logic: Every 10 seconds, the code will crop the faces of tracked persons and save them to the specified output folder. Filenames will include the tracking ID and the current timestamp.
Before running the project, ensure you have the following installed:
- Python 3.7+
- OpenCV
- PyTorch
- SORT
- YOLOv5
Clone this repository:
git clone https://github.com/nj7782/Facedetection_with_uniqueID.gitInstall the required dependencies:
pip install -r requirements.txtDownload the YOLOv5 repository from the official GitHub page:
Download SORT from its official repository:
Download the pre-trained YOLOv5 weights (for example, yolov5s.pt):
Make sure to place the weights file in the appropriate directory as referenced in the code.
To run the tracking system:
python detect_and_track.pyThe output video will display bounding boxes with unique IDs assigned to each person detected in the footage. The results will be similar to the output video found here: