Skip to main content

OTAnalytics

PyPI version Tests Tests

OTAnalytics is a core module of the OpenTrafficCam framework designed to perform traffic analysis on trajectories of road users tracked by OTVision or other tools in videos recorded by OTCamera or other camera systems.

Overview

OTAnalytics provides tools for analyzing traffic data, including:

  • Processing trajectory data of road users
  • Defining and analyzing traffic flows
  • Counting vehicles/road users assigned to flows
  • Generating event lists and statistics
  • Visualizing traffic data

The application offers multiple user interfaces:

  • A graphical desktop interface (using CustomTkinter)
  • A command-line interface for automation and batch processing

Installation

Requirements

The easiest way to install OTAnalytics is to download the latest release from the GitHub Releases page.

  1. Go to the OTAnalytics Releases page
  2. Download the latest release for your operating system
  3. Extract the downloaded archive
  4. Run the application using the instructions in the Usage section

Installation from Source (Linux/macOS)

If you prefer to install from source:

  1. Clone the repository:

    git clone https://github.com/OpenTrafficCam/OTAnalytics.git
    cd OTAnalytics
    
  2. Run the installation script:

    ./install.sh
    

Installation from Source (Windows)

If you prefer to install from source:

  1. Clone the repository:

    git clone https://github.com/OpenTrafficCam/OTAnalytics.git
    cd OTAnalytics
    
  2. Run the installation script:

    install.cmd
    

Usage

Starting the Application

Desktop GUI (Default)

On Linux/macOS:

./start_gui.sh

On Windows:

start_gui.cmd

Command Line Interface

On Linux/macOS:

./start_gui.sh --cli

On Windows:

start_gui.cmd --cli

Configuration

OTAnalytics can be configured using:

  1. Command-line arguments
  2. Configuration files (YAML format)

Example configuration options:

  • Specify track files for analysis
  • Define flow and section configurations using otflow files
  • Configure export formats and counting intervals
  • Control parallelization with multiple processes
  • Include or exclude specific road user classes

Traffic Statistics and Geo Track Export

Two optional exports for the CLI, both off by default. Enable them in the otconfig (under analysis.export, which is JSON) or with a CLI flag:

{
  "analysis": {
    "export": {
      "traffic_statistics": {
        "enabled": true,
        "interval_minutes": 1,
        "max_speed_kmh": 200,
        "peak_window_minutes": 60,
        "peak_step_minutes": 15,
        "class_groups": {
          "LV": ["car", "car_with_trailer", "private_van", "private_van_with_trailer", "delivery_van", "delivery_van_with_trailer", "motorcyclist"],
          "SV": ["truck", "truck_with_trailer", "truck_with_semitrailer", "bus"],
          "BIKE": ["bicyclist", "bicyclist_with_trailer", "cargo_bike_driver", "scooter_driver"],
          "PED": ["pedestrian"]
        }
      },
      "geo_tracks": true
    }
  }
}

Both keys are optional and only the relevant part of the otconfig is shown. Defaults: enabled true, interval_minutes 1; class_groups defaults to every classification being its own group; geo_tracks defaults to false.

Export otconfig key CLI flag
Traffic statistics traffic_statistics --traffic-statistics
Geo tracks geo_tracks --geo-track-export

--traffic-statistics uses the traffic_statistics block of the otconfig if there is one, otherwise the defaults.

Traffic statistics are written per UTC day, because the timezone of the camera is not known while processing. All times in the files are the UTC times of the input files, written as in the counts CSV (YYYY-MM-DD HH:MM:SS, with fractions of a second only where a time has them). Each day has a JSON file and four CSV files in {save_dir}/{save_stem}.traffic_statistics_{YYYY-MM-DD}, where {i} is interval_minutes:

File Content
.json per flow and for all flows, per class group: totals, peak hour, average speed and v85 of the day
.counts_{i}min.csv counts per flow, class group and interval
.speeds_{i}min.csv speed values per flow, class group and interval
.speeds_all_flows_{i}min.csv speed values per class group and interval over all flows
.speeds_total_{i}min.csv speed values per interval over all flows and class groups, classification total

