TATraffic Analyzer

Problem and approach

Detector, tracker, aligned scene map, rules

The task: given a clip from one fixed junction camera, return every traffic event as [start_sec, end_sec, label] over 14 classes, scored by temporal-IoU F1 at 0.3, 0.5 and 0.7. We manually labelled event intervals in all four sample clips and fine-tuned the object detector on annotated frames. Traffic rules use tracked objects and a scene map.

Pipeline

  1. MP4 video
    4K, 29.97 fps, fixed camera
  2. Frame samplingRule-based
    Decode once, analyse a subset of frames
  3. YOLO detectorLearned
    Fine-tuned, 8 classes incl. red/green signal heads
  4. ByteTrackRule-based
    Track ids and trajectories per road user
  5. Scene alignmentRule-based
    SIFT + RANSAC homography maps scene.json onto the clip
  6. Event rulesRule-based
    Per-class geometry and timing rules on tracks and zones
  7. Segment mergingRule-based
    Merge fragments, drop blips, no same-class overlap
  8. Events
    [start_sec, end_sec, label]

Blue border = learned component. Everything else is deterministic code whose thresholds are listed below.

What is learned and what is rule-based

Learned: the object detector only. Rule-based: tracking association, scene alignment, every event decision and segment post-processing. Rules are inspectable and need no event labels, and the camera angle is fixed, so one scene map, re-aligned per clip, covers the hidden test set.

Models and data

  • YOLO (Ultralytics), fine-tuned: 8 classes: car, bus, truck, motorcycle, bicycle, person, red light, green light. Weights ship in weights/. Signal heads as detector classes let rules know the phase without a separate classifier.
  • ByteTrack (via Ultralytics) links detections into tracks, which every rule needs for direction, speed and dwell time.
  • OpenCV SIFT + RANSAC estimates one homography per clip from stationary features against a bundled reference frame.
  • Fine-tuning used annotated frames from the four organizer-provided videos only. No public dataset was added.

Why this design

  • Four manually labelled clips give us a small dev set for tuning, while explicit rules use the scene layout directly.
  • The hidden set uses the same camera and angle, so a hand-drawn map of lanes, stop lines, crossings and the island transfers, once alignment absorbs the small framing shifts we measured.
  • Boundaries decide the score at IoU 0.7. Rules give exact start and end frames tied to the task's own conventions (for example red_light starts when the front crosses the stop line).
  • One detector pass shares tracks across all implemented rules, reducing repeated inference.

Per-class logic

7 of 14 classes have a detector today. The others are listed with the approach we would try next. The harness only scores classes we predict or that occur, so we do not emit guesses.

ClassStatusHow it is decided
CollisionaccidentNot yetNot detected yet. Candidate: box overlap plus abrupt stop of both tracks.
Near missnear_missNot yetNot detected yet. Candidate: time-to-collision below a threshold plus sharp deceleration.
Red-light runningred_lightRuleThe estimated front edge of a vehicle crosses a stop line while the signal counts as red: a red head is detected, or no green head was seen in the last 25 processed frames.
Wrong-way drivingwrong_wayNot yetNot detected yet. Candidate: track heading against the lane direction from scene.json.
Illegal U-turnillegal_u_turnNot yetNot detected yet. Candidate: heading change above 150° inside a no-U-turn zone.
Stopped vehiclestopped_vehicleNot yetNot detected yet. Candidate: stationary track for 10 s or more outside signal queues.
Pedestrian on roadwayjaywalkingRulePerson ground point inside the carriageway polygon and outside every crossing, refuge island and kerb waiting zone.
Not yielding to a pedestrianfailure_to_yieldRuleA tracked vehicle traverses a crossing polygon while a person is inside the same crossing; the event spans its traversal.
Illegal turnillegal_turnRuleA vehicle enters the junction, leaves it and then crosses the south-east crossing, a turn the markings prohibit from that approach.
Solid line crossingsolid_line_crossingRuleA box corner crosses a solid marking segment; the event ends when the vehicle is fully inside the target lane.
Stop-line violationstop_lineRuleA vehicle rests within 30 px of a stop line during red without entering the junction.
CongestioncongestionRuleAt least 75% of vehicles in a lane-direction group move slower than 0.6 box heights per second for 2 s; closes after 1 s clear.
Obstacle on roadroad_obstacleNot yetNot detected yet. Needs a detector beyond the 8 road-user classes.
Fire or smokefire_smokeNot yetNot detected yet. Needs a smoke/fire classifier.

Scene map

Polygons and lines in normalised coordinates, drawn once on C3897 at 287 s and stored in scene.json: carriageway, lanes with travel direction, crossings, refuge island, kerb waiting zones, stop lines and solid markings.

Scene map overlaid on the camera view
Scene map drawn over the reference frame.