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
- Go to Live Camera page
- Click "π€ Select Detection Models"
- Check:
- β Object Detection (for person detection)
- β Advanced Analysis (for fight/behavior analysis)
- Click "βοΈ Apply Selection"
- Click "βΆοΈ Start Camera"
- 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
'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
from tensorflow import keras
analysis_model = keras.models.load_model(model_path)
π Code Examples
Using Bounding Box Data
Frontend (JavaScript):
// Record person detection with bounding boxes
recordPersonDetection([
{
class: 'person',
confidence: 0.95,
bbox: [100, 50, 200, 300]
}
]);
Backend (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! π―