Abraham E. Tavarez
commited on
Commit
·
e2d190f
1
Parent(s):
9c93e59
video detector temp folder fixed
Browse files- detector/video.py +9 -3
detector/video.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from deepface import DeepFace
|
2 |
import cv2
|
3 |
import os
|
|
|
4 |
|
5 |
|
6 |
def extract_frames(video_path, interval=30):
|
@@ -11,6 +12,9 @@ def extract_frames(video_path, interval=30):
|
|
11 |
cap = cv2.VideoCapture(video_path)
|
12 |
frames = []
|
13 |
count = 0
|
|
|
|
|
|
|
14 |
|
15 |
# Loop through the video frames
|
16 |
while cap.isOpened():
|
@@ -20,9 +24,11 @@ def extract_frames(video_path, interval=30):
|
|
20 |
|
21 |
#
|
22 |
if count % interval == 0:
|
23 |
-
frame_path = f"
|
24 |
-
|
25 |
-
|
|
|
|
|
26 |
count += 1
|
27 |
|
28 |
# Release the video capture object
|
|
|
1 |
from deepface import DeepFace
|
2 |
import cv2
|
3 |
import os
|
4 |
+
import tempfile
|
5 |
|
6 |
|
7 |
def extract_frames(video_path, interval=30):
|
|
|
12 |
cap = cv2.VideoCapture(video_path)
|
13 |
frames = []
|
14 |
count = 0
|
15 |
+
|
16 |
+
# temp directory
|
17 |
+
temp_dir = tempfile.gettempdir()
|
18 |
|
19 |
# Loop through the video frames
|
20 |
while cap.isOpened():
|
|
|
24 |
|
25 |
#
|
26 |
if count % interval == 0:
|
27 |
+
frame_path = os.path.join(temp_dir, f"frame_{count}.jpg")
|
28 |
+
|
29 |
+
success = cv2.imwrite(frame_path, frame)
|
30 |
+
if success:
|
31 |
+
frames.append(frame_path)
|
32 |
count += 1
|
33 |
|
34 |
# Release the video capture object
|