-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflow.py
37 lines (28 loc) · 779 Bytes
/
flow.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
import numpy as np
import cv2 as cv
import argparse
from dehz import dehz, fdehz
# from gamma import adjust_gamma
parser = argparse.ArgumentParser()
parser.add_argument('path')
parser.add_argument('--fast', action='store_true')
args = parser.parse_args()
cap_v = cv.VideoCapture(args.path)
f = fdehz if args.fast else dehz
runtime = 0.0
frame_count = 0
while(cap_v.isOpened()):
ret, frame = cap_v.read()
if ret == False:
break
frame_count += 1
e1 = cv.getTickCount()
frame = f(frame)
e2 = cv.getTickCount()
cv.imshow('frame', frame)
runtime += (e2 - e1) / cv.getTickFrequency()
if cv.waitKey(1) & 0xFF == ord('q'):
break
print('average runtime: %.5fs' % (runtime / frame_count))
cap_v.release()
cv.destroyAllWindows()