| from datasets import load_dataset, DatasetDict |
| import polars as pl |
| import numpy as np |
| import matplotlib.pyplot as plt |
| from matplotlib.animation import FuncAnimation |
| from scipy.io import loadmat |
|
|
|
|
| def draw_animation(id, rgb, depth, radar): |
| fig, ax = plt.subplots(1, 3, figsize=(15, 5)) |
|
|
| fig.suptitle(f"ID: {id}") |
|
|
| def update(frame): |
| ax[0].clear() |
| ax[0].set_title("Depth") |
| ax[0].imshow(depth[frame]) |
|
|
| ax[1].clear() |
| ax[1].set_title("RGB") |
| ax[1].imshow(rgb[frame]) |
|
|
| radar_data = radar[frame]["spec_db_slice"][::-1] |
| radar_data = (radar_data - radar_data.min()) / ( |
| radar_data.max() - radar_data.min() |
| ) |
|
|
| ax[2].clear() |
| ax[2].set_title("Radar") |
| ax[2].imshow(radar_data, aspect="auto", cmap="jet") |
|
|
| ani = FuncAnimation(fig, update, frames=len(depth), interval=15) |
| plt.show() |
|
|
|
|
| if __name__ == "__main__": |
| datasets = load_dataset("parquet", data_files="./train.parquet") |
|
|
| df_polars = datasets["train"].to_polars() |
|
|
| ids = df_polars["id"].unique().to_list() |
|
|
| for id in ids: |
| frames = df_polars.filter( |
| pl.col("id").eq(id) |
| & pl.col("selected_range_bin").eq(76) |
| & pl.col("sub_index_frame").eq(1) |
| ).sort("index_frame") |
| print( |
| frames.select( |
| "file_path_radar", |
| "file_path_depth", |
| "file_path_rgb", |
| "index_frame", |
| "id", |
| ) |
| ) |
| rgb = [np.load(f) for f in frames["file_path_rgb"].to_list()] |
| depth = [np.load(f) for f in frames["file_path_depth"].to_list()] |
| radar = [loadmat(f) for f in frames["file_path_radar"].to_list()] |
| draw_animation(id, rgb, depth, radar) |
| break |
|
|