-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.py
114 lines (93 loc) · 2.71 KB
/
plot.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"""Utility functions to plot data."""
import matplotlib.pyplot as plt
from matplotlib import pylab
# Define parameter for plotting
params = {
"legend.fontsize": "medium",
"figure.figsize": (10, 10),
"axes.labelsize": "medium",
"axes.titlesize": "large",
"xtick.labelsize": "medium",
"ytick.labelsize": "medium",
"font.size": 13,
}
pylab.rcParams.update(params)
def plot_fps(det_par, det_count, show_mean: bool):
"""Plot frame rate change in line chart.
Args:
det_par: Array of detection parameter to be plotted (y_axis)
det_count: Array of counter to plot in x axis
show_mean: whether to show the mean of the graph or not
"""
# Plot the line
plt.plot(det_count, det_par, color="red", label="FPS", linewidth=3)
if show_mean:
# Calculate mean of the parameter
par_mean = det_par[1:].mean()
# Plot it
plt.axhline(
par_mean,
color="blue",
label="mean",
linewidth=2,
linestyle="--"
)
# Add title and label
plt.title("FPS Change during Detection")
plt.xlabel("Detection Count")
plt.ylabel("FPS Level")
# Add grid and legend
plt.grid(True)
plt.legend()
# Show image
plt.tight_layout()
plt.show()
def plot_delay(det_par, det_count, show_mean: bool):
"""Plot delay change in line chart.
Args:
det_par: Array of detection parameter to be plotted (y_axis)
det_count: Array of counter to plot (x axis)
show_mean: whether to show the mean of the graph or not
"""
# Plot the line
plt.plot(det_count, det_par, color="red", label="Delay", linewidth=3)
if show_mean:
# Calculate mean of the parameter
par_mean = det_par[1:].mean()
# Plot it
plt.axhline(
par_mean,
color="blue",
label="mean",
linewidth=2,
linestyle="--"
)
# Add title and label
plt.title("Delay Time during Detection")
plt.xlabel("Detection Count")
plt.ylabel("Time (Second)")
# Add grid and legend
plt.grid(True)
plt.legend()
# Show image
plt.tight_layout()
plt.show()
def plot_detection(det_ratio: list, color: list = ["#008fd5", "#fc4f30"]):
"""Plot detection ratio in pie chart.
Args:
det_ratio: List of ratio of detected parameters.
color: list of color for each pie segment.
"""
# Plot the image
plt.pie(
det_ratio,
labels=["Yes", "No"],
colors=color,
wedgeprops={"edgecolor": "black", "linewidth": 2},
autopct="%.1f%%",
)
# Add title
plt.title("Ratio of Detected Object")
# Show image
plt.tight_layout()
plt.show()