File size: 1,614 Bytes
bd820cc
 
 
 
 
 
 
 
5449034
bd820cc
5449034
bd820cc
 
 
 
 
 
 
 
 
 
 
 
 
3901252
 
 
 
 
 
 
 
 
bd820cc
 
3901252
 
 
 
 
 
 
 
 
5449034
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
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt

# ํŒŒ์ผ ์—…๋กœ๋“œ
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")

# ๋ฐ์ดํ„ฐ ํƒ€์ž„ ํ”„๋ ˆ์ž„ ์„ ํƒ
time_frame_options = ["1์ดˆ", "5์ดˆ", "10์ดˆ", "30์ดˆ", "1๋ถ„", "5๋ถ„", "10๋ถ„", "30๋ถ„", "60๋ถ„"]
time_frame = st.selectbox("๋ฐ์ดํ„ฐ ํƒ€์ž„ ํ”„๋ ˆ์ž„ ์„ ํƒ:", time_frame_options)
time_frame_map = {"1์ดˆ": 1/60, "5์ดˆ": 5/60, "10์ดˆ": 10/60, "30์ดˆ": 30/60, "1๋ถ„": 1, "5๋ถ„": 5, "10๋ถ„": 10, "30๋ถ„": 30, "60๋ถ„": 60}
time_frame_minutes = time_frame_map[time_frame]

if uploaded_file:
    # CSV ํŒŒ์ผ ์ฝ๊ธฐ
    df = pd.read_csv(uploaded_file)
    
    # timestamp๋ฅผ datetime ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜
    df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')

    # ์„ ํƒ๋œ ํƒ€์ž„ ํ”„๋ ˆ์ž„์œผ๋กœ ๋ฆฌ์ƒ˜ํ”Œ๋ง
    df_resampled = df.resample(f'{time_frame_minutes}T', on='timestamp').mean()

    # RGB ๊ทธ๋ž˜ํ”„
    fig_rgb, ax_rgb = plt.subplots(figsize=(15, 5))
    ax_rgb.plot(df_resampled['R'], label='R')
    ax_rgb.plot(df_resampled['G'], label='G')
    ax_rgb.plot(df_resampled['B'], label='B')
    ax_rgb.set_title('RGB Color Variation')
    ax_rgb.set_xlabel('Time')
    ax_rgb.set_ylabel('Value')
    ax_rgb.legend()
    st.pyplot(fig_rgb)

    # HSV ๊ทธ๋ž˜ํ”„
    fig_hsv, ax_hsv = plt.subplots(figsize=(15, 5))
    ax_hsv.plot(df_resampled['H'], label='H')
    ax_hsv.plot(df_resampled['S'], label='S')
    ax_hsv.plot(df_resampled['V'], label='V')
    ax_hsv.set_title('HSV Color Variation')
    ax_hsv.set_xlabel('Time')
    ax_hsv.set_ylabel('Value')
    ax_hsv.legend()
    st.pyplot(fig_hsv)