mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-07 05:22:06 -07:00
cleaning
This commit is contained in:
parent
efb22ecce0
commit
1f1f94848b
1 changed files with 24 additions and 23 deletions
|
@ -1,8 +1,9 @@
|
|||
import multiprocessing
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import types
|
||||
import multiprocessing
|
||||
|
||||
import cv2
|
||||
from tqdm import tqdm
|
||||
|
||||
|
@ -21,7 +22,7 @@ class InteractBase(object):
|
|||
EVENT_MBUTTONDOWN = 3
|
||||
EVENT_MBUTTONUP = 4
|
||||
EVENT_RBUTTONDOWN = 5
|
||||
EVENT_RBUTTONUP = 6
|
||||
EVENT_RBUTTONUP = 6
|
||||
EVENT_MOUSEWHEEL = 10
|
||||
|
||||
def __init__(self):
|
||||
|
@ -35,7 +36,7 @@ class InteractBase(object):
|
|||
|
||||
def is_support_windows(self):
|
||||
return False
|
||||
|
||||
|
||||
def is_colab(self):
|
||||
return False
|
||||
|
||||
|
@ -44,10 +45,10 @@ class InteractBase(object):
|
|||
|
||||
def on_create_window (self, wnd_name):
|
||||
raise NotImplemented
|
||||
|
||||
|
||||
def on_destroy_window (self, wnd_name):
|
||||
raise NotImplemented
|
||||
|
||||
|
||||
def on_show_image (self, wnd_name, img):
|
||||
raise NotImplemented
|
||||
|
||||
|
@ -77,35 +78,35 @@ class InteractBase(object):
|
|||
else: print("named_window: ", wnd_name, " already created.")
|
||||
|
||||
def destroy_all_windows(self):
|
||||
if len( self.named_windows ) != 0:
|
||||
self.on_destroy_all_windows()
|
||||
if len( self.named_windows ) != 0:
|
||||
self.on_destroy_all_windows()
|
||||
self.named_windows = {}
|
||||
self.capture_mouse_windows = {}
|
||||
self.capture_keys_windows = {}
|
||||
self.mouse_events = {}
|
||||
self.key_events = {}
|
||||
self.focus_wnd_name = None
|
||||
|
||||
|
||||
def destroy_window(self, wnd_name):
|
||||
if wnd_name in self.named_windows:
|
||||
self.on_destroy_window(wnd_name)
|
||||
self.named_windows.pop(wnd_name)
|
||||
|
||||
if wnd_name == self.focus_wnd_name:
|
||||
|
||||
if wnd_name == self.focus_wnd_name:
|
||||
self.focus_wnd_name = list(self.named_windows.keys())[-1] if len( self.named_windows ) != 0 else None
|
||||
|
||||
|
||||
if wnd_name in self.capture_mouse_windows:
|
||||
self.capture_mouse_windows.pop(wnd_name)
|
||||
|
||||
|
||||
if wnd_name in self.capture_keys_windows:
|
||||
self.capture_keys_windows.pop(wnd_name)
|
||||
|
||||
|
||||
if wnd_name in self.mouse_events:
|
||||
self.mouse_events.pop(wnd_name)
|
||||
|
||||
|
||||
if wnd_name in self.key_events:
|
||||
self.key_events.pop(wnd_name)
|
||||
|
||||
|
||||
def show_image(self, wnd_name, img):
|
||||
if wnd_name in self.named_windows:
|
||||
if self.named_windows[wnd_name] == 0:
|
||||
|
@ -277,16 +278,16 @@ class InteractBase(object):
|
|||
|
||||
|
||||
class InteractDesktop(InteractBase):
|
||||
|
||||
|
||||
def is_support_windows(self):
|
||||
return True
|
||||
|
||||
|
||||
def on_destroy_all_windows(self):
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
def on_create_window (self, wnd_name):
|
||||
cv2.namedWindow(wnd_name)
|
||||
|
||||
|
||||
def on_destroy_window (self, wnd_name):
|
||||
cv2.destroyWindow(wnd_name)
|
||||
|
||||
|
@ -295,7 +296,7 @@ class InteractDesktop(InteractBase):
|
|||
|
||||
def on_capture_mouse (self, wnd_name):
|
||||
self.last_xy = (0,0)
|
||||
|
||||
|
||||
def onMouse(event, x, y, flags, param):
|
||||
(inst, wnd_name) = param
|
||||
if event == cv2.EVENT_LBUTTONDOWN: ev = InteractBase.EVENT_LBUTTONDOWN
|
||||
|
@ -304,11 +305,11 @@ class InteractDesktop(InteractBase):
|
|||
elif event == cv2.EVENT_RBUTTONUP: ev = InteractBase.EVENT_RBUTTONUP
|
||||
elif event == cv2.EVENT_MBUTTONDOWN: ev = InteractBase.EVENT_MBUTTONDOWN
|
||||
elif event == cv2.EVENT_MBUTTONUP: ev = InteractBase.EVENT_MBUTTONUP
|
||||
elif event == cv2.EVENT_MOUSEWHEEL:
|
||||
elif event == cv2.EVENT_MOUSEWHEEL:
|
||||
ev = InteractBase.EVENT_MOUSEWHEEL
|
||||
x,y = self.last_xy #fix opencv bug when window size more than screen size
|
||||
else: ev = 0
|
||||
|
||||
|
||||
self.last_xy = (x,y)
|
||||
inst.add_mouse_event (wnd_name, x, y, ev, flags)
|
||||
cv2.setMouseCallback(wnd_name, onMouse, (self,wnd_name) )
|
||||
|
@ -349,7 +350,7 @@ class InteractColab(InteractBase):
|
|||
|
||||
def is_support_windows(self):
|
||||
return False
|
||||
|
||||
|
||||
def is_colab(self):
|
||||
return True
|
||||
|
||||
|
@ -360,7 +361,7 @@ class InteractColab(InteractBase):
|
|||
def on_create_window (self, wnd_name):
|
||||
pass
|
||||
#clear_output()
|
||||
|
||||
|
||||
def on_destroy_window (self, wnd_name):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue