Spaces:
Runtime error
Runtime error
Shafeek Saleem
commited on
Commit
·
0e1e0d9
1
Parent(s):
c1cf12f
bug fixed
Browse files
pages/1_Technology Behind It.py
CHANGED
@@ -1,13 +1,26 @@
|
|
1 |
import streamlit as st
|
2 |
from utils.levels import complete_level, render_page, initialize_level
|
3 |
from utils.login import initialize_login
|
|
|
4 |
|
5 |
LEVEL = 1
|
6 |
|
7 |
initialize_login()
|
8 |
initialize_level()
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def step1_page():
|
13 |
st.header("Technology Behind It")
|
@@ -47,6 +60,29 @@ def step1_page():
|
|
47 |
|
48 |
st.info("Click on the button below to continue!")
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
if st.button("Complete"):
|
51 |
complete_level(LEVEL)
|
52 |
|
|
|
1 |
import streamlit as st
|
2 |
from utils.levels import complete_level, render_page, initialize_level
|
3 |
from utils.login import initialize_login
|
4 |
+
import cv2
|
5 |
|
6 |
LEVEL = 1
|
7 |
|
8 |
initialize_login()
|
9 |
initialize_level()
|
10 |
|
11 |
+
def returnCameraIndexes():
|
12 |
+
# checks the first 10 indexes.
|
13 |
+
index = 0
|
14 |
+
arr = []
|
15 |
+
i = 10
|
16 |
+
while i > 0:
|
17 |
+
cap = cv2.VideoCapture(index)
|
18 |
+
if cap.read()[0]:
|
19 |
+
arr.append(index)
|
20 |
+
cap.release()
|
21 |
+
index += 1
|
22 |
+
i -= 1
|
23 |
+
return arr
|
24 |
|
25 |
def step1_page():
|
26 |
st.header("Technology Behind It")
|
|
|
60 |
|
61 |
st.info("Click on the button below to continue!")
|
62 |
|
63 |
+
"""TEST"""
|
64 |
+
input_type = st.radio("Select the Input Type", ["Image upload", "Camera", "Live Video"])
|
65 |
+
st.write(returnCameraIndexes())
|
66 |
+
if input_type == "Live Video":
|
67 |
+
cam = cv2.VideoCapture(0)
|
68 |
+
if not cam.isOpened():
|
69 |
+
print("Cannot open camera")
|
70 |
+
exit()
|
71 |
+
cam.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
|
72 |
+
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
|
73 |
+
FRAME_WINDOW = st.image([])
|
74 |
+
|
75 |
+
while True:
|
76 |
+
ret, frame = cam.read()
|
77 |
+
if not ret:
|
78 |
+
st.error("Failed to capture frame from camera")
|
79 |
+
st.info("Please turn off the other app that is using the camera and restart app")
|
80 |
+
st.stop()
|
81 |
+
# image, name, face_id = recognize(frame, tolerance)
|
82 |
+
image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
83 |
+
# Display name and ID of the person
|
84 |
+
FRAME_WINDOW.image(image)
|
85 |
+
|
86 |
if st.button("Complete"):
|
87 |
complete_level(LEVEL)
|
88 |
|