forked from JasmineZhen218/Sign-Language-Identification
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo_to_frame.py
More file actions
36 lines (26 loc) · 999 Bytes
/
video_to_frame.py
File metadata and controls
36 lines (26 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import cv2
from skimage.color import rgb2gray
from skimage.transform import resize
import matplotlib.pyplot as plt
import math
def FrameCapture(pathin, pathout):
# Path to video file
vidObj = cv2.VideoCapture(pathin)
# Used as counter variable
count = 0
# checks whether frames were extracted
success, image = vidObj.read()
while success:
# vidObj object calls read
# function extract frames
# Saves the frames with frame-count
#cv2.imwrite("/content/drive/MyDrive/ML_final/External_test_data/frame%d.jpg" % count, image)
cv2.imwrite(pathout+"/%d.jpg" % count, image)
image = rgb2gray(image)
if count%5 == 0:
plt.imshow(image, cmap='gray')
plt.show()
count += 1
success, image = vidObj.read()
if __name__ == '__main__':
FrameCapture("/content/drive/MyDrive/ML_final/IMG_0358.MP4", "/content/drive/MyDrive/ML_final/External_test_data")