-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep01_VideoSplitPreProcess.py
More file actions
29 lines (25 loc) · 932 Bytes
/
step01_VideoSplitPreProcess.py
File metadata and controls
29 lines (25 loc) · 932 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
import cv2
import os
import sys
#Excluding the letters J and Z
letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y']
for x in letters:
current_letter = x
dir_name = os.path.dirname(__file__)
filename = os.path.join(dir_name, 'Videos', current_letter + '.mp4')
frame_location = os.path.join(dir_name, 'uncropped_frames', 'letter_' + current_letter)
CHECK_FOLDER = os.path.isdir(frame_location)
# If folder doesn't exist, then create it.
if not CHECK_FOLDER:
os.makedirs(frame_location)
capture = cv2.VideoCapture(filename)
frameNr = 0
while (True):
success, frame = capture.read()
if success:
cv2.imwrite(f'{frame_location}/{current_letter}_frame_{frameNr}.jpg', frame)
else:
break
frameNr = frameNr + 1
print(frameNr)
capture.release()