-
Notifications
You must be signed in to change notification settings - Fork 1
/
video_get presenter_images.py
48 lines (39 loc) · 1.28 KB
/
video_get presenter_images.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
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 21 18:48:53 2018
@author: Metin
"""
import os, os.path
import cv2
path = "news"
video_count = len([name for name in os.listdir(path) if os.path.isfile(os.path.join(path, name))])
imageName = 0
for i in range(0, video_count):
videoName = path + "/" + str(i) + ".avi"
video = cv2.VideoCapture(videoName)
if (video.isOpened()== False):
print("Error opening video stream or file")
j = 1
count = 15
isFinish = False
while(video.isOpened() and (isFinish == False) and count != 0):
""" Capture frame-by-frame """
ret, frame = video.read()
if ret == True:
if(j % 3 == 0):
cv2.imwrite("presenter_images/%d.jpg" % imageName, frame)
imageName += 1
count -= 1
j += 1
""" Display the resulting frame """
cv2.imshow('frame', frame)
""" Press Q on keyboard to exit """
if cv2.waitKey(25) & 0xFF == ord('q'):
isFinish = True
else:
""" Break the loop"""
isFinish = True
""" When everything done, release the video capture object"""
video.release()
""" Closes all the frames """
cv2.destroyAllWindows()