A high-performance, production-ready computer vision processing server built with FastAPI and OpenCV. This server provides real-time image and video analysis capabilities for smart surveillance systems, featuring state-of-the-art object detection, motion analysis, and people counting.
The FastAPI Processing Server serves as the intelligent backbone for surveillance systems, offering RESTful APIs for computer vision tasks. Designed for integration with Django web applications, it processes multimedia content and returns structured detection data for security monitoring, crowd management, and object tracking applications.
- Multi-object Detection: Identify persons, vehicles, animals, and everyday objects using YOLOv8 Nano
- Human-specific Detection: Specialized people detection combining HOG descriptors and Haar Cascades
- Motion Analysis: Frame differencing techniques for movement detection and activity monitoring
- Vehicle Recognition: Car, truck, motorcycle, and bus detection for traffic and parking monitoring
- Crowd Analytics: People counting and density estimation for crowd management
- Image Processing: Single-image analysis with sub-3-second response times
- Video Analysis: Frame-by-frame processing with progress tracking
- Batch Operations: Background job processing for long-running video analyses
- Smart Model Management: On-demand model loading and caching system
- Bounding Box Intelligence: Precise object localization with confidence scoring
- Multi-class Classification: Categorization of detected objects into 80+ COCO classes
- Confidence Thresholding: Adjustable sensitivity for detection accuracy
- Size-based Filtering: Exclusion of objects below configurable size thresholds
- FastAPI Framework: Async-ready, high-performance API framework with automatic OpenAPI documentation
- Modular Design: Separated concerns with independent processing modules
- Background Processing: Job queue system for non-blocking video analysis
- Memory Optimization: Designed for 512MB RAM constraints with efficient model loading
Input โ Validation โ Processing โ Detection โ Aggregation โ Response
โ โ โ โ โ โ
File Check โ Decoding โ Preprocessing โ YOLOv8/HOG โ JSON Format โ API Response
- Primary Model: YOLOv8 Nano (6.2MB) - 80-class object detection
- Supplementary Models:
- OpenCV HOG Descriptor for people detection
- Haar Cascade Classifier for face detection
- Traditional CV algorithms for motion analysis
- Image Processing: < 3 seconds end-to-end latency
- Video Processing: Asynchronous with progress reporting
- Throughput: Concurrent processing with configurable worker limits
- Memory Usage: Optimized for Render.com free tier (512MB RAM)
- Person Detection: >85% accuracy in varied lighting conditions
- Object Recognition: 80+ classes with COCO dataset compatibility
- Confidence Scoring: Adjustable thresholds (0.1-0.9) per detection type
- Size Filtering: Configurable minimum detection dimensions
- Supported Formats: JPEG, PNG, MP4, AVI, MOV
- Size Limits: Images โค 10MB, Videos โค 50MB
- Processing: In-memory for images, chunked for videos
- Validation: MIME type verification and malicious content checks
POST /api/v1/process/image: Single-image analysis with immediate resultsPOST /api/v1/process/video: Video processing with job queuingGET /api/v1/jobs/{job_id}/status: Real-time progress monitoringGET /api/v1/jobs/{job_id}/results: Retrieval of completed analysesGET /api/v1/models: Available model inventory and status
- Health Endpoints: System status, resource utilization, and service health
- Metrics API: Processing statistics, success rates, and performance metrics
- Model Management: Dynamic model loading, warming, and version control
- Configuration API: Runtime adjustment of processing parameters
- Webhook Support: Callback URLs for asynchronous result delivery
- Batch Processing: Multiple file processing in single requests
- Format Conversion: Input normalization across different media types
- CORS Configuration: Domain-restricted access for security
- API Key Validation: HMAC-based key verification per request
- JWT Support: Optional token-based authentication for user-level access
- Rate Limiting: Request throttling per API key and IP address
- Access Logging: Comprehensive audit trail of all processing requests
- File Sanitization: Malware scanning and format verification
- Temporary Storage: Ephemeral file handling with automatic cleanup
- No Data Persistence: Processing-only architecture with no permanent storage
- Encryption: HTTPS enforcement with TLS 1.3 support
- Input Validation: Strict bounds checking for all parameters
- Error Obfuscation: Secure error messages without information leakage
- DDoS Protection: Request filtering and connection limiting
- CORS Policies: Origin-based request filtering
{
"success": true,
"processing_time": 1.23,
"detections": [
{
"label": "person",
"confidence": 0.92,
"bbox": [120, 85, 310, 480],
"type": "person",
"attributes": {
"is_moving": true,
"estimated_height": 175
}
}
],
"summary": {
"total_objects": 5,
"people_count": 3,
"vehicles_count": 2,
"dominant_object": "person"
},
"metadata": {
"image_dimensions": "1920x1080",
"model_version": "yolov8n-v1.2",
"timestamp": "2024-01-15T10:30:00Z"
}
}{
"job_id": "vid_abc123xyz",
"status": "processing",
"progress": 45.2,
"estimated_completion": "2024-01-15T10:32:15Z",
"current_metrics": {
"frames_processed": 1350,
"detections_per_frame": 2.3,
"processing_speed": "22.5 fps"
},
"preview_results": {
"peak_activity_frame": 650,
"total_unique_objects": 42,
"activity_timeline": [/* condensed timeline data */]
}
}- Direct API Calls: Synchronous image processing during upload
- Webhook Pattern: Asynchronous video analysis with callback URLs
- Polling Mechanism: Status checking for long-running jobs
- Batch Operations: Bulk processing of surveillance footage
- RESTful Interface: Standard HTTP/JSON for easy integration
- WebSocket Support: Real-time progress updates (optional)
- Webhook Configuration: Customizable callback endpoints
- API Client Libraries: Python SDK for simplified integration
Surveillance Camera โ Django App โ FastAPI Server โ Analysis Results โ Django DB
โ โ โ โ โ
Video Stream โ Upload & Metadata โ Processing โ JSON Results โ Storage & UI
- Development: Local Docker Compose with hot-reload
- Staging: Render.com preview deployments
- Production: Render.com with auto-scaling capabilities
- Docker Optimization: Multi-stage builds for minimal image size
- Layer Caching: Efficient build processes for frequent deployments
- Health Checks: Liveness and readiness probes for orchestration
- Resource Limits: Memory and CPU constraints for fair sharing
- Render.com Blueprint: Infrastructure-as-code deployment
- Environment Variables: Secure configuration management
- Log Aggregation: Structured logging with remote log shipping
- Monitoring Integration: Health check endpoints for uptime monitoring
- Stateless Design: Any instance can handle any request
- Job Queue: Distributed task processing capabilities
- Load Balancing: Ready for multi-instance deployment
- Cache Sharing: Redis-backed job and model caching
- Model Warm-up: Pre-loading of detection models on startup
- Connection Pooling: Efficient database and external service connections
- Memory Management: Aggressive cleanup and garbage collection
- CPU Optimization: Multi-threading for parallel frame processing
- Performance Metrics: Response times, error rates, throughput
- Resource Tracking: CPU, memory, and I/O utilization
- Business Metrics: Processed files, detection counts, accuracy rates
- Alerting: Proactive notification of system issues
- Multi-model ensemble voting for improved accuracy
- GPU acceleration support for compatible deployments
- Custom model upload and training pipeline
- Advanced analytics: loitering detection, path prediction
- Edge computing deployment package
- Federated learning capabilities
- Anomaly detection with unsupervised learning
- Multi-camera correlation and tracking
- 3D scene understanding from 2D feeds
- Predictive analytics for crowd behavior
- Cross-camera person re-identification
- Natural language query interface for footage
- RESTful API design principles
- OpenAPI 3.0 specification compliance
- Semantic versioning for API changes
- Conventional commits for development workflow
- Comprehensive unit and integration testing
- Performance benchmarking suite
- Security vulnerability scanning
- Code quality and style enforcement
- Interactive API documentation (Swagger UI)
- Architecture decision records
- Deployment runbooks
- Troubleshooting guides
Status: Production Ready
Version: 1.0.0
Maintenance: Actively Developed
License: Proprietary