v1.0.1: Automatum house format (Sample_Data, doc, example_scripts, zip, overview) + Parquet
b35f113 verified Download example_scripts/02_heatmap_density.py from AutomatumData/automatum-data-highway-area-pools: direct link, hf CLI and curl.
- Browser
- Download file 1.89 kB
-
https://huggingface.co/datasets/AutomatumData/automatum-data-highway-area-pools/resolve/main/example_scripts/02_heatmap_density.py
- Command line
-
hf download hf://datasets/AutomatumData/automatum-data-highway-area-pools/example_scripts/02_heatmap_density.py
-
curl -L -o 02_heatmap_density.py https://huggingface.co/datasets/AutomatumData/automatum-data-highway-area-pools/resolve/main/example_scripts/02_heatmap_density.py
1.89 kB
| """ | |
| Traffic Density Heatmap — Automatum Data Highway Area Pools (Multi-Drone) | |
| Generates a 2D heatmap of all vehicle positions over time. | |
| Usage: | |
| python 02_heatmap_density.py <path_to_recording_folder> | |
| Example: | |
| python 02_heatmap_density.py ../Sample_Data/Pool-Highway-A9-OffenbauRastanlage_c025-c02598c7-fa60-4302-8cee-12a05f4e0db6 | |
| Output: | |
| traffic_heatmap.png in the current directory | |
| """ | |
| import sys | |
| import os | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from openautomatumdronedata.dataset import droneDataset | |
| def generate_density_heatmap(dataset_path, output_filename="traffic_heatmap.png"): | |
| print(f"Loading dataset from: {dataset_path}") | |
| dataset = droneDataset(dataset_path) | |
| dynWorld = dataset.dynWorld | |
| print("Extracting position data...") | |
| all_x, all_y = [], [] | |
| for dynObj in dynWorld.dynamicObjects.values(): | |
| x_valid = [x for x in dynObj.x_vec if not np.isnan(x)] | |
| y_valid = [y for y in dynObj.y_vec if not np.isnan(y)] | |
| all_x.extend(x_valid) | |
| all_y.extend(y_valid) | |
| if not all_x: | |
| print("No position data found!") | |
| return | |
| print(f"Extracted {len(all_x)} data points. Creating heatmap...") | |
| plt.figure(figsize=(16, 6)) | |
| plt.style.use("dark_background") | |
| plt.hist2d(all_x, all_y, bins=(300, 100), cmap="inferno", cmin=1) | |
| plt.colorbar(label="Traffic density (data points)") | |
| plt.title("Highway Traffic Density Heatmap (Top-View)") | |
| plt.xlabel("X-Position [m]") | |
| plt.ylabel("Y-Position [m]") | |
| plt.gca().set_aspect("equal", adjustable="box") | |
| plt.tight_layout() | |
| plt.savefig(output_filename, dpi=300) | |
| print(f"Heatmap saved: {os.path.abspath(output_filename)}") | |
| if __name__ == "__main__": | |
| if len(sys.argv) < 2: | |
| print("Usage: python 02_heatmap_density.py <path_to_recording_folder>") | |
| else: | |
| generate_density_heatmap(sys.argv[1]) | |