jingyan wang commited on
Commit
27ecb57
·
1 Parent(s): 9d2c7ec

add visualization code

Browse files
Files changed (1) hide show
  1. test_code.py +54 -10
test_code.py CHANGED
@@ -1,13 +1,57 @@
1
- import h5py
2
- import scipy.io as io
 
 
 
 
3
 
4
 
5
- # with h5py.File(
6
- # "radardata/769E33E0_2025_06_16_21_27-mastlab-yao-1400-2D-2-2-0001-076-5.90.mat", "r"
7
- # ) as f:
8
- # data = f["dataset"][:]
9
- # print(data)
10
 
11
- data = io.loadmat(
12
- "radardata/769E33E0_2025_06_16_21_27-mastlab-yao-1400-2D-2-2-0001-076-5.90.mat"
13
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset, DatasetDict
2
+ import polars as pl
3
+ import numpy as np
4
+ import matplotlib.pyplot as plt
5
+ from matplotlib.animation import FuncAnimation
6
+ from scipy.io import loadmat
7
 
8
 
9
+ def draw_animation(id, rgb, depth, radar):
10
+ fig, ax = plt.subplots(1, 3, figsize=(15, 5))
 
 
 
11
 
12
+ fig.suptitle(f"ID: {id}")
13
+
14
+ def update(frame):
15
+ ax[0].clear()
16
+ ax[0].set_title("Depth")
17
+ ax[0].imshow(depth[frame])
18
+
19
+ ax[1].clear()
20
+ ax[1].set_title("RGB")
21
+ ax[1].imshow(rgb[frame])
22
+
23
+ ax[2].clear()
24
+ ax[2].set_title("Radar")
25
+ ax[2].imshow(radar[frame]["spec_db_slice"])
26
+
27
+ ani = FuncAnimation(fig, update, frames=len(depth), interval=30)
28
+ plt.show()
29
+
30
+
31
+ if __name__ == "__main__":
32
+ datasets = load_dataset("parquet", data_files="./train.parquet")
33
+
34
+ df_polars = datasets["train"].to_polars()
35
+
36
+ ids = df_polars["id"].unique().to_list()
37
+
38
+ for id in ids:
39
+ frames = df_polars.filter(
40
+ pl.col("id").eq(id)
41
+ & pl.col("selected_range_bin").eq(76)
42
+ & pl.col("sub_index_frame").eq(1)
43
+ ).sort("index_frame")
44
+ print(
45
+ frames.select(
46
+ "file_path_radar",
47
+ "file_path_depth",
48
+ "file_path_rgb",
49
+ "index_frame",
50
+ "id",
51
+ )
52
+ )
53
+ rgb = [np.load(f) for f in frames["file_path_rgb"].to_list()]
54
+ depth = [np.load(f) for f in frames["file_path_depth"].to_list()]
55
+ radar = [loadmat(f) for f in frames["file_path_radar"].to_list()]
56
+ draw_animation(id, rgb, depth, radar)
57
+ break