การวิเคราะห์วิดีโออัจฉริยะ
Detection, tracking, counting and real-time alerting
Why it matters
A 30-minute drone flight recorded at 30 frames per second holds about 54,000 frames. Nobody can watch all of them with full attention. Intelligent video analytics lets a computer do the first pass and hand only the interesting moments to a person. The work falls into four levels:
- Detection says what objects are in this frame and where.
- Tracking says that an object in this frame is the same one seen in the previous frame, and where it is heading.
- Counting counts objects that cross a line or enter an area, without counting any of them twice.
- Alerting raises a signal when a rule is met, for example a person staying inside a restricted zone for more than 10 seconds.
Each level depends on the one before it. Missed detections break tracks, broken tracks spoil counts, and spoiled counts make alerts untrustworthy. This page covers the whole chain. The lessons go deeper into the parts each course needs.
The processing pipeline
Most systems run as a chain of stages, called a pipeline:
- Decode the compressed stream (for example H.264) into individual frames.
- Detect with a deep-learning model such as the YOLO family. The output is a set of bounding boxes, each with a class label and a confidence score between 0 and 1.
- Track by matching boxes in the new frame to existing tracks and giving each object a track ID.
- Apply event logic to positions and IDs: line crossing, presence in a zone, loitering.
- Publish alerts, statistics or short clips for an operator to confirm.
The pipeline can run at the edge (an onboard or nearby computer), which reacts quickly and avoids sending full video to the ground, or on a ground server, which is more powerful but must wait for data over the radio link. Security work that needs immediate alerts usually runs at the edge. Structural inspection that is not time-critical is usually analysed after the flight.
Detection and how to measure it
A detector usually proposes several overlapping boxes around one object. Non-maximum suppression (NMS) removes heavily overlapping boxes and keeps the most confident one. Overlap is measured with IoU (intersection over union): the shared area divided by the combined area of the two boxes, from 0 to 1.
Detection quality needs two numbers read together:
- Precision = TP / (TP + FP): of everything the system reported, how much was real.
- Recall = TP / (TP + FN): of everything that was really there, how much the system found.
TP is a correct detection, FP a false alarm and FN a miss. Moving the confidence threshold trades one against the other. A low threshold gives high recall with many false alarms. A high threshold gives few false alarms and more misses. Benchmarks such as COCO summarise results as mAP over several IoU levels, but those numbers come from ordinary photographs. A model with a high COCO score can do poorly on aerial images where targets are only a few dozen pixels across, so always test on imagery from the actual job.
Tracking and counting
The most common approach is tracking-by-detection, for example SORT, which repeats three steps every frame:
- Predict where each track will be in the new frame with a constant-velocity Kalman filter.
- Associate predicted boxes with detected boxes, treating high IoU as a good match, and solve the whole matching at once with the Hungarian method.
- Update matched tracks, start new tracks for unmatched detections, and delete tracks that have gone unmatched for several frames.
The typical tracking error is an ID switch: two objects pass close to each other, or one is hidden, and their IDs swap. The CLEAR MOT metric MOTA combines misses, false alarms and ID switches into one number. Counting usually relies on a counting line: an object is counted when its track centre crosses from one side to the other, and each ID is counted once. If a track breaks and restarts with a new ID, the same object is counted again.
Example: counting cars from a hovering drone
Assume a drone hovers at 60 m with a nadir camera, 2.4 µm pixels and an 8.8 mm lens. Ground sample distance GSD = H × p / f = 60 × 2.4 × 10-6 / 8.8 × 10-3 ≈ 1.64 cm. A 4.5 m car is therefore about 275 pixels long. Cars travel at 15 m/s (54 km/h).
At 30 fps a car moves 0.5 m, about 31 pixels, between frames. For two equal boxes shifted along their length, IoU = (length − shift) / (length + shift):
| Processing rate (fps) | Shift per frame (px) | Frame-to-frame IoU |
|---|---|---|
| 30 | 31 | 0.80 |
| 15 | 61 | 0.64 |
| 10 | 92 | 0.50 |
| 5 | 183 | 0.20 |
If the tracker needs IoU of at least 0.3 to associate, processing at 5 fps cannot rely on box overlap and leans heavily on the Kalman prediction. If the onboard computer needs 8 ms to decode, 45 ms to detect and 3 ms to track, the total is 56 ms per frame, or about 17.9 fps. Processing every second frame (15 fps) still keeps IoU near 0.64, which is enough for reliable matching. All values are assumed.
From detections to alerts
A good alert is not sent every time the model sees something. It uses an event rule with several conditions:
- Zone: only objects inside a defined area such as a fence line or hazard area.
- Persistence: the same object must be seen in several consecutive frames, for example three. If false detections were random and independent at 0.05 per frame, three in a row would have a probability of about 0.000125. In practice false detections repeat in the same place (a shadow, a moving branch), so the real reduction is smaller.
- Dwell time: the object stays in the zone longer than a threshold.
- Direction: only inbound crossings count.
Operator workload matters as much as accuracy. Assume 20 real events in one night, recall 0.9 and precision 0.8. The system finds 18 events and raises about 4.5 false alarms. If precision drops to 0.2, false alarms rise to about 72, and operators start to ignore alerts, which is worse than receiving fewer alerts. Design the system so that a person confirms every event before anyone acts on it.
Common pitfalls
- Evaluating on imagery unlike the real job. Altitude, camera angle, lighting and season all change results. Keep a test set from the real site.
- Reporting overall accuracy only. When events are rare, a system that always answers "nothing" scores high accuracy. Report precision and recall.
- Ignoring end-to-end latency. Camera, encoding, radio link and display all add delay. Beyond about one second, gimbal tracking starts to oscillate or lag.
- Double counting after ID switches or broken tracks. Compare automatic counts with manual counts on sample clips before deployment.
- Forgetting personal data. Faces and number plates are personal data. Keep only what is needed and set a retention period.
- Letting the system decide. Analytics filter and rank. An inspector or operator still confirms before action.
Continue in the lessons
- UAT 307 Module 3: Object detection and tracking (four-year programme)
- UAT 362 Module 4: Anomaly analysis (continuing programme)
- UAT 453 Module 4: Finding defects (four-year programme)
- UAT 453 Module 10: Asset condition analysis and maintenance reporting (four-year programme)
- UAT 453 Module 13: Anomaly detection (four-year programme)
- UAT 454 Module 8: Event detection and object tracking (four-year programme)
Key references
- Szeliski, R. (2022). Computer vision: Algorithms and applications (2nd ed.). Springer. link
- OpenCV. OpenCV documentation. link
- Bewley, A., Ge, Z., Ott, L., Ramos, F., & Upcroft, B. (2016). Simple online and realtime tracking. In 2016 IEEE International Conference on Image Processing (pp. 3464–3468). link
- Bernardin, K., & Stiefelhagen, R. (2008). Evaluating multiple object tracking performance: The CLEAR MOT metrics. EURASIP Journal on Image and Video Processing, 2008, 246309. link
- Redmon, J., Divvala, S., Girshick, R., & Farhadi, A. (2016). You only look once: Unified, real-time object detection. In Proceedings of CVPR 2016 (pp. 779–788). link
- COCO Consortium. Detection evaluation. Common Objects in Context. link