Condor AI Detection
The Notification project includes functions that poll the Condor AI detection API for smoke and fire events, persist structured detection data, and broadcast updates to the frontend in real time.
Overviewβ
The Condor integration runs on a 1-minute timer and processes detection events through the following pipeline:
- Poll β
PollCondorApirequests recent smoke/fire detections from the Condor API - Queue β Events are grouped by camera and queued to the
ai-detection-processorqueue - Process β
ProcessCameraEventsDequeuepicks up queued events and runs the processing pipeline - Persist β Events are stored in both Cosmos DB (for real-time state) and SQL Server (for historical queries)
- Broadcast β The latest detection is sent to connected frontend clients via SignalR
Detection Pipelineβ
Camera Matchingβ
Each Condor event includes a camera_id that may correspond to either a device's DeviceId or a stream's StreamId. The function attempts both matches against the camera configuration stored in Cosmos DB.
Events are filtered by:
- Environment β Camera must be enabled in the current deployment environment (dev, stg, prd)
- Public visibility β Camera must be marked as
IsAlertCaPublic
Detection Typesβ
| Type | Identifier | Description |
|---|---|---|
| 60 Detection | Output image path starts with /app/output/detections/ | Standard single-image detection |
| Pano Detection | Output image path starts with detections/panoramas/ | Panoramic multi-frame detection |
COCO Data Persistenceβ
Each Condor detection event may include structured COCO-format detection and annotation data. After the CondorCameraEvent is upserted to SQL Server, its generated Id is used as the foreign key for bulk-inserting the COCO data.
COCODetectionβ
Stores bounding-box detections with confidence scores:
| Column | Type | Source |
|---|---|---|
CondorCameraEventId | INT (FK) | From upserted CondorCameraEvent.Id |
DetectionId | INT | CocoDetectionDTO.ImageId |
CategoryId | INT | Detection category (smoke, fire) |
Score | DECIMAL(3,2) | Confidence score (0.00β1.00) |
BBox | NVARCHAR(255) | Bounding box coordinates (comma-separated) |
Lat, Lon | NVARCHAR(25) | Optional geolocation (nullable, for future use) |
EstimatedAzimuth | DECIMAL(10,2) | Optional azimuth estimate (nullable, for future use) |
COCOAnnotationβ
Stores richer annotation data including segmentation masks:
| Column | Type | Source |
|---|---|---|
CondorCameraEventId | INT (FK) | From upserted CondorCameraEvent.Id |
AnnotationId | INT | CocoAnnotationDTO.Id |
CategoryId | INT | Annotation category |
Score | DECIMAL(3,2) | Confidence score |
BBox | NVARCHAR(255) | Bounding box coordinates |
Segmentation | NVARCHAR(MAX) | Segmentation mask data (semicolon-separated) |
IsCrowd | INT | Whether the annotation represents a crowd region |
Area | BIGINT | Area of the annotation in pixels |
Bulk Insert Patternβ
Both detection and annotation data are inserted using table-valued parameters (TVPs) for performance. The stored procedures COCODetectionBulkInsert and COCOAnnotationBulkInsert delete existing rows for the event before inserting, ensuring idempotent upsert behavior.
Cosmos DB Stateβ
Active detection events are tracked in Cosmos DB as CondorEventEntity documents:
- TTL: 3 hours (auto-expire after detection activity stops)
- Event IDs: Accumulates all Condor event IDs associated with the camera
- Categories: Tracks all detected categories (smoke, fire) across updates
Camera Detection Flagsβ
After processing, the camera's operational document is patched with detection flags:
| Flag | Description |
|---|---|
HasAiDetectionHit | Set to true on any AI detection |
HasRecent60DetectionHit | Set to true for standard 60-second detections |
HasRecentPanoDetectionHit | Set to true for panoramic detections |
These flags are reset by the CleanupSmokeEvents function when no active events remain.
SignalR Broadcastingβ
After processing, the CondorCameraEvent (including PTZ values) is broadcast to the frontend via SignalR:
Target: "BroadcastLatestAiDetectionToGroup"
Group: {cameraId}
Data: CondorCameraEvent (with Pan, Tilt, Zoom, image URLs, category, detection type)