-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStreamData.py
More file actions
44 lines (30 loc) · 732 Bytes
/
StreamData.py
File metadata and controls
44 lines (30 loc) · 732 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
37
38
39
40
41
42
43
import numpy as np
import matplotlib.pyplot as plt
import cv2
FILE_DIR = 'data/'
class StreamData:
def __init__(self, video):
self.directory = FILE_DIR + video
def getVideo(self):
self.cap = cv2.VideoCapture(self.directory)
if self.cap.isOpened() is not True:
self.cap.open()
def getFrame(self):
ret, frame = self.cap.read()
if ret is False:
self.cap.release()
return ret
return ret, cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
def close(self):
if self.cap.isOpened():
self.cap.release()
return True
return False
def getTime(self):
return self.cap.get(cv2.cv.CV_CAP_PROP_POS_MSEC)
def printMatrix(mat):
for row in mat:
s = ''
for col in row:
s += ' ' + str(col)
print s