Update app.py
Browse files
app.py
CHANGED
@@ -5,12 +5,7 @@ import tempfile
|
|
5 |
import os
|
6 |
|
7 |
def detect_and_predict(video):
|
8 |
-
|
9 |
-
temp_video_path = tempfile.NamedTemporaryFile(delete=False, suffix='.mp4').name
|
10 |
-
with open(temp_video_path, "wb") as f:
|
11 |
-
f.write(video.read())
|
12 |
-
|
13 |
-
cap = cv2.VideoCapture(temp_video_path)
|
14 |
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
15 |
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
16 |
|
@@ -18,6 +13,8 @@ def detect_and_predict(video):
|
|
18 |
out_path = tempfile.NamedTemporaryFile(delete=False, suffix='.mp4').name
|
19 |
out = cv2.VideoWriter(out_path, fourcc, 20.0, (width, height))
|
20 |
|
|
|
|
|
21 |
ball_color_lower = np.array([5, 50, 50]) # Orange/red lower
|
22 |
ball_color_upper = np.array([15, 255, 255]) # Orange/red upper
|
23 |
trajectory_points = []
|
|
|
5 |
import os
|
6 |
|
7 |
def detect_and_predict(video):
|
8 |
+
cap = cv2.VideoCapture(video)
|
|
|
|
|
|
|
|
|
|
|
9 |
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
10 |
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
11 |
|
|
|
13 |
out_path = tempfile.NamedTemporaryFile(delete=False, suffix='.mp4').name
|
14 |
out = cv2.VideoWriter(out_path, fourcc, 20.0, (width, height))
|
15 |
|
16 |
+
# ... rest of your code continues ...
|
17 |
+
|
18 |
ball_color_lower = np.array([5, 50, 50]) # Orange/red lower
|
19 |
ball_color_upper = np.array([15, 255, 255]) # Orange/red upper
|
20 |
trajectory_points = []
|