Inspiration

Road-crash data is rare and arrives late: by the time a junction shows up in the statistics, people have already been hurt. Meanwhile, traffic cameras record near-misses every day, and nobody has time to watch them. I live in Benin, where authorities must often decide which junctions to study or fix with almost no early-warning data. I wanted a tool that points a human expert to the moments worth inspecting, without pretending to replace their judgment.

What it does

VigiRoute analyses short traffic clips that are already labelled by site and camera (Site / Camera / clip.mp4). After one click it produces, for each clip:

  • Candidate events classified as collision, near-miss, possible conflict or routine interaction, with approximate timestamps and the analysis pass that found each one.
  • An annotated player that jumps to the moment and overlays tracked pedestrians and vehicles.
  • An exploratory proximity map computed from the tracked boxes.
  • Hypotheses and possible interventions (infrastructure changes or trained staff) that a human expert keeps, dismisses or marks "to verify on site", then exports with the report.
  • A red-light candidate scan where the expert confirms, rejects or marks each candidate as undetermined.

It does not predict crashes, issue fines, read plates or claim real-world distances. Every output is a hypothesis for a person to check.

How I built it

  • Muse Spark 1.3 reads each uploaded clip twice at 4 frames per second: a targeted near-miss scan, then an independent counter-review that hunts for events the first pass missed. Matching timestamps are merged and the pass that found each event stays visible. A third pass at 8 frames per second is triggered by signs of brief or fast motion. Results use a strict JSON Schema.
  • SAM 3.1 follows the concepts "pedestrian" and "motorized vehicle" through the video with instance tracking. A deterministic calculation turns the boxes into proximity candidates in image coordinates, so the language model does not decide the proximity score alone.
  • A zero-dependency Node.js server and a plain HTML/CSS/JavaScript interface, running only on 127.0.0.1.
  • Privacy by design: the key stays in memory, each batch needs explicit consent before video is sent to the provider, and the temporary provider file is deleted after analysis.
  • 39 automated tests covering event merging, timestamp checks, SAM parsing, MP4 frame timing and the HTTP guard.

Challenges I ran into

  • SAM rejected an fps field with HTTP 400, and in some runs returned no decodable boxes. I now omit fps and show an explicit diagnostic: an empty result is never presented as "no objects".
  • Large clips timed out during upload, so clips are limited to 45 seconds and 70 MB.
  • Early readings sometimes missed a brief near-miss, which led to the independent counter-review pass.
  • A malformed URL could crash the server. I reproduced it, fixed it and added a test.

What I learned

Separating semantic evidence (the language model) from geometric evidence (SAM tracks) makes the tool more honest: the interface shows when they agree, when only one found something, and when one returned nothing. I also learned to keep all claims modest: proximities are uncalibrated and timestamps are approximate.

What's next

An annotated benchmark to measure precision and recall, calibrated geometry, on-device blurring of faces and plates, and open-weight models that run locally so footage never leaves the machine.

Built With

Share this project:

Updates

Submission history