Tharusha200219/AI-Powered-Smart-School-Safety-and-Performance-Monitoring-System
GitHub: Tharusha200219/AI-Powered-Smart-School-Safety-and-Performance-Monitoring-System
基于微服务架构的综合性智能校园平台,整合视听威胁检测、人脸考勤与教学自动化功能。
Stars: 0 | Forks: 0
# 🎓 AI 驱动的智能校园安全与表现监控系统
cd AI-Powered-Smart-School-Safety-and-Performance-Monitoring-System
```
### 2. 设置仪表板 (Laravel)
```
cd "Smart-School-Safety-and-Performance-Monitoring-System Dashboard"
# 安装 PHP 依赖
composer install
# 安装 Node 依赖
npm install
# 复制 environment file
cp .env.example .env
# 生成 application key
php artisan key:generate
# 在 .env 文件中配置数据库
# DB_CONNECTION=mysql
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=school_system
# DB_USERNAME=root
# DB_PASSWORD=
# 运行 migrations 和 seeders
php artisan migrate --seed
# 构建 assets
npm run build
# 启动服务器
php artisan serve
```
仪表板将位于 `http://localhost:8000`
### 3. 设置音频威胁检测
```
cd AudioBasedThreatDetection-Models
# 创建虚拟环境
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 安装依赖
pip install -r requirements.txt
# 启动 API
python app.py
```
API 将运行在 `http://localhost:5001`
### 4. 设置视频威胁检测
```
cd Video_Based_Left_Behind_Object_and_Threat_Detection-main
# 创建虚拟环境
python -m venv venv
source venv/bin/activate
# 安装依赖
pip install -r requirements.txt
# 下载 YOLOv8 weights (首次运行时自动下载)
# 在 config/camera_config.json 中配置摄像头
# 启动 API
python app.py
```
API 将运行在 `http://localhost:5002`
### 5. 设置作业管理
```
cd Homework-Management-and-Performance-Monitoring-System
# 创建虚拟环境
python -m venv venv
source venv/bin/activate
# 安装依赖
pip install -r requirements.txt
# 下载 NLTK data
python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords')"
# 启动 API
python app.py
```
API 将运行在 `http://localhost:5003`
### 6. 设置表现预测
```
cd student-performance-prediction-model
# 创建虚拟环境
python -m venv venv
source venv/bin/activate
# 安装依赖
pip install -r requirements.txt
# 训练初始模型
python src/model_trainer.py
# 启动 API
cd api
python app.py
```
API 将运行在 `http://localhost:5004`
### 7. 设置座位安排
```
cd student-seating-arrangement-model
# 创建虚拟环境
python -m venv venv
source venv/bin/activate
# 安装依赖
pip install -r requirements.txt
# 启动 API
cd api
python app.py
```
API 将运行在 `http://localhost:5003`
### 8. 设置人脸识别考勤
```
cd "Facial Recognition Attendance Systems"
# 创建虚拟环境
python -m venv venv
source venv/bin/activate
# 安装依赖
pip install -r requirements.txt
# 启动 API
python app.py
```
API 将运行在 `http://localhost:5004`
**注册流程:**
1. 访问注册页面 `http://localhost:5004/static/register.html`
2. 为每位学生采集 40 张人脸图像
3. 系统自动训练并生成嵌入
4. 学生准备就绪,可以进行识别
**考勤流程:**
1. 访问考勤页面 `http://localhost:5004/static/attendance.html`
2. 系统实时检测和识别人脸
3. 考勤自动标记并同步到仪表板
### 8. 启动所有服务(自动化)
使用提供的 shell 脚本启动所有 API:
```
# 启动所有 API
./start_both_apis.sh
# 停止所有 API
./stop_both_apis.sh
```
## 🔌 API 接口
### 音频威胁检测 API (端口 5001)
```
POST /api/detect
Content-Type: application/json
{
"audio_data": "base64_encoded_audio",
"sample_rate": 16000
}
Response:
{
"threat_detected": true,
"threat_type": "screaming",
"confidence": 0.92,
"timestamp": "2026-01-05T10:30:45Z"
}
```
### 视频威胁检测 API (端口 5002)
```
POST /api/analyze-frame
Content-Type: application/json
{
"camera_id": "classroom_1A",
"frame": "base64_encoded_image"
}
Response:
{
"threats": [
{
"type": "fighting",
"confidence": 0.88,
"location": [120, 340, 250, 480]
}
],
"objects": [
{
"class": "backpack",
"confidence": 0.95,
"duration": 3720
}
]
}
```
### 作业管理 API (端口 5003)
```
POST /api/generate-questions
Content-Type: application/json
{
"subject": "Science",
"topic": "Photosynthesis",
"lesson_content": "Plants use sunlight...",
"question_count": 5
}
Response:
{
"questions": [
{
"type": "mcq",
"question": "What is photosynthesis?",
"options": ["A", "B", "C", "D"],
"correct_answer": "C"
}
]
}
```
### 表现预测 API (端口 5004)
```
POST /api/predict
Content-Type: application/json
{
"student_id": 123,
"subjects": [
{
"subject_name": "Mathematics",
"attendance": 85.5,
"marks": 78.0
}
]
}
Response:
{
"predictions": [
{
"subject": "Mathematics",
"predicted_performance": 82.5,
"trend": "improving",
"confidence": 0.89
}
]
}
```
### 座位安排 API (端口 5003)
```
POST /api/optimize
Content-Type: application/json
{
"class_id": "10A",
"students": [...],
"constraints": {
"separate_friends": true,
"group_by_performance": false
}
}
Response:
{
"arrangement": [
{"row": 1, "seat": 1, "student_id": 101},
{"row": 1, "seat": 2, "student_id": 102}
],
"optimization_score": 0.87
}
```
### 人脸识别 API (端口 5004)
```
POST /recognize_face
Content-Type: multipart/form-data
Body: image file (webcam frame)
Response:
{
"success": true,
"student_id": "DASH_stu-00000078",
"student_name": "John Doe",
"confidence": 0.85,
"bbox": {"x": 100, "y": 50, "width": 150, "height": 150},
"face_detected": true
}
```
```
POST /register_student
Content-Type: application/json
{
"student_id": "DASH_stu-00000078",
"name": "John Doe",
"images": ["base64_image_1", "base64_image_2", ...]
}
Response:
{
"success": true,
"student_id": "DASH_stu-00000078",
"face_count": 40,
"trained": true,
"quality_score": 0.92
}
```
```
POST /retrain_all
Response:
{
"success": true,
"total_students": 3,
"processed_students": 3,
"total_images": 120,
"training_time": 36.5
}
```
## 💻 硬件要求
### 服务器要求
| 用例 | CPU | RAM | GPU | Storage |
| -------------------------------- | --------- | ----- | --------- | ---------- |
| **开发** | 4 cores | 8 GB | Optional | 50 GB |
| **小型学校 (<500 学生)** | 8 cores | 16 GB | GTX 1060 | 100 GB SSD |
| **中型学校 (500-1500)** | 16 cores | 32 GB | RTX 3060 | 250 GB SSD |
| **大型学校 (>1500)** | 32+ cores | 64 GB | RTX 3080+ | 500 GB SSD |
### IoT 硬件
| 项目 | 价格(LKR) |
| ------------------------------------------------------------------------------------------ | ----------- |
| **ESP32 OV2640 Camera and Development bord** | 2,880.00 |
| **2 SD Card 64GB and MicroSD Card Module** | 3,140.00 |
| **Arduino UNO R3 and UNO+WiFi R3** | 4,110.00 |
| **RFID Card Reader/Writer RC522 x 2** | 800.00 |
| **LCD1602 I2C Display Module Blue Green Screen 5V PCF8574 IIC Adapter Llate for Arduino** | 700.00 |
| **10pcs 5mm Diffused RGB Common Anode LED Bulb and RTC Real Time Clock Module** | 396.00 |
| **RFID Wristband** | 365.00 |
| ------------------------------------------------------------------------------------------ | ----------- |
| Total | 12,026.00 |
**不带腕带和 Hostinger 的单台一次性硬件设置成本**: 12,026.00
#### ESP32-CAM 规格
- **处理器**: ESP32-S (双核 160MHz)
- **摄像头**: OV2640 (2MP)
- **WiFi**: 802.11 b/g/n
- **内存**: 520KB SRAM + 4MB PSRAM
- **摄像头设置预估成本**: 5000LKR
#### 部署建议
**视频监控:**
- 每个教室 1 个摄像头
- 每个走廊/过道 1 个摄像头
- 主入口 1 个摄像头
- 操场 1 个摄像头(可选)
**人脸识别考勤:**
- 每个教室入口 1 个 ESP32-CAM(生产环境)
- 内置摄像头用于测试/开发
- 建议:摄像头位置光线充足
**20 个摄像头设置的预估成本**: 100000LKR
## 📚 文档
各组件的详细文档:
- **音频威胁检测**: [AudioBasedThreatDetection-Models/README.md](AudioBasedThreatDetection-Models/README.md)
- **视频威胁检测**: [Video_Based_Left_Behind_Object_and_Threat_Detection-main/README.md](Video_Based_Left_Behind_Object_and_Threat_Detection-main/README.md)
- **作业管理**: [Homework-Management-and-Performance-Monitoring-System/DOCUMENTATION.md](Homework-Management-and-Performance-Monitoring-System/DOCUMENTATION.md)
- **表现预测**: [student-performance-prediction-model/README.md](student-performance-prediction-model/README.md)
- **座位安排**: [student-seating-arrangement-model/README.md](student-seating-arrangement-model/README.md)
- **人脸识别**: [Facial Recognition Attendance Systems/docs/DOCUMENTATION.md](Facial%20Recognition%20Attendance%20Systems/docs/DOCUMENTATION.md)
- **仪表板设置**: [Smart-School-Safety-and-Performance-Monitoring-System Dashboard/README.md](Smart-School-Safety-and-Performance-Monitoring-System Dashboard/README.md)
### 其他资源
- **API 文档**: 参见各组件的 README 文件
- **模型训练指南**: 位于相应的模型目录中
- **ESP32-CAM 设置**: [Video_Based_Left_Behind_Object_and_Threat_Detection-main/firmware/](Video_Based_Left_Behind_Object_and_Threat_Detection-main/firmware/)
- **故障排除**: 查看组件特定的文档
## 🔒 隐私与安全
本系统优先考虑用户隐私:
- ✅ **不存储音频/视频** - 所有处理均在内存中完成
- ✅ **最小数据保留** - 仅存储元数据和警报
- ✅ **加密通信** - 所有 API 调用均使用 HTTPS/TLS
- ✅ **基于角色的访问控制** - 细粒度的权限系统
- ✅ **审计日志** - 完整的活动追踪
- ✅ **符合 GDPR** - 设计时考虑了隐私法规
- ✅ **用户同意** - 监控需获得明确许可
## 🧪 测试
### 运行单个组件的测试
```
# Audio Threat Detection
cd AudioBasedThreatDetection-Models
python -m pytest tests/
# Video Threat Detection
cd Video_Based_Left_Behind_Object_and_Threat_Detection-main
python test_system.py
# Performance Prediction
cd student-performance-prediction-model
python test_system.py
# Laravel Dashboard
cd "Smart-School-Safety-and-Performance-Monitoring-System Dashboard"
php artisan test
```
#### 端口被占用
```
# 查找占用端口的进程
lsof -ti:5001 | xargs kill -9 # macOS/Linux
netstat -ano | findstr :5001 # Windows
```
#### CUDA/GPU 问题
```
# 验证 CUDA 安装
python -c "import torch; print(torch.cuda.is_available())"
# 强制 CPU 模式 (添加到 .env)
USE_GPU=false
```
#### 模型下载失败
```
# 手动下载模型
cd models/saved/
wget
```
#### 数据库连接问题
```
# 检查 MySQL 服务
sudo systemctl status mysql # Linux
brew services list | grep mysql # macOS
# 重置 migrations
php artisan migrate:fresh --seed
```
## 📊 性能基准
| 组件 | 延迟 | 吞吐量 | GPU Usage |
| -------------------------- | -------- | ----------- | --------- |
| **Audio Detection** | <100ms | 30 fps | N/A |
| **Video Detection** | <50ms | 25 fps | 60% |
| **Homework Generation** | 2-5s | 10 req/min | N/A |
| **Performance Prediction** | <200ms | 100 req/min | N/A |
| **Facial Recognition** | 60-100ms | 10-15 fps | 30% |
_基准测试环境: Intel i7-10700K, 32GB RAM, RTX 3070_
## 📅 路线图
### 第一阶段 - 核心功能(已完成)
- ✅ 音频威胁检测
- ✅ 视频威胁检测
- ✅ 作业管理
- ✅ 表现预测
- ✅ 仪表板集成
## 🙏 致谢
- **YOLOv8** - Ultralytics 用于物体检测
- **PyTorch** - Facebook AI Research
- **Laravel** - Taylor Otwell 和 Laravel 社区
- **Transformers** - Hugging Face
- **OpenCV** - 开源计算机视觉库





