diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..87ccbd5a2b5597393f3e64e223121b0e9c4758ed --- /dev/null +++ b/README.en.md @@ -0,0 +1,292 @@ +# Elderly Fall Detection System (Older Fall Detection System) + +## 📋 Project Introduction + +This project is a deep learning-based elderly fall detection system that utilizes the YOLO object detection model to automatically recognize falling behaviors in video and real-time camera feeds. The system provides a complete front-end and back-end solution, supporting user registration and login, video upload detection, real-time monitoring, and historical record query functions. + +## ✨ Key Features + +- **High-Precision Fall Detection**: Based on Ultralytics YOLO deep learning models +- **Multiple Detection Modes**: Supports image detection, video detection, and real-time camera monitoring +- **User Management System**: Complete registration, login, and authentication features +- **Historical Record Tracking**: Saves detection history and video files +- **Email Alert Notifications**: Automatically sends alert emails when a fall is detected +- **Visualized Statistics**: Provides statistical analysis charts for fall data +- **Docker Deployment Support**: Multi-platform Docker configuration files for quick deployment +- **Responsive Frontend Interface**: Modern management interface based on Vue 3 + +## 🛠 Technology Stack + +### Backend Technologies +- **Python 3.11** - Development language +- **Flask** - Web framework +- **PyTorch 2.5.1** - Deep learning framework +- **Ultralytics YOLO** - Object detection model +- **SQLite** - Lightweight database +- **OpenCV** - Image processing + +### Frontend Technologies +- **Vue 3** - Frontend framework +- **Element Plus** - UI component library +- **Vite** - Build tool +- **Pinia** - State management +- **ECharts** - Chart visualization + +## 📁 Project Structure + +``` +older_fall/ +├── backend/ # Backend project directory +│ ├── app.py # Flask main application file +│ ├── predict.py # Fall detection core logic +│ ├── train.py # Model training script +│ ├── models.py # Database model definitions +│ ├── seed.py # Data initialization script +│ ├── data.yaml # Dataset configuration file +│ ├── data_split.py # Dataset splitting script +│ ├── detect.py # Detection script +│ ├── coco_trans.py # COCO dataset conversion +│ ├── image_2_vedio.py # Image to video script +│ ├── ultralytics/ # YOLO model framework +│ ├── templates/ # HTML templates +│ ├── uploads/ # Uploaded file storage directory +│ ├── test_data/ # Test data +│ │ ├── images/ # Test images +│ │ └── videos/ # Test videos +│ ├── docker/ # Docker configuration files +│ │ ├── Dockerfile # CPU version Dockerfile +│ │ ├── Dockerfile-arm64 # ARM64 architecture version +│ │ ├── Dockerfile-conda # Conda environment version +│ │ ├── Dockerfile-cpu # Pure CPU version +│ │ └── ... # Other platform versions +│ ├── examples/ # YOLO example code +│ └── tests/ # Test files +│ +└── frontend/ # Frontend project directory + ├── src/ + │ ├── views/ # Page views + │ │ ├── Login/ # Login page + │ │ ├── Dashboard/ # Dashboard + │ │ ├── Detection/ # Detection page + │ │ │ ├── detect_image.vue # Image detection + │ │ │ └── detect_video.vue # Video detection + │ │ ├── VideoHistory.vue # Video history + │ │ ├── Monitor/ # Monitoring page + │ │ └── UserInfoManage/ # User management + │ ├── components/ # Reusable components + │ ├── layout/ # Layout components + │ ├── router/ # Route configuration + │ ├── stores/ # Pinia state management + │ ├── api/ # API interfaces + │ ├── utils/ # Utility functions + │ └── assets/ # Static resources + ├── public/ # Public static resources + ├── package.json + └── vite.config.js +``` + +## 🚀 Quick Start + +### Environment Requirements + +- Python 3.8+ +- Node.js 20+ +- 4GB+ RAM +- CUDA-supported GPU (Optional, for accelerating inference) + +### Backend Installation + +1. Enter the backend directory: +```bash +cd backend +``` + +2. Create a virtual environment: +```bash +python -m venv venv +source venv/bin/activate # Linux/Mac +# or +venv\Scripts\activate # Windows +``` + +3. Install dependencies: +```bash +pip install -r requirements.txt +``` + +4. Initialize the database: +```bash +python seed.py +``` + +5. Start the service: +```bash +python app.py +``` + +The backend service will start on `http://localhost:5000`. + +### Frontend Installation + +1. Enter the frontend directory: +```bash +cd frontend +``` + +2. Install dependencies: +```bash +npm install +# or +pnpm install +``` + +3. Start the development server: +```bash +npm run dev +# or +pnpm dev +``` + +The frontend application will start on `http://localhost:5173`. + +### Docker Deployment + +#### CPU Version Deployment + +```bash +cd backend/docker +docker build -f Dockerfile-cpu -t older-fall-cpu . +docker run -p 5000:5000 older-fall-cpu +``` + +#### GPU Version Deployment + +```bash +cd backend/docker +docker build -f Dockerfile -t older-fall-gpu . +docker run --gpus all -p 5000:5000 older-fall-gpu +``` + +## 📖 Usage Instructions + +### 1. User Registration and Login + +Upon first use, you need to register an account and log in to the system. + +### 2. Image Fall Detection + +1. Enter the "Image Detection" page +2. Click the upload button to select the image to be detected +3. The system will automatically perform fall detection +4. View the detection results and confidence + +### 3. Video Fall Detection + +1. Enter the "Video Detection" page +2. Upload the video file to be detected (supports MP4, AVI formats) +3. The system analyzes video content frame by frame +4. After detection is complete, you can view the processed video and detection report + +### 4. Real-time Monitoring + +1. Enter the "Real-time Monitoring" page +2. Connect the camera device +3. The system will detect fall behaviors in the scene in real-time +4. Once a fall is detected, an alarm will be triggered immediately + +### 5. View History + +- View all detection records on the "History" page +- Filter history records by time and type +- Support viewing detailed information and original files + +## 🔧 Configuration Instructions + +### Backend Configuration + +The following parameters can be configured in `backend/app.py`: + +- `UPLOAD_FOLDER`: Uploaded file storage path +- `MAX_CONTENT_LENGTH`: Maximum uploaded file size +- `ALLOWED_EXTENSIONS`: Allowed file extensions + +### Model Configuration + +The model configuration file is located at `backend/ultralytics/cfg/default.yaml`, where you can adjust: + +- `model`: YOLO model selection (e.g., yolo11n.pt, yolo11s.pt) +- `conf`: Confidence threshold +- `iou`: NMS IoU threshold +- `imgsz`: Input image size + +## 📊 API Interface Documentation + +| Endpoint | Method | Description | +|------|------|------| +| `/api/register` | POST | User Registration | +| `/api/login` | POST | User Login | +| `/api/logout` | POST | Logout | +| `/upload_video` | POST | Upload Video | +| `/detect_video` | POST | Video Detection | +| `/detect` | POST | Image Detection | +| `/api/history` | GET | Get Detection History | +| `/api/history/` | DELETE | Delete History Record | +| `/api/stop_video` | POST | Stop Video Detection | +| `/api/start_camera` | POST | Start Camera | +| `/api/stop_camera` | POST | Stop Camera | +| `/video_feed` | GET | Video Stream | +| `/api/fall_statistics` | GET | Get Fall Statistics | + +## 🧪 Testing + +### Backend Testing + +```bash +cd backend +pytest tests/ -v +``` + +### Frontend Testing + +```bash +cd frontend +npm run test +``` + +## 📝 Directory Information + +### Backend Directory + +- `uploads/` - User uploaded original files and detection results +- `test_data/` - Example data for development and testing +- `instance/` - SQLite database file storage location + +### Frontend Directory + +- `src/views/` - Page components +- `src/components/` - Common components +- `src/api/` - API interface encapsulation +- `src/stores/` - State management + +## 🤝 Contributing Guide + +1. Fork this repository +2. Create a feature branch (`git checkout -b feature/AmazingFeature`) +3. Commit changes (`git commit -m 'Add some AmazingFeature'`) +4. Push to the branch (`git push origin feature/AmazingFeature`) +5. Open a Pull Request + +## 📄 License + +This project uses the MIT License - See the [LICENSE](backend/LICENSE) file for details + +## 📞 Contact Information + +- Project Address: https://gitee.com/archervr/older_fall +- Author: archervr + +## 🙏 Acknowledgements + +- [Ultralytics](https://ultralytics.com/) - YOLO Object Detection Framework +- [Vue.js](https://vuejs.org/) - Frontend Framework +- [Flask](https://flask.palletsprojects.com/) - Web Framework \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..91970fad88bf046b9125f5dac7c7ff7b336fb9a3 --- /dev/null +++ b/README.md @@ -0,0 +1,294 @@ + + +# 老人跌倒检测系统 (Older Fall Detection System) + +## 📋 项目简介 + +本项目是一个基于深度学习的老人跌倒检测系统,采用YOLO目标检测模型实现对视频和实时摄像头画面中跌倒行为的自动识别。系统提供完整的前后端解决方案,支持用户注册登录、视频上传检测、实时监控和历史记录查询等功能。 + +## ✨ 主要特性 + +- **高精度跌倒检测**:基于Ultralytics YOLO深度学习模型 +- **多种检测模式**:支持图片检测、视频检测和实时摄像头监控 +- **用户管理系统**:完整的注册、登录和认证功能 +- **历史记录追踪**:保存检测历史和视频文件 +- **邮件告警通知**:检测到跌倒时自动发送告警邮件 +- **可视化统计**:提供跌倒数据的统计分析图表 +- **Docker部署支持**:多平台Docker配置文件,便于快速部署 +- **响应式前端界面**:基于Vue3的现代化管理界面 + +## 🛠 技术栈 + +### 后端技术 +- **Python 3.11** - 开发语言 +- **Flask** - Web框架 +- **PyTorch 2.5.1** - 深度学习框架 +- **Ultralytics YOLO** - 目标检测模型 +- **SQLite** - 轻量级数据库 +- **OpenCV** - 图像处理 + +### 前端技术 +- **Vue 3** - 前端框架 +- **Element Plus** - UI组件库 +- **Vite** - 构建工具 +- **Pinia** - 状态管理 +- **ECharts** - 图表可视化 + +## 📁 项目结构 + +``` +older_fall/ +├── backend/ # 后端项目目录 +│ ├── app.py # Flask主应用文件 +│ ├── predict.py # 跌倒检测核心逻辑 +│ ├── train.py # 模型训练脚本 +│ ├── models.py # 数据库模型定义 +│ ├── seed.py # 数据初始化脚本 +│ ├── data.yaml # 数据集配置文件 +│ ├── data_split.py # 数据集划分脚本 +│ ├── detect.py # 检测脚本 +│ ├── coco_trans.py # COCO数据集转换 +│ ├── image_2_vedio.py # 图片转视频脚本 +│ ├── ultralytics/ # YOLO模型框架 +│ ├── templates/ # HTML模板 +│ ├── uploads/ # 上传文件存储目录 +│ ├── test_data/ # 测试数据 +│ │ ├── images/ # 测试图片 +│ │ └── videos/ # 测试视频 +│ ├── docker/ # Docker配置文件 +│ │ ├── Dockerfile # CPU版本Dockerfile +│ │ ├── Dockerfile-arm64 # ARM64架构版本 +│ │ ├── Dockerfile-conda # Conda环境版本 +│ │ ├── Dockerfile-cpu # 纯CPU版本 +│ │ └── ... # 其他平台版本 +│ ├── examples/ # YOLO示例代码 +│ └── tests/ # 测试文件 +│ +└── frontend/ # 前端项目目录 + ├── src/ + │ ├── views/ # 页面视图 + │ │ ├── Login/ # 登录页面 + │ │ ├── Dashboard/ # 仪表板 + │ │ ├── Detection/ # 检测页面 + │ │ │ ├── detect_image.vue # 图片检测 + │ │ │ └── detect_video.vue # 视频检测 + │ │ ├── VideoHistory.vue # 视频历史 + │ │ ├── Monitor/ # 监控页面 + │ │ └── UserInfoManage/ # 用户管理 + │ ├── components/ # 可复用组件 + │ ├── layout/ # 布局组件 + │ ├── router/ # 路由配置 + │ ├── stores/ # Pinia状态管理 + │ ├── api/ # API接口 + │ ├── utils/ # 工具函数 + │ └── assets/ # 静态资源 + ├── public/ # 公共静态资源 + ├── package.json + └── vite.config.js +``` + +## 🚀 快速开始 + +### 环境要求 + +- Python 3.8+ +- Node.js 20+ +- 4GB+ RAM +- CUDA支持的GPU(可选,用于加速推理) + +### 后端安装 + +1. 进入后端目录: +```bash +cd backend +``` + +2. 创建虚拟环境: +```bash +python -m venv venv +source venv/bin/activate # Linux/Mac +# 或 +venv\Scripts\activate # Windows +``` + +3. 安装依赖: +```bash +pip install -r requirements.txt +``` + +4. 初始化数据库: +```bash +python seed.py +``` + +5. 启动服务: +```bash +python app.py +``` + +后端服务将在 `http://localhost:5000` 启动。 + +### 前端安装 + +1. 进入前端目录: +```bash +cd frontend +``` + +2. 安装依赖: +```bash +npm install +# 或 +pnpm install +``` + +3. 启动开发服务器: +```bash +npm run dev +# 或 +pnpm dev +``` + +前端应用将在 `http://localhost:5173` 启动。 + +### Docker部署 + +#### CPU版本部署 + +```bash +cd backend/docker +docker build -f Dockerfile-cpu -t older-fall-cpu . +docker run -p 5000:5000 older-fall-cpu +``` + +#### GPU版本部署 + +```bash +cd backend/docker +docker build -f Dockerfile -t older-fall-gpu . +docker run --gpus all -p 5000:5000 older-fall-gpu +``` + +## 📖 使用说明 + +### 1. 用户注册与登录 + +首次使用时,需要注册账号并登录系统。 + +### 2. 图片跌倒检测 + +1. 进入"图片检测"页面 +2. 点击上传按钮选择要检测的图片 +3. 系统将自动进行跌倒检测 +4. 查看检测结果和置信度 + +### 3. 视频跌倒检测 + +1. 进入"视频检测"页面 +2. 上传待检测的视频文件(支持MP4、AVI格式) +3. 系统逐帧分析视频内容 +4. 检测完成后可查看处理后的视频和检测报告 + +### 4. 实时监控 + +1. 进入"实时监控"页面 +2. 连接摄像头设备 +3. 系统将实时检测画面中的跌倒行为 +4. 一旦检测到跌倒,立即触发告警 + +### 5. 查看历史记录 + +- 在"历史记录"页面查看所有检测记录 +- 可按时间、类型筛选历史记录 +- 支持查看详细信息和原始文件 + +## 🔧 配置说明 + +### 后端配置 + +在 `backend/app.py` 中可配置以下参数: + +- `UPLOAD_FOLDER`: 上传文件存储路径 +- `MAX_CONTENT_LENGTH`: 最大上传文件大小 +- `ALLOWED_EXTENSIONS`: 允许的文件扩展名 + +### 模型配置 + +模型配置文件位于 `backend/ultralytics/cfg/default.yaml`,可调整: + +- `model`: YOLO模型选择(如 yolo11n.pt, yolo11s.pt) +- `conf`: 置信度阈值 +- `iou`: NMS IoU阈值 +- `imgsz`: 输入图像尺寸 + +## 📊 API 接口文档 + +| 接口 | 方法 | 说明 | +|------|------|------| +| `/api/register` | POST | 用户注册 | +| `/api/login` | POST | 用户登录 | +| `/api/logout` | POST | 退出登录 | +| `/upload_video` | POST | 上传视频 | +| `/detect_video` | POST | 视频检测 | +| `/detect` | POST | 图片检测 | +| `/api/history` | GET | 获取检测历史 | +| `/api/history/` | DELETE | 删除历史记录 | +| `/api/stop_video` | POST | 停止视频检测 | +| `/api/start_camera` | POST | 启动摄像头 | +| `/api/stop_camera` | POST | 停止摄像头 | +| `/video_feed` | GET | 视频流 | +| `/api/fall_statistics` | GET | 获取跌倒统计数据 | + +## 🧪 测试 + +### 后端测试 + +```bash +cd backend +pytest tests/ -v +``` + +### 前端测试 + +```bash +cd frontend +npm run test +``` + +## 📝 目录说明 + +### 后端目录 + +- `uploads/` - 用户上传的原文件和检测结果 +- `test_data/` - 开发和测试用的示例数据 +- `instance/` - SQLite数据库文件存储位置 + +### 前端目录 + +- `src/views/` - 页面组件 +- `src/components/` - 通用组件 +- `src/api/` - API接口封装 +- `src/stores/` - 状态管理 + +## 🤝 贡献指南 + +1. Fork 本仓库 +2. 创建特性分支 (`git checkout -b feature/AmazingFeature`) +3. 提交改动 (`git commit -m 'Add some AmazingFeature'`) +4. 推送到分支 (`git push origin feature/AmazingFeature`) +5. 发起 Pull Request + +## 📄 许可证 + +本项目采用 MIT License - 详见 [LICENSE](backend/LICENSE) 文件 + +## 📞 联系方式 + +- 项目地址:https://gitee.com/archervr/older_fall +- 作者:archervr + +## 🙏 致谢 + +- [Ultralytics](https://ultralytics.com/) - YOLO目标检测框架 +- [Vue.js](https://vuejs.org/) - 前端框架 +- [Flask](https://flask.palletsprojects.com/) - Web框架 \ No newline at end of file