File size: 4,708 Bytes
cb3c674 | 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 170 171 172 173 | # Quick Start: Bounding Boxes & Analysis Models
## π― What's New
### 1. Green Bounding Boxes Around Persons
- **Visual**: Green rectangles around each detected person
- **Label**: "Person" + confidence score (e.g., "Person 0.95")
- **Real-time**: Updates as persons move in frame
### 2. Advanced Analysis Models
- **Fight Detection**: Identifies physical conflicts
- **Behavior Analysis**: Analyzes suspicious activities
- **Models**: Located in `ai_models/analysis_models/`
### 3. Enhanced Detection Tracking
- **Bounding Box Data**: Stored in database
- **Coordinates**: x1, y1, x2, y2 for each person
- **Confidence**: Detection confidence per person
---
## π How to Use
### Enable Bounding Box Detection
1. Go to **Live Camera** page
2. Click "π€ Select Detection Models"
3. Check:
- β
**Object Detection** (for person detection)
- β
**Advanced Analysis** (for fight/behavior analysis)
4. Click "βοΈ Apply Selection"
5. Click "βΆοΈ Start Camera"
6. **Green boxes appear!** π¦
### View Bounding Box Data
- **Live Display**: Green boxes on camera feed
- **Statistics**: Person detection count updates in real-time
- **Database**: All detections stored with coordinates
---
## π Model Details
| Model | Description | Location |
|-------|-------------|----------|
| YOLO | Person/object detection | `object_detection/yolov8n.pt` |
| Fight Detection | Identifies fights | `analysis_models/fight_detection_model.h5` |
| CustomCNN | Behavior analysis | `analysis_models/CustomCNN*.h5` |
---
## π¨ Visual Elements
### Bounding Box Format
```
βββββββββββββββββββββββββββββββββββ
β Person 0.95 β β Label with confidence
β β
β ββββββββββββββββββββββββ β
β β β β
β β [Person in] β β β Green box (detected person)
β β β β
β ββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββ
```
### Statistics Display
```
π€ Person Detected: 5 β Total persons detected
ποΈ Person Present: β
Yes β Currently present
```
---
## πΎ Database Storage
Each detection includes:
- **person_count**: How many people detected
- **confidence**: Average confidence score
- **bounding_boxes**: Coordinates for each person
- **timestamp**: When detection occurred
---
## π§ Configuration
### Enable in Model Config
File: `config/model_config.py`
```python
'analysis': {
'candidates': [
MODELS_DIR / "analysis_models" / "fight_detection_model.h5",
MODELS_DIR / "analysis_models" / "CustomCNN150.h5",
],
'description': 'Advanced Analysis Model (Fight/Behavior Detection)'
}
```
### Load in App
File: `app.py`
```python
from tensorflow import keras
analysis_model = keras.models.load_model(model_path)
```
---
## π Code Examples
### Using Bounding Box Data
**Frontend (JavaScript)**:
```javascript
// Record person detection with bounding boxes
recordPersonDetection([
{
class: 'person',
confidence: 0.95,
bbox: [100, 50, 200, 300]
}
]);
```
**Backend (Python)**:
```python
# Draw bounding boxes
video_processor._draw_person_bounding_boxes(frame, detections)
# Results include bbox data
for det in detections:
if det['class'] == 'person':
x1, y1, x2, y2 = det['bbox']
confidence = det['confidence']
```
---
## β
Verification Checklist
- [ ] Models loaded successfully (check console)
- [ ] "Advanced Analysis" appears in model selection
- [ ] Bounding boxes visible on camera feed
- [ ] Person detection count increasing
- [ ] Database storing coordinates
- [ ] Statistics updating in real-time
---
## π Troubleshooting
| Issue | Solution |
|-------|----------|
| No bounding boxes | Enable "Object Detection" model |
| Analysis model error | Install TensorFlow: `pip install tensorflow` |
| Database not saving | Check user is logged in |
| Slow performance | Reduce frame resolution or skip frames |
---
## π Full Documentation
See detailed documentation:
- **Full Guide**: `docs/BOUNDING_BOXES_AND_ANALYSIS_MODELS.md`
- **Person Detection**: `docs/PERSON_DETECTION_FEATURE.md`
- **Frontend**: `docs/FRONTEND_ENHANCEMENTS.md`
---
**Ready to detect!** π―
|