a b/README.md
1
# TeleICU-Monitoring-System
2
* This project is developed by Team Duelists
3
* Team Members:
4
  * Debraj Mistry (Team Lead)
5
  * Md Faizan
6
  * Jyotipriya Mallick
7
  * Sushanta Bhunia
8
  * Hrishikesh Chandra
9
       
10
# 🔍 Project Overview
11
This project implements an innovative monitoring system for TeleICU patients using video processing and deep learning techniques. The system aims to reduce the burden on remote healthcare professionals by allowing them to monitor multiple patients simultaneously.
12
13
# 📋 Key Features
14
15
**Multi-source Video Input**: The system can process video from various sources including local files, YouTube links, and live CCTV feeds.
16
17
**Patient Detection and Tracking**: Utilizes the YOLOv8 object detection model to identify and track patients, doctors, nurses, monitors and others in the video feed.
18
19
**Movement Analysis**: Implements advanced motion detection algorithms to analyze patient movements, including:
20
 *  Overall motion detection using Structural Similarity Index (SSIM) method for measuring the similarity between two images.
21
 *  Specific movement detection for head, hands, legs, and chest (for breathlessness)
22
23
**Fall Detection**: Incorporates a separate YOLOv8 model trained specifically for detecting fall incidents.
24
25
**Real-time Alerting**: Generates visual alerts on the video feed when critical events of patients are detected.
26
27
**Movement Logging**: Records detected movements with timestamps in a log file for later analysis.
28
29
**Video Output**: Processes and saves the annotated video feed with detected objects, movements, and alerts.
30
31
# 🛠️ Technical Approach
32
33
**Video Processing**
34
35
* OpenCV (cv2) is used for video capture, processing, and output.
36
* The system supports multiple video sources, including local files, YouTube links (using yt-dlp), and live CCTV feeds.
37
38
**Object Detection**
39
40
Fine-Tuned YOLOv8 models are employed for object detection:
41
42
1. A general model ('person_labelling.pt') for detecting patients, doctors, nurses, monitor and others.
43
2. A specialized model ('fall_detection.pt') for fall detection.
44
45
**Movement Analysis**
46
47
* Optical flow (cv2.calcOpticalFlowFarneback) is used to detect and analyze specific movements.
48
49
* The patient's body is analysed into regions (head, hands, legs, chest) for targeted movement analysis.
50
51
* SSIM (Structural Similarity Index) is used to detect overall motion between frames.
52
53
**Fall Detection**
54
55
A separate thread continuously analyzes frames for potential fall incidents.
56
When a fall is detected, an alert is displayed on the video feed for a set duration.
57
58
**Real-time Processing**
59
60
The system processes video frames in real-time, performing object detection, movement analysis, and fall detection on each frame.
61
Multithreading is used to ensure smooth performance, especially for the continuous fall detection.
62
63
# 🪄 Unique Features of Our Project
64
65
1. **Multi-Source Video Input**
66
     * Supports video input from local files, URLs (e.g., YouTube), and live CCTV feeds.
67
       
68
2. **Person Detection and Identification**
69
      * Detects various individuals in the ICU, including doctors, nurses, and patients using the Fine-Tuned YOLOv8 model (person_labelling.pt).
70
      * Identifies when a patient is without a doctor or nurse and changes the bounding box color accordingly:
71
          * Green: Indicates presence of a doctor or nurse.
72
          * Yellow: Indicates no significant motion detected and no doctor/nurse present.
73
          * Blue: Indicates significant motion detected without specific movements.
74
          * Red: Indicates significant movement or specific detected movements (e.g., head, hand, leg, breathlessness).
75
76
3. **Specific Movement Detection**
77
      * Detects and analyzes specific patient movements such as head, hand, leg movements, and signs of breathlessness using optical flow and structural similarity metrics.
78
79
4. **Fall Detection and Alert System**
80
      * Uses a secondary Fine-Tuned YOLOv8 model (fall_detection.pt) for detecting falling of the patient and other dangerous movements of the patient.
81
      * Generates real-time alerts with visual indicators and log entries for critical detections.
82
      * Displays a red border around the video frame and an alert message for a specified duration when a fall is detected.
83
84
5. **Real-Time Video Processing and Output**
85
      * Processes video in real-time, applying detections and annotations dynamically.
86
      * Saves processed video with annotations for later review and analysis.
87
88
6. **Movement Logging**
89
      * Logs detected movements with timestamps for comprehensive documentation and future analysis.
90
      * Updates movement logs in real-time to ensure accuracy.