The CSV files have the format of the counts CSV export, with the class group in the classification column. The speed files have the columns speed count (number of plausible speeds), avg speed and v85 (km/h) instead of count, and the files over all flows have no flow and section columns.

A road user is counted at most once per day. Speed is the flow distance divided by the time between the road user's start and end event, in km/h. Only speeds above 0 and up to max_speed_kmh enter the speed figures. v85 is the 85th percentile of the measured speeds (nearest rank). The JSON file contains results plus coverage and as_of. To continue a day after a restart, pass the road user assignment CSV files of the day with --traffic-statistics-restore. Counts and speeds are rebuilt from them with the current settings, and coverage and as_of are taken from an existing day file. A classification may belong to at most one class group. Only the time ranges of the processed videos count as covered: intervals between videos (e.g. a camera outage) have no rows in the CSV files. A covered interval without plausible speeds has a speed count of 0 and empty speed values.

Geo tracks are written to {save_dir}/{save_stem}_{YYYY-MM-DD_HH-MM-SS}.geo_tracks.json.bz2 (timestamp of the earliest detection of the chunk, UTC). The bz2-compressed JSON file looks like this:

{"metadata": {"format": "otanalytics.geo_tracks", "version": 1},
 "data": {"detections": [
   {"track-id": "...", "class": "car", "geo_x": 455123.12, "geo_y": 5701234.56,
    "occurrence": 1761572520.04}
 ]}}

occurrence is the Unix timestamp in seconds. Detections without a geo coordinate are left out, and if none remain no file is written.

Features

  • Track Analysis: Process and analyze trajectory data from various sources
  • Flow Definition: Define and analyze traffic flows between sections
  • Counting: Count road users assigned to flows with configurable time intervals
  • Event Detection: Generate event lists when road users cross defined sections
  • Visualization: Visualize tracks, flows, and sections
  • Export: Export analysis results in various formats
  • Filtering: Filter tracks by road user class and time
  • Parallelization: Process data using multiple CPU cores

Documentation

For detailed instructions on how to install and use OTAnalytics, please refer to the official documentation.

Contributing

We appreciate your support in the form of both code and comments. Please have a look at the contribute section of the OpenTrafficCam documentation for guidelines on how to contribute to this project.

To set up a development environment, see docs/dev.md.

License

This software is licensed under the GPL-3.0 License

Contact

Metadata

Release files for OTAnalytics 0.7.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for OTAnalytics 0.7.6
File Size Uploaded Provenance Actions
otanalytics-0.7.6.tar.gz 11.6 MB With provenance Details for otanalytics-0.7.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for OTAnalytics 0.7.6
File Interpreter ABI Platform Actions
otanalytics-0.7.6-py3-none-any.whl Python 3 none any Details for otanalytics-0.7.6-py3-none-any.whl

Total release size: 12.3 MB

Release files / otanalytics-0.7.6.tar.gz

Download URL otanalytics-0.7.6.tar.gz
Size 11.6 MB
Tags Source
SHA-256 checksum
How to use checksums
27467ef53ba5982858ab749cfeee175aa32afe73dd13177cef7bff538054dd3c
BLAKE2b-256 checksum
How to use checksums
7b66831fcf0093cb63028e5d146d853c5797054ecbb3411620836b7f3adc6a5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / otanalytics-0.7.6-py3-none-any.whl

Download URL otanalytics-0.7.6-py3-none-any.whl
Size 709.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
064e2aa631e94adc385cc1a64ef7ba2a3bc78c64a5c8e21065b54a6e42c33288
BLAKE2b-256 checksum
How to use checksums
0f8841e0ad8c440bb227d3c877a3be4f258e916a9c23e250770ade2b00fba859
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for OTAnalytics 0.7.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for otanalytics-0.7.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page