-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo_static_opengl.py
executable file
·50 lines (37 loc) · 1.05 KB
/
video_static_opengl.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
49
50
#!/usr/bin/env python
import cv2
import numpy as np
import timeit
font = cv2.FONT_HERSHEY_DUPLEX
# Image parameters
w = 1280
h = 720
# c = 1 # monochrome
c = 3 # color
# Timing
N = 10
k = 0
t = timeit.default_timer()
t_prev = 0
fps_imshow = 0
fps = 0
cv2.namedWindow('window',cv2.WINDOW_AUTOSIZE | cv2.WINDOW_KEEPRATIO | cv2.WINDOW_OPENGL)
while(True):
k += 1
static = np.random.randint(0,255,[h,w,c],np.uint8)
# timing
if(k % N == 0):
t_prev = t
t = timeit.default_timer()
fps = N/(t-t_prev)
cv2.putText(static, "fps display: {0:.1f}".format(fps), (0, 30), font, 1, (0, 0, 255), 1, cv2.LINE_AA)
cv2.putText(static, "fps imshow: {0:.1f}".format(fps_imshow), (0, 60), font, 1, (0, 255, 0), 1, cv2.LINE_AA)
t_start = timeit.default_timer()
cv2.imshow('window',static)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
t_stop = timeit.default_timer()
fps_imshow = 1/(t_stop-t_start)
cv2.destroyAllWindows()
# Hack not to "hang" the window in *nix systems (Linux,Mac)
cv2.waitKey(1)