-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowManager.py
More file actions
35 lines (27 loc) · 777 Bytes
/
WindowManager.py
File metadata and controls
35 lines (27 loc) · 777 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
import cv2
nextPosList = [
[0, 0],
[400, 0],
[0, 400],
[400, 400]
]
_nextPosIter = 0
def next_pos():
global _nextPosIter
pos = nextPosList[_nextPosIter]
_nextPosIter = (_nextPosIter+1)%4
return pos
class WindowManager(object):
def __init__(self, name, size=(400, 400), pos=next_pos()):
self.name = name
self.size = size
cv2.startWindowThread()
self.window = cv2.namedWindow(name, cv2.WINDOW_NORMAL | cv2.WINDOW_AUTOSIZE)
cv2.resizeWindow(name, *size)
# cv2.moveWindow(name, *pos)
def put(self, img):
img = cv2.resize(src=img, dsize=tuple(self.size))
if img is None:
print "\n\nNONENONENONE\n\n"
cv2.imshow(self.name, img)
cv2.waitKey(5)