fix(): remove preview window switch and fix typo
parent
e0dafa0b9b
commit
4d2c793d4b
|
@ -85,9 +85,9 @@ def create_face_masks(
|
||||||
x, y, w, h = cv2.boundingRect(lower_lip_polygon)
|
x, y, w, h = cv2.boundingRect(lower_lip_polygon)
|
||||||
mouth_cutout = frame[y : y + h, x : x + w].copy()
|
mouth_cutout = frame[y : y + h, x : x + w].copy()
|
||||||
|
|
||||||
return face_mask, mouth_cutout, (x, y, w, h), lower_lip_polygon
|
return face_mask, mouth_mask, mouth_cutout, (x, y, w, h), lower_lip_polygon
|
||||||
|
|
||||||
return None, None, None, None
|
return None, None, None, None, None
|
||||||
|
|
||||||
|
|
||||||
def apply_mouth_area(
|
def apply_mouth_area(
|
||||||
|
@ -138,9 +138,8 @@ def swap_face(source_face: Face, target_face: Face, temp_frame: Frame) -> Frame:
|
||||||
|
|
||||||
if modules.globals.mouth_mask:
|
if modules.globals.mouth_mask:
|
||||||
# Create masks
|
# Create masks
|
||||||
face_mask = create_face_mask(target_face, temp_frame)
|
face_mask, mouth_mask, mouth_cutout, mouth_box, lower_lip_polygon = (
|
||||||
mouth_mask, mouth_cutout, mouth_box, lower_lip_polygon = (
|
create_face_masks(target_face, temp_frame)
|
||||||
create_lower_mouth_mask(target_face, temp_frame)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if mouth_mask is not None:
|
if mouth_mask is not None:
|
||||||
|
|
|
@ -97,6 +97,9 @@ def save_switch_states():
|
||||||
"live_resizable": modules.globals.live_resizable,
|
"live_resizable": modules.globals.live_resizable,
|
||||||
"fp_ui": modules.globals.fp_ui,
|
"fp_ui": modules.globals.fp_ui,
|
||||||
"show_fps": modules.globals.show_fps,
|
"show_fps": modules.globals.show_fps,
|
||||||
|
"show_mouth": modules.globals.mouth_mask,
|
||||||
|
"show_mouth_mask_box": modules.globals.show_mouth_mask_box,
|
||||||
|
"mouth_mask_switch_preview": modules.globals.mouth_mask_switch_preview,
|
||||||
}
|
}
|
||||||
with open("switch_states.json", "w") as f:
|
with open("switch_states.json", "w") as f:
|
||||||
json.dump(switch_states, f)
|
json.dump(switch_states, f)
|
||||||
|
@ -117,6 +120,10 @@ def load_switch_states():
|
||||||
modules.globals.live_resizable = switch_states.get("live_resizable", False)
|
modules.globals.live_resizable = switch_states.get("live_resizable", False)
|
||||||
modules.globals.fp_ui = switch_states.get("fp_ui", {"face_enhancer": False})
|
modules.globals.fp_ui = switch_states.get("fp_ui", {"face_enhancer": False})
|
||||||
modules.globals.show_fps = switch_states.get("show_fps", False)
|
modules.globals.show_fps = switch_states.get("show_fps", False)
|
||||||
|
modules.globals.mouth_mask = switch_states.get("mouth_mask", False)
|
||||||
|
modules.globals.show_mouth_mask_box = switch_states.get(
|
||||||
|
"show_mouth_mask_box", False
|
||||||
|
)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
# If the file doesn't exist, use default values
|
# If the file doesn't exist, use default values
|
||||||
pass
|
pass
|
||||||
|
@ -513,8 +520,7 @@ def update_popup_source(
|
||||||
|
|
||||||
def toggle_mouthmask():
|
def toggle_mouthmask():
|
||||||
"""
|
"""
|
||||||
Toggle the mouth mask state and synchronize all UI switches.
|
Toggle the mouth mask state.
|
||||||
Updates both the global state and any existing switch controls.
|
|
||||||
"""
|
"""
|
||||||
is_mouthmask = modules.globals.mouth_mask_var.get()
|
is_mouthmask = modules.globals.mouth_mask_var.get()
|
||||||
modules.globals.mouth_mask = is_mouthmask
|
modules.globals.mouth_mask = is_mouthmask
|
||||||
|
@ -526,13 +532,6 @@ def toggle_mouthmask():
|
||||||
else:
|
else:
|
||||||
modules.globals.mouth_mask_switch_root.deselect()
|
modules.globals.mouth_mask_switch_root.deselect()
|
||||||
|
|
||||||
# Update preview window switch if it exists
|
|
||||||
if hasattr(modules.globals, "mouth_mask_switch_preview"):
|
|
||||||
if is_mouthmask:
|
|
||||||
modules.globals.mouth_mask_switch_preview.select()
|
|
||||||
else:
|
|
||||||
modules.globals.mouth_mask_switch_preview.deselect()
|
|
||||||
|
|
||||||
|
|
||||||
def create_preview(parent: ctk.CTkToplevel) -> ctk.CTkToplevel:
|
def create_preview(parent: ctk.CTkToplevel) -> ctk.CTkToplevel:
|
||||||
global preview_label, preview_slider
|
global preview_label, preview_slider
|
||||||
|
@ -550,17 +549,6 @@ def create_preview(parent: ctk.CTkToplevel) -> ctk.CTkToplevel:
|
||||||
preview_slider = ctk.CTkSlider(
|
preview_slider = ctk.CTkSlider(
|
||||||
preview, from_=0, to=0, command=lambda frame_value: update_preview(frame_value)
|
preview, from_=0, to=0, command=lambda frame_value: update_preview(frame_value)
|
||||||
)
|
)
|
||||||
mouth_mask_switch_preview = ctk.CTkSwitch(
|
|
||||||
preview,
|
|
||||||
text="Mouth Mask",
|
|
||||||
variable=modules.globals.mouth_mask_var,
|
|
||||||
cursor="hand2",
|
|
||||||
command=toggle_mouthmask,
|
|
||||||
)
|
|
||||||
mouth_mask_switch_preview.pack(side="left", padx=5, pady=5)
|
|
||||||
|
|
||||||
# Store the switch in modules.globals for access from create_root
|
|
||||||
modules.globals.mouth_mask_switch_preview = mouth_mask_switch_preview
|
|
||||||
|
|
||||||
return preview
|
return preview
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue