Approach

One camera never moves, so we learn only what has to be learned, which is where the road users are. Everything else is explicit geometry and kinematics you can read, test and tune: when a car counts as stopped, which way a lane flows, how close two vehicles came.

Two parts, one perception stack

Part A: events

Reads the whole file, so it can smooth tracks in both directions. Frames are decoded in order and every second one goes to the detector at 960 px in FP16 batches of 16. ByteTrack links boxes into tracks. Kinematics turn tracks into speed, heading and acceleration. Fourteen rules turn those into segments, and post-processing makes the output valid.

Part B: risk

A separate copy of the same detector and tracker receives frames one at a time and never sees the future, the file or Part A's output. Every third frame it measures time to collision, braking, swerving, wrong-way motion and pedestrians on the road. A logistic combiner, a causal moving average and a one-second peak hold turn those measurements into a 0 to 1 score.

What is learned and what is a rule

StageKindDetails
Object detectionLearnedYOLO11m, COCO weights, FP16; 960 px for events, 640 px for risk. Keeps person, bicycle, car, motorcycle, bus and truck, plus animals and luggage for obstacles. YOLO11n on CPU.
TrackingAlgorithmByteTrack with a 30-frame buffer. Tracks are split at physically impossible jumps and short gaps are interpolated.
KinematicsRuleSavitzky-Golay smoothing (Part A) or least-squares windows (Part B). Speeds are normalised by the typical vehicle size at that image row, so one threshold works near and far.
SceneHand-drawn, with automatic fall-backLanes, stop lines, crosswalks and zones come from scene.json. When absent, the road surface and lane flow are learned from the video's own tracks.
EventsRuleOne class per file in roadsight/events/rules/; every threshold lives in configs/default.yaml.
RiskHand-set logistic, refittableWeights in weights/risk.json; tools/fit_risk.py refits them on labelled accidents.

The fourteen rules

A class that is predicted but never occurs adds a zero to the macro average, so each class ships only behind a confidence gate. Classes that need scene geometry stay silent until it is drawn.

ClassStarts whenEnds whenMain signalNeeds
stopped vehicleVehicle stopsMoves again or leavesBelow 0.1 BL/s for 10 s while same-direction traffic keeps passingauto road
congestionQueue stops movingQueue clearsMedian speed per travel direction below 0.2 BL/s with many vehiclesauto road
jaywalkingPedestrian steps onto the roadLeaves itFoot point inside the carriageway, away from crosswalks and parked carsauto road
wrong wayEnters against the flowBack in a correct lane or goneHeading against the lane flow for 1.5 s over at least one car lengthauto flow
accidentFirst contactEveryone involved stopsBox contact, speed collapse, then standing still or people appearingnone
near missEvasive action startsPair separatesTime to collision under 1 s plus braking or swerving above the video's own noisenone
red lightFront crosses the stop line on redClears the junctionSignal colour in a drawn box plus line crossingstop line, signal
stop lineStops past the line on redSignal turns greenStationary beyond the line during redstop line, signal
failure to yieldVehicle enters the crosswalkLeaves itPedestrian on the same crosswalk nearbyauto crosswalk
solid line crossingWheels reach the lineFully acrossFootprint straddles a drawn solid line, then stays on the other sidesolid lines
illegal U-turnTurn startsHeading settlesHeading change over 150° inside a no-U-turn zonezone
illegal turnTurn startsHeading settlesEntry and exit arms not in the allowed-movement tablearms, table
road obstacleObject appearsRemovedAnimal or luggage on the carriageway for several secondsauto road
fire or smokeSmoke appearsClearsFlame colour with flicker, persisting 3 soff by default

BL/s is body lengths per second: pixel speed divided by the typical vehicle size at that image row.

Constraints we designed around

Models, data and licences

ComponentLicenceUse
Ultralytics YOLO11 (m, s, n; COCO weights)AGPL-3.0Detection, unchanged COCO weights
ByteTrack (Ultralytics implementation)MIT / AGPL-3.0Multi-object tracking
COCOCC BY 4.0Training data of the detector weights
Organizer sample videosCompetition termsDevelopment labels and tuning