Skip to content

trajlab

trajlab turns raw vehicle trajectories from drone and overhead-camera recordings into clean tracks with lanes, lane changes and surrounding vehicles. It is for researchers and traffic engineers who want to analyze driving behavior on public datasets or on their own recordings.

First run

Install trajlab from source with matplotlib for the figures (Python 3.11 or newer). Then run the quickstart, which needs no download:

git clone https://github.com/baumarv/trajlab.git
cd trajlab
pip install ".[viz]"
python examples/quickstart.py

The quickstart generates a synthetic motorway, runs the processing chain on one travel direction, prints the lane changes and writes a figure of where the vehicles drive. Its core is a few lines:

import trajlab

raw = trajlab.examples.synthetic_motorway(duration_s=40.0)  # synthetic drone data, no download
ref_east, ref_west = trajlab.estimate_ref_lines(raw)  # one reference line per travel direction
config = trajlab.load_preset("drone_hgv_paper", site={"lanes": {"n_main_lanes": 3}})
result = trajlab.run_pipeline_detailed(raw[raw["orientation"] > 0], ref_east, config)
print(result.events.head())

The chain runs one travel direction at a time (orientation is +1 or −1). A preset is a ready-made configuration for a kind of recording, and the site settings describe the road, here three main lanes. The repository README shows how to bring your own trajectories from a CSV file.

Reading order

  1. Example: lane changes on NGSIM: a complete run on public data, from the raw file to a table of lane changes.
  2. Adapting the configuration to a dataset: which settings to check for a new kind of recording, and checks that need no ground truth.
  3. Using single processing steps: one step at a time instead of the whole chain.
  4. Pipeline steps: what each of the eleven steps does, with its inputs, outputs and options. Then the method and its limitations.

For looking things up: configuration, dataset readers, the I-24 MOTION dataset, output format, glossary and the API reference, generated from the docstrings. Contributors find the code style here. The repository README also describes how to reproduce the paper submitted to ANT 2027.