File size: 1,679 Bytes
87d5e36
bd820cc
 
 
9463232
 
 
bd820cc
 
 
9463232
 
 
 
 
 
 
 
 
 
 
 
 
bd820cc
e3ddefb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
07cdbf6
 
 
 
 
 
 
 
 
 
 
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

import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import io

st.title("Webcam Color Detection Charting")

uploaded_file = st.file_uploader("Choose a CSV file", type="csv")

time_frame_options = [
    "All",
    "1 second",
    "5 seconds",
    "10 seconds",
    "30 seconds",
    "1 minute",
    "5 minutes",
    "10 minutes",
    "30 minutes",
    "60 minutes",
]
time_frame = st.selectbox("Data Time Frame", time_frame_options)

if uploaded_file is not None:
    # CSV 파일 읽기
    data = pd.read_csv(uploaded_file)

    # 시간 프레임에 따른 데이터 필터링
    if time_frame != "All":
        seconds = {
            "1 second": 1,
            "5 seconds": 5,
            "10 seconds": 10,
            "30 seconds": 30,
            "1 minute": 60,
            "5 minutes": 300,
            "10 minutes": 600,
            "30 minutes": 1800,
            "60 minutes": 3600,
        }
        data['timestamp'] = pd.to_datetime(data['timestamp'], unit='ms')
        data.set_index('timestamp', inplace=True)
        data = data.resample(f"{seconds[time_frame]}S").mean().dropna().reset_index()

    # 차트 생성
    fig, axes = plt.subplots(2, 1, figsize=(10, 8))

    # RGB 차트
    axes[0].plot(data['R'], 'r', label='R')
    axes[0].plot(data['G'], 'g', label='G')
    axes[0].plot(data['B'], 'b', label='B')
    axes[0].legend(loc='upper right')
    axes[0].set_title('RGB Values')

    # HSV 차트
    axes[1].plot(data['H'], 'r', label='H')
    axes[1].plot(data['S'], 'g', label='S')
    axes[1].plot(data['V'], 'b', label='V')
    axes[1].legend(loc='upper right')
    axes[1].set_title('HSV Values')

    st.pyplot(fig)