Backend Python Scripts Documentation
🗂️ Object Detection Module
Module: `object_detection.py`
Purpose: YOLO-based object detection
Key Functions |
Description |
`predict_from_cv2_frame()` |
Performs object detection on a frame using Ultralytics YOLO
model
|
Key Features |
Details |
Image Conversion |
Converts OpenCV frames to PIL images |
Image Resizing |
Resizes images to 640x640 for YOLO compatibility |
Detection Output |
Returns filtered bounding boxes with class names and
confidences
|
⚙️ Threshold Configuration
Module: `threshold_config.py`
Purpose: Manage and persist threshold
configuration
Class: `ThresholdConfig`
Configuration Factors |
Description |
`blur_factor` |
Sensitivity to image blur |
`movement_factor` |
Sensitivity to object movement |
`shake_factor` |
Sensitivity to camera shake |
Key Methods |
Functionality |
`load_config()` |
Load configuration from JSON |
`save_config()` |
Save configuration to JSON |
`update_factors()` |
Update individual factors |
🎬 Video Analyzer
Module: `video_analyzer.py`
Purpose: Analyze video characteristics for
detection
Class: `VideoAnalyzer`
Key Analysis Methods |
Description |
`analyze_video()` |
Processes entire video to determine baseline metrics |
`_calculate_thresholds()` |
Computes detection thresholds |
Metric Calculations |
Details |
Blur Detection |
Laplacian variance |
Movement Tracking |
Movement area calculation |
Shake Metric |
Shake computation |
Threshold Calculation |
Outlier removal for robust results |
📹 Video Processor
Module: `video_processor.py`
Purpose: Process videos for machine learning
dataset creation
Key Functions |
Description |
`process_video()` |
Main video processing function
- Extracts frames based on movement and quality
- Generates YOLO-compatible annotations
- Interacts with S3 for dataset management
|
`split_data()` |
Splits processed data into train/test/validation sets |
Advanced Features |
Details |
Class Management |
Dynamic class name management in YAML |
Data Split |
Configurable train/test/validation split ratios |
Storage |
S3 integration for dataset storage |
Frame Selection |
Based on movement, blur, and shake thresholds |