AlBaraa63 commited on
Commit
b12eefb
·
verified ·
1 Parent(s): a7834b4

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -40
app.py CHANGED
@@ -16,11 +16,7 @@ def main():
16
  st.title("Yellow Object Detection")
17
 
18
  # Mode selection in main screen
19
- options = ["Upload Image"]
20
- if WEBRTC_AVAILABLE:
21
- options.append("Webcam (Live Browser)")
22
-
23
- mode = st.selectbox("Select Mode", options, key="mode_selector")
24
 
25
  if mode == "Upload Image":
26
  st.write("Upload an image to detect yellow objects.")
@@ -52,41 +48,9 @@ def main():
52
  result_image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
53
 
54
  st.image(result_image, caption="Processed Image", use_column_width=True)
55
-
56
- elif mode == "Webcam (Live Browser)":
57
- st.write("This mode works on the web! It uses your browser's webcam.")
58
-
59
- class VideoProcessor(VideoTransformerBase):
60
- def transform(self, frame):
61
- img = frame.to_ndarray(format="bgr24")
62
-
63
- # Process the image
64
- yellow = [0, 255, 255] # Yellow in BGR
65
- hsv_image = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
66
- lower_limit, upper_limit = get_limits(color=yellow)
67
- mask = cv2.inRange(hsv_image, lower_limit, upper_limit)
68
- mask = cv2.medianBlur(mask, 3)
69
-
70
- contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
71
-
72
- for contour in contours:
73
- if cv2.contourArea(contour) > 400:
74
- x, y, w, h = cv2.boundingRect(contour)
75
- img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 5)
76
-
77
- return img
78
-
79
- webrtc_streamer(
80
- key="yellow-detection",
81
- video_transformer_factory=VideoProcessor,
82
- rtc_configuration={
83
- "iceServers": [
84
- {"urls": ["stun:stun.l.google.com:19302"]},
85
- {"urls": ["stun:stun1.l.google.com:19302"]},
86
- ]
87
- },
88
- media_stream_constraints={"video": True, "audio": False},
89
- )
90
 
91
  if __name__ == "__main__":
92
  main()
 
16
  st.title("Yellow Object Detection")
17
 
18
  # Mode selection in main screen
19
+ mode = st.selectbox("Select Mode", ["Upload Image"], key="mode_selector")
 
 
 
 
20
 
21
  if mode == "Upload Image":
22
  st.write("Upload an image to detect yellow objects.")
 
48
  result_image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
49
 
50
  st.image(result_image, caption="Processed Image", use_column_width=True)
51
+
52
+ # Maintenance notice
53
+ st.info("🔧 Live Webcam Mode - Under Maintenance")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  if __name__ == "__main__":
56
  main()