File size: 3,335 Bytes
628b6bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import os

# Streamlit config dosyasını kullanıcının home dizininde oluştur
config_dir = os.path.join(os.path.expanduser("~"), ".streamlit")
os.makedirs(config_dir, exist_ok=True)

config_path = os.path.join(config_dir, "config.toml")
with open(config_path, "w") as f:
    f.write("""

[server]

headless = true

port = $PORT

enableCORS = false

""")

import streamlit as st
import tempfile
from movement_detector import extract_frames, detect_camera_movement

st.set_page_config(page_title="Camera Movement Detector", layout="centered")

# CSS + HTML (Profesyonel Tasarım)
st.markdown("""

    <style>

    body {

        font-family: 'Segoe UI', sans-serif;

    }



    .stApp {

        background-color: #f4f4f4;

        padding-top: 30px;

    }



    .logo-container {

        display: flex;

        justify-content: center;

        align-items: center;

        margin-bottom: 15px;

    }



    .logo-container img {

        width: 60px;

        height: auto;

        opacity: 0.9;

    }



    .card {

        background-color: white;

        border-radius: 12px;

        padding: 30px;

        max-width: 700px;

        margin: auto;

        box-shadow: 0 8px 20px rgba(0,0,0,0.08);

    }



    .title {

        text-align: center;

        font-size: 26px;

        color: #333;

        margin-bottom: 10px;

        font-weight: 600;

    }



    .description {

        text-align: center;

        font-size: 16px;

        color: #666;

        margin-bottom: 25px;

    }



    .stButton>button {

        background-color: #ff4b4b;

        color: white;

        border-radius: 6px;

        padding: 8px 20px;

        font-weight: bold;

    }



    .stFileUploader label {

        font-weight: 500;

        color: #444;

    }



    /* 🔧 Info ve spinner kutularının metin rengini siyah yap */

    .stAlert > div {

        color: black !important;

    }



    .stSpinner > div {

        color: black !important;

    }



    </style>

""", unsafe_allow_html=True)

# 🔹 Logo
st.markdown("""

<div class="logo-container">

    <img src="https://i.hizliresim.com/khnekdt.png" alt="ATP Logo">

</div>

""", unsafe_allow_html=True)

# 🔹 İçerik Kartı
st.markdown('<div class="card">', unsafe_allow_html=True)

st.markdown('<div class="title">📷 Camera Movement Detector</div>', unsafe_allow_html=True)
st.markdown('<div class="description">Upload a video to detect <b>significant camera movement</b> (not object motion).</div>', unsafe_allow_html=True)

# 🔸 Dosya yükleyici
uploaded_video = st.file_uploader("🎞️ Upload your video", type=["mp4", "avi", "mov"])

# 🔸 Analiz işlemi
if uploaded_video:
    with tempfile.NamedTemporaryFile(delete=False) as temp_file:
        temp_file.write(uploaded_video.read())
        temp_video_path = temp_file.name

    st.info("Extracting frames...")
    frames = extract_frames(temp_video_path)

    st.info("Analyzing for camera movement...")
    with st.spinner("Running detection..."):
        indices = detect_camera_movement(frames)

    st.success("✅ Detection complete.")
    st.markdown(f"<div class='description'>📌 Movement detected at frames:<br><code>{indices}</code></div>", unsafe_allow_html=True)

st.markdown('</div>', unsafe_allow_html=True)