91
92
# ⚙️ Implementation Details
93
94
**Language: Python**
95
96
**Main Libraries**:
97
98
* OpenCV (cv2) for video processing
99
* Ultralytics YOLO for object detection and fall detection
100
* NumPy for numerical operations
101
* scikit-image for image processing algorithms
102
* PyTorch for deep learning model inference
103
* Video Handling: yt-dlp for downloading YouTube videos
104
* Multithreading: Python's threading module for concurrent processing
105
106
# 📝 Challenges Addressed
107
108
**Dataset Creation**: While not explicitly shown in the code, the project likely involved creating or curating a dataset of ICU patient images/videos for training the models.
109
110
**Real-time Video Processing**: The code efficiently processes high-quality video in real-time, addressing one of the major challenges mentioned in the problem statement.
111
112
**Error Margin Reduction**: By using multiple analysis techniques (object detection, movement analysis, fall detection), the system aims to reduce error margins in patient monitoring.
113
114
# ♾️ Future Improvements
115
116
* Utilize IoT devices (wearable sensors, smart beds) for continuous patient monitoring.
117
* Implement more sophisticated algorithms for detecting complex patient behaviors.
118
* Integrate with hospital information systems for comprehensive patient monitoring.
119
* Develop a user-friendly interface for healthcare professionals to monitor multiple patients.
120
* Utilize IoT devices (wearable sensors, smart beds) for continuous patient monitoring.
121
* Create alert systems that prioritize alerts based on severity, notifying healthcare staff promptly to enable quick interventions.
122
* Forecast patient movements and health changes using historical and real-time data.
123
124
125
# ⏳Conclusion
126
127
The TeleICU Monitoring System revolutionizes remote ICU patient care by integrating advanced video processing and deep learning techniques. Our system supports versatile video input from local files, URLs, and live CCTV feeds, ensuring flexibility in various monitoring scenarios. Leveraging the YOLOv8 model, it accurately detects and identifies individuals such as doctors, nurses, patients, monitor, others, dynamically changing bounding box colors to indicate the presence of healthcare professionals and specific patient movements. Unique features include detailed analysis of head, hand, leg movements, signs of breathlessness, and a robust fall detection system that generates real-time alerts. The system processes and saves annotated video feeds in real-time, accompanied by comprehensive movement logs with timestamps, ensuring accurate documentation for future analysis. By providing these innovative tools, our TeleICU Monitoring System significantly enhances patient safety and care quality, setting a new standard in telemedicine and remote ICU monitoring.
128
129
# 🤖 Installation and Run Guide
130
131
# 📽️ Guide Video
132
  Full guide for better understanding [ Guide_video.mp4](https://github.com/DMHACKERZ/TeleICU-Monitoring-System/blob/main/Guide_video.mp4)
133
134
## Prerequisites
135
* Python 3.8 
136
* Git / Github Desktop
137
138
## Installation Guide
139
140
Step 1: Clone the Repository
141
First, clone the repository from GitHub.
142
143
144
145
    git clone https://github.com/DMHACKERZ/TeleICU-Monitoring-System
146
    cd your-repo-directory
147
148
Step 2: Set Up a Virtual Environment
149
Create and activate a virtual environment to manage dependencies.
150
* Ensure you run all the following commands inside "your-repo-directory"
151
152
**Windows**
153
cmd
154
155
    python -m venv environment_name
156
    environment_name\Scripts\activate
157
158
**Mac and Linux**
159
160
    python3 -m venv environment_name
161
    source environment_name/bin/activate
162
163
Step 3: Install Dependencies
164
Install the required Python packages using pip.
165
166
167
     pip install -r requirements.txt
168
169
170
171
## Running the Code
172
173
Step 1: Ensure YOLO Models Are Available
174
Ensure that the Fine-Tuned YOLO models (person_labelling.pt and fall_detection.pt) are available in the project directory.
175
176
Step 2: Run the Script
177
To run the script, execute the following command:
178
179
180
    python icu.py
181
182
**Usage Guide**
183
184
Prompt for Video Source: After running the script, you will be prompted to enter the video source. You can provide a file path, a YouTube URL, or type 'cctv' for live camera feed.
185
186
Example inputs:
187
188
    Enter the video file path, URL, or 'cctv' for live feed: example_video.mp4
189
    Enter the video file path, URL, or 'cctv' for live feed: https://www.youtube.com/watch?v=example
190
    Enter the video file path, URL, or 'cctv' for live feed: cctv
191
    
192
**Monitor the Output**: The script will process the video and display a window with live predictions. Detected movements will be logged in "movement_log.txt" in real-time. If a fall is detected, the alert will be displayed on the video feed.
193
194
**Terminate the Script**: To terminate the script, press q while the video window is active.
195
196
**Platform-Specific Notes**
197
198
Windows
199
* Ensure you have the correct drivers installed for your GPU if using CUDA for acceleration.
200
  
201
Mac
202
* Ensure you have Xcode command line tools installed for compiling certain packages.
203
* Use python3 instead of python if your system defaults to Python 2.
204
205
Linux
206
* Ensure you have the necessary build tools installed. You can typically install them via your package manager. For example, on Ubuntu, you can run:
207
208
      sudo apt-get update
209
      sudo apt-get install build-essential
210
## Troubleshooting
211
* If you encounter issues with yt-dlp, ensure you have the latest version installed.
212
* For any dependency issues, verify that all packages in "requirements.txt" are installed correctly and compatible with your Python version.
213
* Check the logs and error messages for specific issues and resolve them accordingly. Common issues might include missing files, incorrect paths, or compatibility problems.
214
215
# Contributing
216
217
Feel free to fork the repository and submit pull requests. For major changes, please open an issue first to discuss what you would like to change.