mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-07 05:22:06 -07:00
fix performance issue
This commit is contained in:
parent
3549272244
commit
4ffae1a954
1 changed files with 9 additions and 2 deletions
|
@ -8,7 +8,10 @@ from tqdm import tqdm
|
||||||
|
|
||||||
class Interact(object):
|
class Interact(object):
|
||||||
EVENT_LBUTTONDOWN = 1
|
EVENT_LBUTTONDOWN = 1
|
||||||
EVENT_MOUSEWHEEL = 2
|
EVENT_LBUTTONUP = 2
|
||||||
|
EVENT_RBUTTONDOWN = 5
|
||||||
|
EVENT_RBUTTONUP = 6
|
||||||
|
EVENT_MOUSEWHEEL = 10
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.named_windows = {}
|
self.named_windows = {}
|
||||||
|
@ -55,7 +58,11 @@ class Interact(object):
|
||||||
def onMouse(event, x, y, flags, param):
|
def onMouse(event, x, y, flags, param):
|
||||||
(inst, wnd_name) = param
|
(inst, wnd_name) = param
|
||||||
if event == cv2.EVENT_LBUTTONDOWN: ev = Interact.EVENT_LBUTTONDOWN
|
if event == cv2.EVENT_LBUTTONDOWN: ev = Interact.EVENT_LBUTTONDOWN
|
||||||
|
elif event == cv2.EVENT_LBUTTONUP: ev = Interact.EVENT_LBUTTONUP
|
||||||
|
elif event == cv2.EVENT_RBUTTONDOWN: ev = Interact.EVENT_RBUTTONDOWN
|
||||||
|
elif event == cv2.EVENT_RBUTTONUP: ev = Interact.EVENT_RBUTTONUP
|
||||||
elif event == cv2.EVENT_MOUSEWHEEL: ev = Interact.EVENT_MOUSEWHEEL
|
elif event == cv2.EVENT_MOUSEWHEEL: ev = Interact.EVENT_MOUSEWHEEL
|
||||||
|
|
||||||
else: ev = 0
|
else: ev = 0
|
||||||
inst.add_mouse_event (wnd_name, x, y, ev, flags)
|
inst.add_mouse_event (wnd_name, x, y, ev, flags)
|
||||||
|
|
||||||
|
@ -105,7 +112,7 @@ class Interact(object):
|
||||||
|
|
||||||
if has_windows or has_capture_keys:
|
if has_windows or has_capture_keys:
|
||||||
wait_key_time = int(sleep_time / 1000) if sleep_time != 0 else 1
|
wait_key_time = int(sleep_time / 1000) if sleep_time != 0 else 1
|
||||||
key = cv2.waitKey(1) & 0xFF
|
key = cv2.waitKey(wait_key_time) & 0xFF
|
||||||
else:
|
else:
|
||||||
if sleep_time != 0:
|
if sleep_time != 0:
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue