-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvideoProcessing.py
33 lines (30 loc) · 1.16 KB
/
videoProcessing.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
import time
import cv2
from imageProcessing import ImageProcessing
class VideoProcessing:
def __init__(self, videoName):
self.videoName = videoName
self.frameCounter = 0
self.second = 0
def videoFunction(self):
cap = cv2.VideoCapture(self.videoName)
first = time.time()
while(cap.isOpened()):
_, frame = cap.read()
if frame is not None:
imageProcessing.image = frame
cv2.imshow(self.videoName, imageProcessing.imageFunction())
last = time.time() - first
if 0.95 < last < 1.01:
self.second += 1
print(self.second, "second(s),", "FPS:", self.frameCounter)
self.frameCounter = 0
first = time.time()
self.frameCounter = self.frameCounter + 1
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
print("The video is finished.")
cap.release()
cv2.destroyAllWindows()
imageProcessing = ImageProcessing()