-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathinfo.txt
More file actions
169 lines (139 loc) · 4.68 KB
/
info.txt
File metadata and controls
169 lines (139 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
This code is a comprehensive Flask-based web application designed for real-time video monitoring with integrated AI-based detection systems. Let's break down its key components and functionalities:
### 1. Core Features
- **Multi-Feature Detection System**:
- Restricted Zone Intrusion Detection
- Fire/Smoke Detection
- Safety Gear Detection
- Pose Estimation (for worker safety monitoring)
- Motion Amplification (for subtle motion analysis)
- **User Management**:
- Registration/Login system with Flask-Login
- Session management
- Role-based access control
- **Alert System**:
- Visual/audio alerts
- SMS notifications via Twilio
- Alert history with frame snapshots
- **complaint Management**:
- User-submitted complaint with file attachments
- complaint tracking system
- **Camera Management**:
- Multiple camera configuration
- Feature toggling per camera
- RTSP/Webcam support
### 2. Technical Stack
- **Backend**:
- Flask web framework
- SQLAlchemy ORM with multiple databases
- OpenCV for video processing
- YOLOv8 models for various detections
- Twilio integration for SMS alerts
- **Frontend**:
- HTML templates with Jinja2 rendering
- Video streaming with multipart MIME type
- Interactive dashboard
- **Database**:
- SQLite databases for:
- User credentials
- Camera configurations
- Alert history
- complaints
### 3. Key Components Breakdown
#### **A. Detection Modules**
- **People Detection** (`people_detection`):
- Uses YOLOv8n model
- Restricted zone monitoring
- Configurable detection regions
- **Fire Detection** (`fire_detection`):
- Custom trained model (fire.pt)
- 0.60 confidence threshold
- Persistent bounding box display
- **Safety Gear Detection** (`gear_detection`):
- Specialized PPE detection
- Real-time visual feedback
- **Motion Amplification** (`amp`):
- Eulerian video magnification
- Amplifies subtle motions (α=2.5)
#### **B. Core Routes**
1. **Authentication System**:
```python
@app.route('/login', methods=['GET', 'POST'])
def login():
# Handles user authentication
# Integrates with Flask-Login
@app.route('/register', methods=['GET', 'POST'])
def register():
# Manages user registration
# Password stored in plaintext (needs improvement)
```
2. **Video Processing Pipeline**:
```python
def process_frames(camid, region, flag_r_zone, flag_pose_alert, flag_fire, flag_gear, user_id):
# Main video processing loop
# Handles multiple detection systems
# Yields JPEG frames for streaming
```
3. **Alert System**:
```python
def add_to_db(results, frame, alert_name, user_id):
# Database logging with 1-minute cooldown
# Stores base64 encoded snapshots
def send_alert_message():
# Twilio integration for SMS alerts
# Triggered on fire detection
```
#### **C. Database Models**
1. **User Model**:
```python
class User(UserMixin, db.Model):
# Stores user credentials
# Relationships with cameras and alerts
```
2. **Camera Configuration**:
```python
class Camera(db.Model):
# Per-camera feature toggles
# Supports multiple cameras per user
```
3. **Alert System**:
```python
class Alert(db.Model):
# Timestamped alert records
# Stores JPEG snapshots as BLOB
```
### 4. Security Features
- Flask-Login integration
- Session management
- CSRF protection (needs improvement)
- File upload validation
- Environment variable configuration
### 5. Operational Flow
1. User authenticates via web interface
2. Configures camera(s) with desired detection features
3. Video stream processed through selected detectors
4. Detected anomalies trigger:
- Visual/audio alerts
- Database logging
- SMS notifications (for critical events)
5. Users can review historical alerts and submit complaint
### 6. Optimization Opportunities
- **Security**:
- Implement password hashing
- Add CSRF protection
- Secure file upload handling
- **Performance**:
- Model quantization for faster inference
- Batch processing of video frames
- Database connection pooling
- **Features**:
- Real-time dashboard metrics
- Camera health monitoring
- Multi-user support with roles
- Exportable reports
### 7. Deployment Considerations
- Proper WSGI server configuration (e.g., Gunicorn)
- Reverse proxy setup (Nginx/Apache)
- Database migration to PostgreSQL/MySQL
- Docker containerization
- GPU acceleration for model inference
This system provides a foundation for industrial safety monitoring with AI capabilities. It demonstrates effective integration of computer vision models with web technologies, while maintaining scalability for enterprise-level deployments.