awacke1 commited on
Commit
31f1983
·
verified ·
1 Parent(s): 5545e2c

Create backup1.vidcapworks.app.py

Browse files
Files changed (1) hide show
  1. backup1.vidcapworks.app.py +56 -0
backup1.vidcapworks.app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import cv2
3
+ import numpy as np
4
+ from camera_input_live import camera_input_live
5
+
6
+ # Set page config
7
+ st.set_page_config(page_title="Real-Time Video AI Demo", layout="wide")
8
+
9
+ # Title and description
10
+ st.title("Real-Time Video AI Processing with Streamlit")
11
+ st.write("This app demonstrates real-time webcam video processing with AI filters using Streamlit and OpenCV.")
12
+
13
+ # Sidebar for filter selection
14
+ st.sidebar.header("Filter Controls")
15
+ filter_type = st.sidebar.selectbox(
16
+ "Choose a filter",
17
+ ["None", "Grayscale", "Canny Edge Detection", "Blur"]
18
+ )
19
+
20
+ # Initialize the camera input
21
+ image = camera_input_live()
22
+
23
+ # Process and display the video feed
24
+ if image is not None:
25
+ # Convert the image from bytes to numpy array
26
+ nparr = np.frombuffer(image.getvalue(), np.uint8)
27
+ frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
28
+
29
+ # Apply selected filter
30
+ if filter_type == "Grayscale":
31
+ frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
32
+ # Convert back to 3 channels for Streamlit display
33
+ frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
34
+ elif filter_type == "Canny Edge Detection":
35
+ frame = cv2.Canny(frame, 100, 200)
36
+ # Convert back to 3 channels for Streamlit display
37
+ frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
38
+ elif filter_type == "Blur":
39
+ frame = cv2.GaussianBlur(frame, (15, 15), 0)
40
+
41
+ # Display the processed frame
42
+ st.image(frame, channels="RGB", caption="Live Video Feed")
43
+ else:
44
+ st.warning("Waiting for camera input...")
45
+
46
+ # Instructions
47
+ st.sidebar.markdown("""
48
+ ### Instructions
49
+ 1. Allow camera access when prompted
50
+ 2. Select a filter from the dropdown
51
+ 3. View the processed video in real-time
52
+ 4. Try different filters to see AI processing in action
53
+ """)
54
+
55
+ # Requirements note
56
+ st.sidebar.info("Make sure you have installed: streamlit, opencv-python, numpy, streamlit-camera-input-live")