-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo2pic.py
More file actions
31 lines (24 loc) · 706 Bytes
/
Copy pathvideo2pic.py
File metadata and controls
31 lines (24 loc) · 706 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
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 3 10:15:56 2018
@author: Xiang Guo
"""
import numpy as np
import cv2
import os
import glob
os.chdir('E:\\Xiang Guo\\JIGSAWS data\\Motion_History_Image')
videolist = glob.glob('*.avi')
for vid in videolist:
path = 'E:\\Xiang Guo\\JIGSAWS data\\Motion_History_Image\\videos_frames\\' + vid.split('.')[0]
os.mkdir(path)
vidcap = cv2.VideoCapture(vid)
success,image = vidcap.read()
count = 0
success = True
while success:
success,image = vidcap.read()
filename = str("\\%d.jpg" % (count+1))
filepath = path + filename
cv2.imwrite(filepath, image) # save frame as JPEG file
count += 1