shin0624 commited on
Commit
091d20d
ยท
verified ยท
1 Parent(s): 5c12344

Create visualization.py

Browse files
Files changed (1) hide show
  1. utils/visualization.py +69 -0
utils/visualization.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ from mpl_toolkits.mplot3d import Axes3D
4
+
5
+ class FactoryVisualizer:
6
+ @staticmethod
7
+ def plot_3d_pointcloud(points, save_path=None):
8
+ """3D ํฌ์ธํŠธ ํด๋ผ์šฐ๋“œ ์‹œ๊ฐํ™”"""
9
+ fig = plt.figure(figsize=(12, 8))
10
+ ax = fig.add_subplot(111, projection='3d')
11
+
12
+ ax.scatter(
13
+ points[:,0],
14
+ points[:,1],
15
+ points[:,2],
16
+ c=points[:,2],
17
+ cmap='viridis',
18
+ s=20,
19
+ alpha=0.7
20
+ )
21
+
22
+ ax.set_xlabel('X Axis')
23
+ ax.set_ylabel('Y Axis')
24
+ ax.set_zlabel('Frame Sequence (Z)')
25
+ ax.set_title('3D Factory Point Cloud')
26
+
27
+ if save_path:
28
+ plt.savefig(save_path, dpi=120, bbox_inches='tight')
29
+ plt.close()
30
+ else:
31
+ plt.show()
32
+
33
+ @staticmethod
34
+ def create_top_down_view(points, save_path):
35
+ """ํƒ‘๋ทฐ 2D ํ”„๋กœ์ ์…˜ ์ƒ์„ฑ"""
36
+ plt.figure(figsize=(10, 8))
37
+ plt.scatter(points[:,0], points[:,1],
38
+ c=points[:,2], cmap='plasma',
39
+ alpha=0.5, s=15)
40
+ plt.colorbar(label='Frame Sequence')
41
+ plt.xlabel('X Position')
42
+ plt.ylabel('Y Position')
43
+ plt.title('Top-Down View')
44
+ plt.grid(True)
45
+ plt.savefig(save_path, dpi=100)
46
+ plt.close()
47
+
48
+ @staticmethod
49
+ def plot_class_distribution(detections, save_path):
50
+ """๊ฐ์ฒด ๋ถ„ํฌ ์‹œ๊ฐํ™”"""
51
+ classes = list(detections.keys())
52
+ counts = [len(v) for v in detections.values()]
53
+
54
+ plt.figure(figsize=(10, 6))
55
+ bars = plt.bar(classes, counts,
56
+ color=['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4'])
57
+
58
+ plt.ylabel('Detection Count')
59
+ plt.title('Object Distribution')
60
+ plt.xticks(rotation=45)
61
+
62
+ for bar in bars:
63
+ height = bar.get_height()
64
+ plt.text(bar.get_x() + bar.get_width()/2., height,
65
+ f'{height}',
66
+ ha='center', va='bottom')
67
+
68
+ plt.savefig(save_path, bbox_inches='tight')
69
+ plt.close()