Compare commits
3 Commits
520aef31ca
...
8a41a3c1f8
Author | SHA1 | Date |
---|---|---|
|
8a41a3c1f8 | |
|
14ab470dcc | |
|
72287ce89e |
|
@ -6,7 +6,6 @@ from typing import Callable, Tuple, List, Any
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
import cv2
|
import cv2
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps
|
||||||
from pygrabber.dshow_graph import FilterGraph
|
|
||||||
import pyvirtualcam
|
import pyvirtualcam
|
||||||
|
|
||||||
# Import OS-specific modules only when necessary
|
# Import OS-specific modules only when necessary
|
||||||
|
@ -14,6 +13,8 @@ if platform.system() == 'Darwin': # macOS
|
||||||
import objc
|
import objc
|
||||||
from Foundation import NSObject
|
from Foundation import NSObject
|
||||||
import AVFoundation
|
import AVFoundation
|
||||||
|
elif platform.system() == 'Windows' or platform.system() == 'Linux':
|
||||||
|
from pygrabber.dshow_graph import FilterGraph
|
||||||
|
|
||||||
import modules.globals
|
import modules.globals
|
||||||
import modules.metadata
|
import modules.metadata
|
||||||
|
@ -116,6 +117,9 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||||
source_button = ctk.CTkButton(root, text='Select a face', cursor='hand2', command=select_source_path)
|
source_button = ctk.CTkButton(root, text='Select a face', cursor='hand2', command=select_source_path)
|
||||||
source_button.place(relx=0.1, rely=0.35, relwidth=0.3, relheight=0.1)
|
source_button.place(relx=0.1, rely=0.35, relwidth=0.3, relheight=0.1)
|
||||||
|
|
||||||
|
swap_faces_button = ctk.CTkButton(root, text='↔', cursor='hand2', command=lambda: swap_faces_paths())
|
||||||
|
swap_faces_button.place(relx=0.45, rely=0.4, relwidth=0.1, relheight=0.1)
|
||||||
|
|
||||||
target_button = ctk.CTkButton(root, text='Select a target', cursor='hand2', command=select_target_path)
|
target_button = ctk.CTkButton(root, text='Select a target', cursor='hand2', command=select_target_path)
|
||||||
target_button.place(relx=0.6, rely=0.35, relwidth=0.3, relheight=0.1)
|
target_button.place(relx=0.6, rely=0.35, relwidth=0.3, relheight=0.1)
|
||||||
|
|
||||||
|
@ -221,6 +225,30 @@ def select_source_path() -> None:
|
||||||
source_label.configure(image=None)
|
source_label.configure(image=None)
|
||||||
|
|
||||||
|
|
||||||
|
def swap_faces_paths() -> None:
|
||||||
|
global RECENT_DIRECTORY_SOURCE, RECENT_DIRECTORY_TARGET
|
||||||
|
|
||||||
|
source_path = modules.globals.source_path
|
||||||
|
target_path = modules.globals.target_path
|
||||||
|
|
||||||
|
if not is_image(source_path) or not is_image(target_path):
|
||||||
|
return
|
||||||
|
|
||||||
|
modules.globals.source_path = target_path
|
||||||
|
modules.globals.target_path = source_path
|
||||||
|
|
||||||
|
RECENT_DIRECTORY_SOURCE = os.path.dirname(modules.globals.source_path)
|
||||||
|
RECENT_DIRECTORY_TARGET = os.path.dirname(modules.globals.target_path)
|
||||||
|
|
||||||
|
PREVIEW.withdraw()
|
||||||
|
|
||||||
|
source_image = render_image_preview(modules.globals.source_path, (200, 200))
|
||||||
|
source_label.configure(image=source_image)
|
||||||
|
|
||||||
|
target_image = render_image_preview(modules.globals.target_path, (200, 200))
|
||||||
|
target_label.configure(image=target_image)
|
||||||
|
|
||||||
|
|
||||||
def select_target_path() -> None:
|
def select_target_path() -> None:
|
||||||
global RECENT_DIRECTORY_TARGET
|
global RECENT_DIRECTORY_TARGET
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue