SafeEye is an advanced person detection and tracking system built with Python. It uses computer vision and deep learning technologies to detect and track people in real time from a webcam stream. The system stores detections in a MySQL database, saves images of detected people, and provides a simple web interface for live video streaming and browsing detection history.
- Real-time person detection using YOLOv5 (deep learning object detection).
- Person tracking with DeepSort algorithm—each person gets a unique ID.
- Web interface for live video streaming (Flask-based).
- Detection history: browse all detected people, their images, timestamps, and IDs.
- Automatic photo saving of newly detected persons.
- MySQL database integration for persistent storage of detections.
- Simple, responsive web frontend.
- CORS enabled for easy integration with external frontends.
- Live video is captured from your default webcam.
- YOLOv5 detects people in each frame.
- DeepSort tracker assigns and maintains unique IDs for tracked individuals.
- Detected persons are saved as cropped images in the
static/tracked_personsdirectory. - Detection events are recorded in a MySQL database (
track_id, timestamp, image path). - Web interface provides:
/for live video stream/datafor browsing detection history with images
- Python 3.7+
- MySQL server
- Webcam
Install required libraries:
pip install -r requirements.txtMain packages used:
opencv-pythontorchultralytics/yolov5(via torch.hub)deep_sort_realtimeflaskflask_corsmysql-connector-python
Create a MySQL database and the required table:
CREATE DATABASE person_tracker;
USE person_tracker;
CREATE TABLE tracked_persons (
id INT AUTO_INCREMENT PRIMARY KEY,
track_id INT NOT NULL,
timestamp DATETIME NOT NULL,
image_path VARCHAR(255) NOT NULL
);Adjust MySQL credentials in main.py if needed:
db_config = {
'host': 'localhost',
'user': 'admin',
'password': 'admin',
'database': 'person_tracker'
}- Make sure your MySQL server is running.
- Plug in your webcam.
- Run the application:
python main.pyThe server will start on http://0.0.0.0:5761/.
- / — Live video stream.
- /video_feed — MJPEG video stream (used by the main page).
- /data — Detection history with images of tracked persons.
safeEye/
├── main.py
├── requirements.txt
├── static/
│ └── tracked_persons/
└── README.md
- The app saves images only for newly detected (unique) people.
- The live stream overlays bounding boxes, IDs, and detection times on the video.
- All data is persistent as long as the database and
static/tracked_personsdirectory are preserved.
This project is licensed under the MIT License.
SafeEye — Real-time person detection and tracking for security, analytics, and smart monitoring.