-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
85 lines (63 loc) · 2.53 KB
/
Copy pathapp.py
File metadata and controls
85 lines (63 loc) · 2.53 KB
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
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 23 10:46:05 2021
@author: Pascal
"""
import streamlit as st
from PIL import Image
from datetime import date
import time
import cv2
import os
import object_detection as detect
import snapshot as snap
def write_image(out_image):
today = date.today()
d = today.strftime("%b-%d-%Y")
t = time.localtime()
current_time = time.strftime("%H-%M-%S", t)
file_name = "tempDir/photo_" + d + "_" + current_time + ".jpg"
cv2.imwrite(file_name, out_image)
return(file_name)
def main():
# ===================== Set page config and background =======================
st.set_page_config(page_title ="Objekterkennung",
page_icon=':camera:',
layout='centered')
# ===================== Set header and site info =============================
text = """
<center> <br>Testumgebung für Objektklassifizierungen mit Webcam. </br> </center>
</center>
"""
html_temp = f"""
<p style = "color:#1F4E79; text_align:justify;"> {text} </p>
</div>
"""
st.markdown(html_temp, unsafe_allow_html = True)
# ======================= Get tf lite model details ==========================
labels, colors, height, width, interpreter = detect.define_tf_lite_model()
# ============================= Main app =====================================
option = st.selectbox('Wähle Eingabeart aus',
('Nichts',
'Webcam',
# 'Upload photo'
))
if option == 'Webcam':
out_image = snap.streamlit_webrtc_snapshot()
if out_image is not None:
st.header("Dein Bild")
st.image(out_image, channels="BGR")
# Speichere Bild temporär
file_name = write_image(out_image)
object_detection = detect.display_results(labels,
colors,
height,
width,
file_name,
interpreter,
threshold=0.5)
st.image(Image.fromarray(object_detection), use_column_width=True)
# else:
# st.warning('Kalibriere...')
if __name__ == "__main__":
main()