-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrameExtract.py
56 lines (47 loc) · 1.55 KB
/
FrameExtract.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import cv2
import os
import shutil
'''
sourcePath = './data/SDR_540p/'
savedPath = './data/low/'
filelist = sorted(os.listdir(sourcePath))
for filename in filelist:
videoCapture = cv2.VideoCapture(sourcePath + filename)
i = 0
while True:
success, frame = videoCapture.read()
if not success:
print('Video %s is all read, %d frames in total' % (filename, i))
break
i += 1
savedname = "%s_%03d.jpg" % (filename.split('.')[0], i)
cv2.imwrite(savedPath + savedname, frame)
sourcePath = './data/SDR_4K/'
savedPath = './data/high/'
filelist = sorted(os.listdir(sourcePath))
for filename in filelist:
videoCapture = cv2.VideoCapture(sourcePath + filename)
i = 0
while True:
success, frame = videoCapture.read()
if not success:
print('Video %s is all read, %d frames in total' % (filename, i))
break
i += 1
savedname = "%s_%03d.jpg" % (filename.split('.')[0], i)
cv2.imwrite(savedPath + savedname, frame)
'''
sourcePath = './SDR_540p/'
savedPath = './data/test/'
filelist = sorted(os.listdir(sourcePath))
for filename in filelist:
videoCapture = cv2.VideoCapture(sourcePath + filename)
i = 0
while True:
success, frame = videoCapture.read()
if not success:
print('Video %s is all read, %d frames in total' % (filename, i))
break
i += 1
savedname = "%s_%03d.jpg" % (filename.split('.')[0], i)
cv2.imwrite(savedPath + savedname, frame)