# 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!** 🎯