Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,20 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
|
|
|
| 4 |
|
| 5 |
-
st.set_page_config(page_title="
|
| 6 |
|
| 7 |
-
st.title("📷
|
| 8 |
-
st.write("This app captures video from your webcam and displays it live.")
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
cap = cv2.VideoCapture(0) # Open webcam
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
cap.release()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
| 4 |
+
from PIL import Image
|
| 5 |
|
| 6 |
+
st.set_page_config(page_title="Webcam App", page_icon="📷")
|
| 7 |
|
| 8 |
+
st.title("📷 Streamlit Webcam App")
|
|
|
|
| 9 |
|
| 10 |
+
# Use Streamlit's built-in camera input
|
| 11 |
+
image_file = st.camera_input("Take a picture")
|
|
|
|
| 12 |
|
| 13 |
+
if image_file:
|
| 14 |
+
# Convert image to OpenCV format
|
| 15 |
+
img = Image.open(image_file)
|
| 16 |
+
img = np.array(img) # Convert to NumPy array
|
| 17 |
+
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) # Convert to OpenCV BGR format
|
| 18 |
+
|
| 19 |
+
# Show the captured image
|
| 20 |
+
st.image(img, caption="Captured Image", use_column_width=True)
|
|
|
|
|
|