Update app.py
Browse files
app.py
CHANGED
@@ -1,45 +1,63 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
4 |
|
5 |
-
# ํ์ผ ์
๋ก๋
|
6 |
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
if uploaded_file:
|
15 |
# CSV ํ์ผ ์ฝ๊ธฐ
|
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 |
|
|
|
|
1 |
+
|
2 |
import streamlit as st
|
3 |
import pandas as pd
|
4 |
import matplotlib.pyplot as plt
|
5 |
+
import io
|
6 |
+
|
7 |
+
st.title("Webcam Color Detection Charting")
|
8 |
|
|
|
9 |
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
10 |
|
11 |
+
time_frame_options = [
|
12 |
+
"All",
|
13 |
+
"1 second",
|
14 |
+
"5 seconds",
|
15 |
+
"10 seconds",
|
16 |
+
"30 seconds",
|
17 |
+
"1 minute",
|
18 |
+
"5 minutes",
|
19 |
+
"10 minutes",
|
20 |
+
"30 minutes",
|
21 |
+
"60 minutes",
|
22 |
+
]
|
23 |
+
time_frame = st.selectbox("Data Time Frame", time_frame_options)
|
24 |
|
25 |
+
if uploaded_file is not None:
|
26 |
# CSV ํ์ผ ์ฝ๊ธฐ
|
27 |
+
data = pd.read_csv(uploaded_file)
|
28 |
+
|
29 |
+
# ์๊ฐ ํ๋ ์์ ๋ฐ๋ฅธ ๋ฐ์ดํฐ ํํฐ๋ง
|
30 |
+
if time_frame != "All":
|
31 |
+
seconds = {
|
32 |
+
"1 second": 1,
|
33 |
+
"5 seconds": 5,
|
34 |
+
"10 seconds": 10,
|
35 |
+
"30 seconds": 30,
|
36 |
+
"1 minute": 60,
|
37 |
+
"5 minutes": 300,
|
38 |
+
"10 minutes": 600,
|
39 |
+
"30 minutes": 1800,
|
40 |
+
"60 minutes": 3600,
|
41 |
+
}
|
42 |
+
data['timestamp'] = pd.to_datetime(data['timestamp'], unit='ms')
|
43 |
+
data.set_index('timestamp', inplace=True)
|
44 |
+
data = data.resample(f"{seconds[time_frame]}S").mean().dropna().reset_index()
|
45 |
+
|
46 |
+
# ์ฐจํธ ์์ฑ
|
47 |
+
fig, axes = plt.subplots(2, 1, figsize=(10, 8))
|
48 |
+
|
49 |
+
# RGB ์ฐจํธ
|
50 |
+
axes[0].plot(data['R'], 'r', label='R')
|
51 |
+
axes[0].plot(data['G'], 'g', label='G')
|
52 |
+
axes[0].plot(data['B'], 'b', label='B')
|
53 |
+
axes[0].legend(loc='upper right')
|
54 |
+
axes[0].set_title('RGB Values')
|
55 |
+
|
56 |
+
# HSV ์ฐจํธ
|
57 |
+
axes[1].plot(data['H'], 'r', label='H')
|
58 |
+
axes[1].plot(data['S'], 'g', label='S')
|
59 |
+
axes[1].plot(data['V'], 'b', label='V')
|
60 |
+
axes[1].legend(loc='upper right')
|
61 |
+
axes[1].set_title('HSV Values')
|
62 |
|
63 |
+
st.pyplot(fig)
|