ibrahim313 commited on
Commit
9649350
·
verified ·
1 Parent(s): 405fdf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -25
app.py CHANGED
@@ -47,30 +47,15 @@ def process_hand(image):
47
  st.title("AI Sign Language Interpreter")
48
  st.write("Make a thumbs up or thumbs down gesture in front of your camera.")
49
 
50
- # Upload or capture an image
51
- uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
52
- if uploaded_file is not None:
53
- image = np.array(Image.open(uploaded_file))
54
- processed_image = process_hand(image)
55
-
56
- # Convert the image back to RGB for display
57
- st.image(cv2.cvtColor(processed_image, cv2.COLOR_BGR2RGB), caption="Processed Output", use_column_width=True)
58
- else:
59
- st.write("Please upload an image.")
60
-
61
- # Activate the webcam feed for live processing
62
  if st.button("Start Webcam"):
63
- run = st.checkbox('Running')
64
- cam = cv2.VideoCapture(0)
65
- stframe = st.empty()
66
-
67
- while run:
68
- ret, frame = cam.read()
69
- if not ret:
70
- st.write("Failed to capture image")
71
- break
72
-
73
- processed_frame = process_hand(frame)
74
- stframe.image(cv2.cvtColor(processed_frame, cv2.COLOR_BGR2RGB), channels="RGB", use_column_width=True)
75
 
76
- cam.release()
 
 
47
  st.title("AI Sign Language Interpreter")
48
  st.write("Make a thumbs up or thumbs down gesture in front of your camera.")
49
 
50
+ # Button to start webcam
 
 
 
 
 
 
 
 
 
 
 
51
  if st.button("Start Webcam"):
52
+ # Use Streamlit's built-in camera input
53
+ video_input = st.camera_input("Camera Input")
54
+
55
+ if video_input is not None:
56
+ # Read the video input
57
+ image = Image.open(video_input)
58
+ processed_image = process_hand(np.array(image))
 
 
 
 
 
59
 
60
+ # Display the processed output
61
+ st.image(cv2.cvtColor(processed_image, cv2.COLOR_BGR2RGB), caption="Processed Output", use_column_width=True)