这是一个综合性的 AI 驱动解决方案,旨在通过尖端的机器学习技术增强校园安全、优化教育成果并自动化管理任务。
[主要功能](#-key-features) • [系统架构](#-system-architecture) • [安装说明](#-installation) • [组件](#-system-components) • [文档](#-documentation)
## 📋 目录
- [项目概述](#-project-overview)
- [主要功能](#-key-features)
- [系统架构](#-system-architecture)
- [系统组件](#-system-components)
- [技术栈](#-technology-stack)
- [项目依赖](#-project-dependencies)
- [安装说明](#-installation)
- [快速开始](#-quick-start)
- [API 接口](#-api-endpoints)
- [硬件要求](#-hardware-requirements)
- [文档](#-documentation)
- [贡献指南](#-contributing)
- [许可证](#-license)
## 🎯 项目概述
**AI 驱动的智能校园安全与表现监控系统**是一个综合性的多组件平台,利用人工智能、机器学习和 IoT 技术创造更安全、更高效的教育环境。该系统通过中央仪表板整合了六个专业模块,提供:
### 安全监控
- **实时音频威胁检测** - 识别危险声音(尖叫声、玻璃破碎声、攻击性言语)
- **基于视频的威胁检测** - 检测暴力行为、打架或攻击性动作
- **遗留物品检测** - 监控课后教室内的遗留物品
### 表现优化
- **学生表现预测** - 根据出勤率和成绩预测学业结果
- **智能座位安排** - 优化教室座位以获得更好的学习效果
- **作业管理系统** - 自动化作业生成、分发和评估
### 卓越管理
- **人脸识别考勤** - 使用深度学习人脸识别自动记录考勤
- **中央仪表板** - 基于 Laravel 的 Web 界面,用于系统范围的管理
- **实时警报** - 多渠道通知(电子邮件、Telegram、短信)
- **分析与报告** - 全面的表现和安全报告
## ✨ 主要功能
### 🛡️ 安全与安保
- ✅ 用于威胁检测的**实时音频分析**(尖叫声、玻璃破碎声、威胁性言语)
- ✅ 结合 AI 动作识别的**视频监控**
- ✅ 用于语音分析的**多语言支持**(英语和僧伽罗语)
- ✅ **隐私优先设计** - 不存储音频/视频,仅在内存中处理
- ✅ **ESP32-CAM 集成**,用于低成本 IoT 摄像头部署
- ✅ 基于学校时间表的**计划感知监控**
- ✅ 具有可配置通知渠道的**即时警报系统**
### 🤖 考勤自动化
- ✅ 使用 FaceNet 深度学习模型的**人脸识别考勤**
- ✅ 用于高精度识别的**多重嵌入匹配**
- ✅ 使用 MTCNN 的**实时人脸检测**
- ✅ 具有冷却时间管理的**自动考勤标记**
- ✅ **仪表板集成**,实现无缝考勤追踪
### 📊 表现与分析
- ✅ 针对所有科目学生表现的**预测性分析**
- ✅ 使用 NLP 和 AI 的**自动作业生成**
- ✅ 针对 MCQ 和描述性问题的**智能答案评估**
- ✅ 考虑学生关系和表现的**基于 ML 的座位优化**
- ✅ 具有全面可视化的**实时仪表板**
- ✅ 面向教师和家长的**月度表现报告**
### 🎓 教务管理
- ✅ **多科目支持**(科学、数学、历史、英语、健康科学)
- ✅ 基于课程内容的**题目生成**
- ✅ 带有反馈生成的**自动评分系统**
- ✅ **表现追踪**和趋势分析
- ✅ 通过自动化**减轻教师工作负担**
## 🏗️ 系统架构
该系统遵循**微服务架构**,专业的 AI/ML 模块通过 REST API 与中央 Laravel 仪表板进行通信。
Overall system architecture
**用 ❤️ 构建,为了更安全、更智能的校园**
[⬆ 返回顶部](#-ai-powered-smart-school-safety-and-performance-monitoring-system)
标签:Apex, Laravel, OpenVAS, PHP, Python, 人工智能, 仪表盘, 作业管理, 凭据扫描, 学校安全, 学生成绩预测, 安全管理系统, 座位优化, 教育科技, 无后门, 智慧校园, 智能教育, 机器学习, 校园监控, 深度学习, 物联网, 用户模式Hook绕过, 系统调用监控, 自动化管理, 行为检测, 视频威胁检测, 逆向工具, 音频分析