abbosaliboev/worker-abnormal-behavior-detection
GitHub: abbosaliboev/worker-abnormal-behavior-detection
基于 YOLO11n-pose 姿态估计与 ByteTracker 跟踪,利用生物力学规则实时检测工人跌倒、不安全奔跑和长时间静止的无需训练的工业安全监控系统。
Stars: 0 | Forks: 0
# 工人异常行为检测
一个基于规则的实时系统,利用姿态估计和目标跟踪来检测工人的异常行为。无需训练模型 —— 将纯粹的生物力学规则应用于 YOLO11n-pose 关键点。
**[한국어](README_KO.md) | [O'zbek](README_UZ.md)**
## 检测行为
| 行为 | 描述 | 准确率 |
|---|---|---|
| **跌倒检测** | 检测工人何时突然跌倒 | 92.4% |
| **不安全奔跑** | 检测在受限/危险区域内的奔跑行为 | 91.0% |
| **长时间静止** | 检测保持静止超过 5 分钟的工人 | 95.8% |
## 项目结构
```
worker-abnormal-behavior-detection/
│
├── fall_detection/ # Fall Detection module
│ ├── detector.py # Detection logic (rules)
│ └── evaluate.py # Evaluation script
│
├── running_detection/ # Unsafe Running module
│ ├── detector.py # Detection logic (rules)
│ └── evaluate.py # Evaluation script
│
├── inactivity_detection/ # Long-time Inactivity module
│ ├── detector.py # Detection logic (rules)
│ └── evaluate.py # Evaluation script
│
├── src/ # Shared core modules
│ ├── config.py # All thresholds and settings
│ ├── pose_extractor.py # YOLO11n-pose + ByteTracker
│ ├── feature_extractor.py # Biomechanical feature computation
│ └── behavior_monitor.py # Orchestrates all three detectors
│
├── datasets/ # Dataset utilities
│ ├── npy_loader.py # Load pre-extracted keypoints (X.npy)
│ └── download_running.py # Download KTH Action dataset
│
├── evaluation/
│ └── feature_utils.py # Shared feature extraction helper
│
├── main.py # Real-time demo entry point
├── requirements.txt
├── REPORT.md # Detailed technical report
└── README.md / README_UZ.md / README_KO.md
```
## 工作原理
```
CCTV / Camera
↓
YOLO11n-pose → 17 body keypoints per person
↓
ByteTracker → Unique ID assigned to each worker
↓
┌──────────────────┬──────────────────┬──────────────────┐
│ fall_detection/ │running_detection/│inactivity_ │
│ detector.py │ detector.py │detection/ │
│ │ │ detector.py │
└──────────────────┴──────────────────┴──────────────────┘
↓
Alert (FALL | RUNNING | INACTIVITY)
```
### 跌倒检测逻辑
- 计算 **身体倾斜角度** 和 **角度变化率** (°/sec)
- 规则:`body_angle > 70° AND angle_rate > 65°/sec`
- 核心见解:跌倒发生得非常快 (74–140°/sec),而故意的躺下动作很慢 (2–5°/sec)
### 不安全奔跑逻辑
- 逐帧跟踪 **水平质心速度**
- 规则:`horizontal_speed > calibrated_threshold`
- 在侧向摄像机设置中,奔跑速度大约是步行的 2 倍
### 静止逻辑
- 测量 **静止帧占比** 和 **姿态稳定性**
- 规则:`still_fraction > 0.70 AND body_angle_std < 3.5°`
- 计时器:在持续静止 5 分钟后触发警报
## 结果
| 检测器 | 准确率 | 数据集 | 协议 |
|---|---|---|---|
| 跌倒 | **92.40%** ± 3.4% | UP-Fall (4 名受试者) | LOOCV |
| 奔跑 | **90.99%** ± 0.4% | KTH Action (25 名受试者) | LOOCV |
| 静止 | **95.83%** ± 4.2% | UP-Fall (4 名受试者) | LOOCV |
| **平均值** | **93.07%** | | |
## 数据集
### UP-Fall Detection 数据集
- Martinez-Velasco 等人,*Data* 2019
- 活动:跌倒(5 种类型)、行走、站立、坐下、捡起物品
- 用于:跌倒和静止评估
### KTH Action 数据集
- Schuldt 等人,*ICPR* 2004
- 25 名受试者,200 个片段(100 个奔跑 + 100 个行走)
- 用于:奔跑检测评估
## 安装
```
pip install -r requirements.txt
```
**环境要求:** Python 3.10+、PyTorch、Ultralytics YOLO、OpenCV、SciPy
## 评估
分别运行每个检测器的评估:
```
# 跌倒检测 → 92.4%
python -m fall_detection.evaluate
# 不安全奔跑 → 91.0%
python -m running_detection.evaluate
# 长时间不活动 → 95.8%
python -m inactivity_detection.evaluate
```
在运行检测评估之前下载 KTH 数据集:
```
python -m datasets.download_running
```
## 实时演示
```
# Webcam
python main.py
# 视频文件
python main.py --source path/to/video.mp4
# RTSP 流
python main.py --source rtsp://192.168.1.10/stream
```
## 核心技术
- **YOLO11n-pose** — 实时 17 关键点姿态估计
- **ByteTracker** — 多人持久 ID 跟踪
- **Butterworth Filter** — 用于跌倒运动学的信号平滑
- **基于规则的逻辑** — 无需模型训练,完全可解释
标签:YOLO, 凭据扫描, 姿态估计, 目标跟踪, 行为识别, 计算机视觉, 逆向工具