This project aims to develop a real-time AI-powered fall detection system using YOLO and MediaPipe. It detects human falls via a camera and sends immediate alerts through Telegram. The system is designed for use in various environments such as hospitals, nursing homes, and private residences to prevent accidents and enable quick response.
- Human Detection: Uses YOLO to accurately detect people in images or video streams.
- Pose Estimation: Uses MediaPipe to estimate key body landmarks and posture.
- Fall Detection: Detects falls based on body aspect ratio and body tilt angle.
- Real-Time Alerts: Automatically sends fall alerts via Telegram with captured images.
The system consists of the following components:
- YOLOv8: Detects humans with high confidence (threshold ≥ 0.7).
- MediaPipe: Extracts 33 body landmarks for detailed posture analysis.
- Fall Detection Algorithm: Uses aspect ratio, body angle, and a sliding window to calculate a confidence score.
- Telegram Alert System: Sends alerts with JPEG images when a fall is detected.
- Streamlit UI: Provides real-time video display with fall status visualization.
- Python 3.8+
- All required libraries are listed in
requirements.txt
.
-
Clone the repository:
git clone <repository_url> cd <repository_directory>
-
Install dependencies:
pip install -r requirements.txt
-
Configure Telegram bot credentials in
telegram_alert.py
:BOT_TOKEN = 'your_bot_token' CHAT_ID = 'your_chat_id'
-
Run with OpenCV (CLI):
python main.py
-
Run with Streamlit (Web UI):
streamlit run app.py
-
Quick Launch (Windows): If you are using Windows, you can quickly launch the application by simply double-clicking the file:
run_app.bat
📌 This batch file will automatically execute streamlit run app.py to start the web-based fall detection interface.
main.py
– Main script for real-time detection using YOLO and MediaPipe.fall_detector.py
– Includes pose estimation and fall detection logic.telegram_alert.py
– Sends alerts via Telegram Bot API.app.py
– Web-based UI built with Streamlit.
Explanation: In the Streamlit UI, a red bounding box indicates a detected fall, while green indicates normal posture.
- Salimi, M. et al., Using Deep Neural Networks for Human Fall Detection Based on Pose Estimation, Sensors, 2022.
- YOLO Documentation - Ultralytics
- Google MediaPipe Documentation
- Yong Chen et al., Vision-Based Fall Event Detection Using Attention Guided Bi-Directional LSTM
- Telegram Bot API
- OpenCV + MediaPipe Fall Detection
- YOLO-NAS Custom Object Detection – Code with Aarohi
- Ali Zara et al., Human Fall Detection Using Pose Estimation with Transformers
This project is licensed under the MIT License.
See the LICENSE
file for details.