Skip to main content

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:

  1. Poll β€” PollCondorApi requests recent smoke/fire detections from the Condor API
  2. Queue β€” Events are grouped by camera and queued to the ai-detection-processor queue
  3. Process β€” ProcessCameraEventsDequeue picks up queued events and runs the processing pipeline
  4. Persist β€” Events are stored in both Cosmos DB (for real-time state) and SQL Server (for historical queries)
  5. 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​

TypeIdentifierDescription
60 DetectionOutput image path starts with /app/output/detections/Standard single-image detection
Pano DetectionOutput 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:

ColumnTypeSource
CondorCameraEventIdINT (FK)From upserted CondorCameraEvent.Id
DetectionIdINTCocoDetectionDTO.ImageId
CategoryIdINTDetection category (smoke, fire)
ScoreDECIMAL(3,2)Confidence score (0.00–1.00)
BBoxNVARCHAR(255)Bounding box coordinates (comma-separated)
Lat, LonNVARCHAR(25)Optional geolocation (nullable, for future use)
EstimatedAzimuthDECIMAL(10,2)Optional azimuth estimate (nullable, for future use)

COCOAnnotation​

Stores richer annotation data including segmentation masks:

ColumnTypeSource
CondorCameraEventIdINT (FK)From upserted CondorCameraEvent.Id
AnnotationIdINTCocoAnnotationDTO.Id
CategoryIdINTAnnotation category
ScoreDECIMAL(3,2)Confidence score
BBoxNVARCHAR(255)Bounding box coordinates
SegmentationNVARCHAR(MAX)Segmentation mask data (semicolon-separated)
IsCrowdINTWhether the annotation represents a crowd region
AreaBIGINTArea 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:

FlagDescription
HasAiDetectionHitSet to true on any AI detection
HasRecent60DetectionHitSet to true for standard 60-second detections
HasRecentPanoDetectionHitSet 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)