davron04 commited on
Commit
1d9eccd
·
1 Parent(s): c9a2598
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
__pycache__/camera_view.cpython-312.pyc CHANGED
Binary files a/__pycache__/camera_view.cpython-312.pyc and b/__pycache__/camera_view.cpython-312.pyc differ
 
__pycache__/main_view.cpython-312.pyc CHANGED
Binary files a/__pycache__/main_view.cpython-312.pyc and b/__pycache__/main_view.cpython-312.pyc differ
 
__pycache__/upload_view.cpython-312.pyc CHANGED
Binary files a/__pycache__/upload_view.cpython-312.pyc and b/__pycache__/upload_view.cpython-312.pyc differ
 
camera_view.py CHANGED
@@ -2,11 +2,15 @@ import streamlit as st
2
  import cv2
3
  import time
4
 
 
 
5
  class Camera_View:
6
  def __init__(self, app, model):
7
  self.app = app
8
  self.model = model
9
 
 
 
10
  def show(self):
11
  col1_back, col2_back = st.columns([0.2, 0.8])
12
  with col1_back:
@@ -21,9 +25,11 @@ class Camera_View:
21
  stop_button = st.button("Stop Camera", icon=':material/videocam_off:',
22
  type='secondary') # Button to stop video
23
  with col2_button:
24
- start_button = st.button("Start Camera", icon=':material/videocam:',
25
- type='primary') # Button to start video
26
-
 
 
27
  if start_button:
28
  cap = cv2.VideoCapture(0) # Open webcam
29
 
 
2
  import cv2
3
  import time
4
 
5
+ if "show_button" not in st.session_state:
6
+ st.session_state.show_button = True
7
  class Camera_View:
8
  def __init__(self, app, model):
9
  self.app = app
10
  self.model = model
11
 
12
+ def toggle_button(self):
13
+ st.session_state.show_button = False
14
  def show(self):
15
  col1_back, col2_back = st.columns([0.2, 0.8])
16
  with col1_back:
 
25
  stop_button = st.button("Stop Camera", icon=':material/videocam_off:',
26
  type='secondary') # Button to stop video
27
  with col2_button:
28
+ start_button = st.button("Start Camera",
29
+ icon=':material/videocam:',
30
+ type='primary', on_click=self.toggle_button())
31
+ if st.session_state.show_button:
32
+ picture = st.camera_input("")
33
  if start_button:
34
  cap = cv2.VideoCapture(0) # Open webcam
35
 
test.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Initialize session state
4
+ if "show_button" not in st.session_state:
5
+ st.session_state.show_button = True
6
+
7
+ # Function to hide the button
8
+ def hide_button():
9
+ st.session_state.show_button = False
10
+
11
+ st.title("Dynamic Button in Streamlit")
12
+
13
+ # Conditionally display button
14
+ if st.session_state.show_button:
15
+ if st.button("Click to Hide"):
16
+ hide_button()