Image Acquisition Engine
The Image Acquisition Engine (Alert.CA.ImageAcquisition) is the primary application in the solution. It is an Azure Functions v4 app using Durable Functions with the Netherite backend to continuously capture images from hundreds of cameras in parallel through long-running orchestration loops.
Architecture Overviewโ
Tech Stackโ
| Component | Technology |
|---|---|
| Runtime | .NET 10, Azure Functions v4 (Isolated Worker) |
| Orchestration | Durable Functions with Netherite backend |
| Netherite Config | Max 2000 orchestrators, 4000 activities, 32 partitions |
| Hub Name | imgacqhub |
| Image Processing | Emgu.CV (OpenCV), System.Drawing |
| Camera Protocol | VAPIX via IVAPIXClient |
| Real-time | SignalR Client (auto-reconnect with exponential backoff) |
| Monitoring | Application Insights (custom telemetry) |
| Config | Azure App Configuration + Key Vault |
Project Structureโ
Alert.CA.ImageAcquisition/
โโโ Program.cs # DI registration + middleware
โโโ host.json # Netherite + function host config
โโโ Functions/
โ โโโ CameraOrchestratorFunction.cs # Main entry point (Cosmos trigger)
โ โโโ RefreshPTZForFE.cs # Timer: sync PTZ to frontend entity
โ โโโ VapixOrchestrations/
โ โ โโโ VapixOrchestrator.cs # Orchestration lifecycle manager
โ โ โโโ BaseOrchestrationFunction.cs # Eternal loop (~350 lines)
โ โ โโโ StandardModeFunctions.cs # SINGLE + PANO capture
โ โ โโโ TurboModeFunctions.cs # High-speed wrapper
โ โ โโโ LeaseModeFunctions.cs # Manual control mode
โ โ โโโ IntervalAcquisitionFunctions.cs # Time-interval base
โ โ โโโ IO/
โ โ โโโ RequestImageFunctions.cs # Single image activity
โ โ โโโ RequestPanoImagesFunctions.cs # Panoramic image activity
โ โ โโโ CameraMovementFunctions.cs # 7 PTZ activity functions
โ โ โโโ CameraControlQueueFunctions.cs # 6 HTTP endpoints for PTZ
โ โ โโโ SubmitCameraStatusFunctions.cs # ESRI status reporting
โ โโโ MobotixOrchestrations/
โ โ โโโ MobotixOrchestrator.cs # Skeleton (future)
โ โโโ OrchestrationManagement/
โ โโโ GetDurableEntityFunctions.cs # Query entity state
โ โโโ PurgeAllOrchestrations.cs # Cleanup all
โ โโโ PurgeSingleOrchestration.cs # Cleanup one
โ โโโ ResetAllOrchestrations.cs # Reset all
โ โโโ ResetFailedOrchestrations.cs # Reset failed
โโโ Services/
โ โโโ BaseImageStorageService.cs # Abstract base for image storage
โ โโโ SingleImageStorageService.cs # Single image + thumbnail
โ โโโ PanoImageStorageService.cs # Panoramic stitching + storage
โ โโโ PreStitchedImageStorageService.cs # Pre-stitch ZIP archive
โ โโโ SignalRConnectionService.cs # Real-time broadcasting
โ โโโ DurableDataStoreService.cs # Entity state โ Table Storage
โโโ Middleware/
โ โโโ CorsMiddleware.cs # Local dev CORS
โโโ Utilities/
โโโ OrchestrationModeHelper.cs # Mode state transitions
Key Conceptsโ
- Eternal Orchestration โ Each camera runs an infinite orchestration loop using
ContinueAsNew(). The loop captures images, checks for commands, sleeps, and repeats forever until explicitly terminated. - Durable Entities โ Per-camera
CameraStateentities maintain mode, PTZ position, command queues, and timing data across orchestration restarts. - Activity Functions โ All I/O (camera communication, image storage, ESRI updates) is isolated in activity functions so failures don't crash the orchestration.
- Cosmos Change Feed Trigger โ The engine reacts to device configuration changes in real-time, starting/stopping orchestrations automatically.
Documentation Sectionsโ
- Cosmos DB Change Feed Trigger โ How the engine starts, stops, and redeploys orchestrations
- Orchestration Lifecycle โ VapixOrchestrator lifecycle management and the eternal loop pattern
- Acquisition Modes โ SINGLE, PANO, LEASED, and TURBO mode behavior
- Activity Functions โ Image capture, camera movement, and status reporting
- Camera Control Queue โ HTTP endpoints for real-time PTZ/focus/brightness commands
- SignalR Integration โ Real-time image metadata broadcasting
- Orchestration Management โ Admin endpoints for querying, purging, and resetting orchestrations
- Telemetry & Monitoring โ Application Insights custom metrics