Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,32 +9,24 @@ model = YOLO("best.pt") # Ensure the path to your model is correct
|
|
| 9 |
# Set the title of the app
|
| 10 |
st.title("Live Fire Detection App")
|
| 11 |
|
| 12 |
-
|
| 13 |
-
lower_red = np.array([0, 100, 100])
|
| 14 |
-
upper_red = np.array([10, 255, 255])
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
while True:
|
| 20 |
ret, frame = cap.read()
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
# Create a mask for the fire color range
|
| 26 |
-
mask = cv2.inRange(hsv, lower_red, upper_red)
|
| 27 |
-
|
| 28 |
-
# Apply the mask to the original frame
|
| 29 |
-
res = cv2.bitwise_and(frame, frame, mask=mask)
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
cv2.imshow('
|
| 33 |
|
| 34 |
-
# Exit if 'q' is pressed
|
| 35 |
if cv2.waitKey(1) & 0xFF == ord('q'):
|
| 36 |
break
|
| 37 |
|
| 38 |
-
# Release the capture and close windows
|
| 39 |
cap.release()
|
| 40 |
-
cv2.destroyAllWindows()
|
|
|
|
| 9 |
# Set the title of the app
|
| 10 |
st.title("Live Fire Detection App")
|
| 11 |
|
| 12 |
+
cap = cv2.VideoCapture(0) # 0 for default camera
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
if not cap.isOpened():
|
| 15 |
+
print("Error: Could not open video capture device.")
|
| 16 |
+
exit()
|
| 17 |
|
| 18 |
while True:
|
| 19 |
ret, frame = cap.read()
|
| 20 |
|
| 21 |
+
if not ret:
|
| 22 |
+
print("Error: Could not read frame.")
|
| 23 |
+
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
# Process the frame here (e.g., display, save, analyze)
|
| 26 |
+
cv2.imshow('Frame', frame)
|
| 27 |
|
|
|
|
| 28 |
if cv2.waitKey(1) & 0xFF == ord('q'):
|
| 29 |
break
|
| 30 |
|
|
|
|
| 31 |
cap.release()
|
| 32 |
+
cv2.destroyAllWindows()
|