File size: 1,799 Bytes
27ecb57
 
 
 
 
 
6c9d7cd
 
27ecb57
 
6c9d7cd
27ecb57
 
 
 
 
 
 
 
 
 
 
c6136d8
 
 
 
 
27ecb57
 
c6136d8
27ecb57
c6136d8
27ecb57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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