Download Processing_Code/README.md from InterestingITS/U-EASWS: direct link, hf CLI and curl.
- Browser
- Download file 6.18 kB
-
https://huggingface.co/datasets/InterestingITS/U-EASWS/resolve/main/Processing_Code/README.md
- Command line
-
hf download hf://datasets/InterestingITS/U-EASWS/Processing_Code/README.md
-
curl -L -o README.md https://huggingface.co/datasets/InterestingITS/U-EASWS/resolve/main/Processing_Code/README.md
U-EASWS processing code
The scripts provide coordinate conversion, trajectory reconstruction, vehicle-length estimation, TTC/PET/DRAC annotation, vehicle pairing, balanced sampling, driver-space parameter estimation and interaction annotation. The four measured calibration configurations contain the actual fitting inputs for sixteen source videos. Paths are supplied through command-line arguments.
Installation
Use Python 3.12 and keep the Python files together. Run commands from this directory:
python -m venv .venv
# Activate .venv using the command appropriate to your operating system.
python -m pip install -r requirements.txt
Every executable script accepts --help. Output files must have new names. For commands producing several outputs, all destination paths must be distinct and not already exist.
Start with the released Basic trajectory files
Download a Basic trajectory CSV from the U-EASWS repository and place it under data/basic/. The Basic files already contain Lane number, Direction, metric positions, velocities and estimated vehicle lengths. Use these fields directly for downstream processing. configs/basic_manifest.csv gives the four observation groups and the local filenames used in the examples; if the downloaded filename differs, pass its actual path in --input or rename it to the listed local filename without changing its records.
The following commands use the existing WS3 Basic file and its recorded lane and direction fields:
python annotate_risk.py --input "data/basic/Weaving Segment_3.csv" --output runs/ws3_risk.csv
python generate_vehicle_pairs.py --input "data/basic/Weaving Segment_3.csv" --output runs/ws3_pairs.csv --audit runs/ws3_pairs_summary.json
python balance_pair_samples.py --input runs/ws3_pairs.csv --output runs/ws3_balanced.csv --audit runs/ws3_sampling_summary.json --seed 42
python fit_pr_parameters.py --input runs/ws3_balanced.csv --output runs/ws3_pr_parameters.csv --audit runs/ws3_fit_summary.json --workers 1
python annotate_interactions.py --input "data/basic/Weaving Segment_3.csv" --pairs runs/ws3_pairs.csv --parameters runs/ws3_pr_parameters.csv --output runs/ws3_interactions.csv
The pair, sample and inference commands operate on the complete observation-group file. Fit parameter groups are defined by cangle,round_v. Use the full candidate-pair file for interaction annotation; the balanced subset is for fitting.
Risk annotation uses Time_s when present. For the released format containing Delta_t_s, it reconstructs a shared time reference for each connected sequence of observed frame intervals. This uses the recorded 30/60 fps intervals, including mixed-rate files. Disconnected sequences receive independent Time_Reference_ID values and start at Time_s=0; elapsed time between such references is not inserted. Trajectories must remain within one reference. An explicit --fps is an alternative only for a recording with that constant frame rate.
Start with source detection records
The pixel-to-metric and reconstruction commands are separate entry points for source detection records. Use configs/source_manifest.csv to match each Raw_Data CSV to the actual source FPS and calibration source key.
| Observation group | Master source | Measured configuration |
|---|---|---|
| WS1-2 | video4 | WS1_2.json |
| WS3 | video2 | WS3.json |
| WS4-5 | video1 | WS4_5.json |
| WS6-7 | video2 | WS6_7.json |
All supplied JSONs in calibrations/ contain measured scene values. See CALIBRATION.md for the fields and transformation equations. Raw file suffix _N corresponds to videoN.
For raw reconstruction, supply a source-frame annotation CSV containing Frame,Vehicle_ID,Lane number,Direction, keyed by the original detection records, or use metric detections that already contain these fields. The published Basic data provide lane and direction fields under processed Frame,Ego_Vehicle_ID. To transfer those fields to raw detections, apply the corresponding source/frame/vehicle mapping to obtain the original keys.
The source-frame example below uses WS3/video2 at 30 fps and data/lanes/WS3_video2_lanes.csv as the annotation input:
python coordinate_transform.py --input data/raw/WS3_raw_detection_data_2.csv --calibration calibrations/WS3.json --source video2 --output runs/ws3_video2_metric.csv
python attach_lane_annotations.py --input runs/ws3_video2_metric.csv --annotations data/lanes/WS3_video2_lanes.csv --output runs/ws3_video2_metric_with_lanes.csv
python reconstruct_trajectories.py --input runs/ws3_video2_metric_with_lanes.csv --source video2 --fps 30 --id-offset 0 --frame-offset 0 --time-offset 0 --output runs/ws3_video2_reconstructed.csv --rejected runs/ws3_video2_rejected.csv --audit runs/ws3_video2_screening.csv
python estimate_vehicle_length.py --input data/raw/WS3_raw_detection_data_2.csv --calibration calibrations/WS3.json --source video2 --output runs/ws3_video2_lengths.csv
python merge_vehicle_lengths.py --input runs/ws3_video2_reconstructed.csv --lengths runs/ws3_video2_lengths.csv --output runs/ws3_video2_basic.csv
The generated Basic file can then be supplied to the downstream commands above. If the metric detection input already includes source-frame lanes/direction, omit the lane-join command and pass that file to reconstruction.
Use one source recording per reconstruction. The example offsets retain source-local IDs and time; supply established offsets explicitly when combining sources. filter_trajectory_outliers.py exposes the same screen used inside reconstruction. Measured --merge-x-m and --diverge-x-m reference coordinates enable the corresponding distance fields.
See INPUT_OUTPUT.md for all input schemas and METHOD_NOTES.md for processing rules and numerical settings. Attribution for the reused driver-space code is retained in THIRD_PARTY_NOTICES.md.