frameviewer module

Handles the display of frames in the Frame Viewer section of Faceswap’s Manual Tool.

frame module

Module Summary

ActionsFrame The left hand action frame holding the action buttons.
BackgroundImage The background image of the canvas
DisplayFrame The main video display frame (top left section of GUI).
FrameViewer Annotation onto tkInter Canvas.
Navigation Handles playback and frame navigation for the Frame Viewer Window.

Module

The frame viewer section of the manual tool GUI

class tools.manual.frameviewer.frame.ActionsFrame(parent)

Bases: tkinter.ttk.Frame

The left hand action frame holding the action buttons.

Parameters:parent (DisplayFrame) – The Display frame that the Actions reside in
actions

The available action names as a tuple of strings.

Type:tuple
add_optional_buttons(editors)

Add the optional editor specific action buttons

key_bindings

action}. The mapping of key presses to actions. Keyboard shortcut is the first letter of each action.

Type:dict
Type:{key
on_click(action)

Click event for all of the main buttons.

Parameters:action (str) – The action name for the button that has called this event as exists in _buttons
tk_selected_action

The variable holding the currently selected action

Type:tkinter.StringVar
class tools.manual.frameviewer.frame.DisplayFrame(parent, tk_globals, detected_faces)

Bases: tkinter.ttk.Frame

The main video display frame (top left section of GUI).

Parameters:
  • parent (ttk.PanedWindow) – The paned window that the display frame resides in
  • tk_globals (TkGlobals) – The tkinter variables that apply to the whole of the GUI
  • detected_faces (tools.manual.detected_faces.DetectedFaces) – The detected faces stored in the alignments file
active_editor

The current editor in use based on selected_action.

Type:Editor
cycle_filter_mode()

Cycle the navigation mode combo entry

editors

All of the Editor that the canvas holds

Type:dict
navigation

Class that handles frame Navigation and transport.

Type:Navigation
set_action(key)

Set the current action based on keyboard shortcut

Parameters:key (str) – The pressed key
tk_control_colors

Editor key with tkinter.StringVar containing the selected color hex code for each annotation

Type:dict
tk_selected_action

The variable holding the currently selected action

Type:tkinter.StringVar
tk_selected_mask

Editor key with tkinter.StringVar containing the selected color hex code for each annotation

Type:dict
class tools.manual.frameviewer.frame.FrameViewer(parent, tk_globals, detected_faces, actions, tk_action_var)

Bases: tkinter.Canvas

Annotation onto tkInter Canvas.

Parameters:
  • parent (tkinter.ttk.Frame) – The parent frame for the canvas
  • tk_globals (TkGlobals) – The tkinter variables that apply to the whole of the GUI
  • detected_faces (AlignmentsData) – The alignments data for this manual session
  • actions (tuple) – The available actions from ActionFrame.actions
  • tk_action_var (tkinter.StringVar) – The variable holding the currently selected action
active_editor

The current editor in use based on selected_action.

Type:Editor
annotation_formats

The selected formatting options for each annotation

Type:dict
control_tk_vars

dictionary of tkinter variables as populated by the right hand control panel. Tracking for all control panel variables, for access from all editors.

Type:dict
editor_display

List of editors and any additional annotations they should display.

Type:dict
editors

All of the Editor objects that exist

Type:dict
key_bindings

dictionary of key bindings for each editor for access from all editors.

Type:dict
offset

The (width, height) offset of the canvas based on the size of the currently displayed image

Type:tuple
selected_action

The name of the currently selected Editor action

Type:str

control module

Module Summary

BackgroundImage The background image of the canvas
Navigation Handles playback and frame navigation for the Frame Viewer Window.

Module

Handles Navigation and Background Image for the Frame Viewer section of the manual tool GUI.

class tools.manual.frameviewer.control.BackgroundImage(canvas)

Bases: object

The background image of the canvas

refresh(view_mode)

Update the displayed frame.

Parameters:view_mode (["frame", "face"]) – The currently active editor’s selected view mode.
class tools.manual.frameviewer.control.Navigation(display_frame)

Bases: object

Handles playback and frame navigation for the Frame Viewer Window.

Parameters:display_frame (DisplayFrame) – The parent frame viewer window
decrement_frame()

Update The frame navigation position to the previous frame based on filter.

goto_first_frame()

Go to the first frame that meets the filter criteria.

goto_last_frame()

Go to the last frame that meets the filter criteria.

handle_play_button()

Handle the play button.

Switches the tk_is_playing variable.

increment_frame(frame_count=None, is_playing=False)

Update The frame navigation position to the next frame based on filter.

nav_scale_callback(*args, reset_progress=True)

Adjust transport slider scale for different filters.

Returns:True if the navigation scale has been updated otherwise False
Return type:bool
stop_playback()

Stop play back if playing

tk_is_playing

Whether the stream is currently playing.

Type:tkinter.BooleanVar

editor package

_base module

Module Summary

Editor Parent Class for Object Editors.
View The view Editor.

Module

Editor objects for the manual adjustments tool

class tools.manual.frameviewer.editor._base.Editor(canvas, detected_faces, control_text='', key_bindings=None)

Bases: object

Parent Class for Object Editors.

Editors allow the user to use a variety of tools to manipulate alignments from the main display frame.

Parameters:
  • canvas (tkinter.Canvas) – The canvas that holds the image and annotations
  • detected_faces (DetectedFaces) – The _detected_faces data for this manual session
  • control_text (str) – The text that is to be displayed at the top of the Editor’s control panel.
actions

The optional action buttons for the actions frame in the GUI for the current editor

Type:list
bind_mouse_motion()

Binds the mouse motion for the current editor’s mouse <Motion> event to the editor’s _update_cursor() function.

Called on initialization and active editor update.

controls

The control panel options and header text for the current editor

Type:dict
hide_annotation(tag=None)

Hide annotations for this editor.

Parameters:tag (str, optional) – The specific tag to hide annotations for. If None then all annotations for this editor are hidden, otherwise only the annotations specified by the given tag are hidden. Default: None
scale_from_display(points, do_offset=True)

Scale and offset the given points from the current display to the correct original values.

Parameters:
  • points (numpy.ndarray) – Array of x, y co-ordinates to adjust
  • offset (bool, optional) – True if the offset should be calculated otherwise False. Default: True
Returns:

The adjusted x, y co-ordinates to the original frame location rounded to the nearest integer

Return type:

numpy.ndarray

set_mouse_click_actions()

Add the bindings for left mouse button click and drag actions.

This binds the mouse to the _drag_start(), _drag() and _drag_stop() methods.

By default these methods do nothing (except for _drag_stop() which resets _drag_data.

This bindings should be added for all editors. To add additional bindings, super().set_mouse_click_actions should be called prior to adding them..

update_annotation()

Update the display annotations for the current objects.

Override for specific editors.

view_mode

The view mode for the currently selected editor. If the editor does not have a view mode that can be updated, then “frame” will be returned.

Type:[“frame”, “face”]
class tools.manual.frameviewer.editor._base.View(canvas, detected_faces)

Bases: tools.manual.frameviewer.editor._base.Editor

The view Editor.

Does not allow any editing, just used for previewing annotations.

This is the default start-up editor.

Parameters:
  • canvas (tkinter.Canvas) – The canvas that holds the image and annotations
  • detected_faces (DetectedFaces) – The _detected_faces data for this manual session

bounding_box module

Bounding Box Editor for the manual adjustments tool

class tools.manual.frameviewer.editor.bounding_box.BoundingBox(canvas, detected_faces)

Bases: tools.manual.frameviewer.editor._base.Editor

The Bounding Box Editor.

Adjusting the bounding box feeds the aligner to generate new 68 point landmarks.

Parameters:
  • canvas (tkinter.Canvas) – The canvas that holds the image and annotations
  • detected_faces (DetectedFaces) – The _detected_faces data for this manual session
set_mouse_click_actions()

Add context menu to OS specific right click action.

update_annotation()

Get the latest bounding box data from alignments and update.

extract_box module

Extract Box Editor for the manual adjustments tool

class tools.manual.frameviewer.editor.extract_box.ExtractBox(canvas, detected_faces)

Bases: tools.manual.frameviewer.editor._base.Editor

The Extract Box Editor.

Adjust the calculated Extract Box to shift all of the 68 point landmarks in place.

Parameters:
  • canvas (tkinter.Canvas) – The canvas that holds the image and annotations
  • detected_faces (DetectedFaces) – The _detected_faces data for this manual session
set_mouse_click_actions()

Add context menu to OS specific right click action.

update_annotation()

Draw the latest Extract Boxes around the faces.

landmarks module

Module Summary

Landmarks The Landmarks Editor.
Mesh The Landmarks Mesh Display.

Module

Landmarks Editor and Landmarks Mesh viewer for the manual adjustments tool

class tools.manual.frameviewer.editor.landmarks.Landmarks(canvas, detected_faces)

Bases: tools.manual.frameviewer.editor._base.Editor

The Landmarks Editor.

Adjust individual landmark points and re-generate Extract Box.

Parameters:
  • canvas (tkinter.Canvas) – The canvas that holds the image and annotations
  • detected_faces (DetectedFaces) – The _detected_faces data for this manual session
update_annotation()

Get the latest Landmarks points and update.

class tools.manual.frameviewer.editor.landmarks.Mesh(canvas, detected_faces)

Bases: tools.manual.frameviewer.editor._base.Editor

The Landmarks Mesh Display.

There are no editing options for Mesh editor. It is purely aesthetic and updated when other editors are used.

Parameters:
  • canvas (tkinter.Canvas) – The canvas that holds the image and annotations
  • detected_faces (DetectedFaces) – The _detected_faces data for this manual session
update_annotation()

Get the latest Landmarks and update the mesh.

mask module

Mask Editor for the manual adjustments tool

class tools.manual.frameviewer.editor.mask.Mask(canvas, detected_faces)

Bases: tools.manual.frameviewer.editor._base.Editor

The mask Editor.

Edit a mask in the alignments file.

Parameters:
  • canvas (tkinter.Canvas) – The canvas that holds the image and annotations
  • detected_faces (DetectedFaces) – The _detected_faces data for this manual session
hide_annotation(tag=None)

Clear the mask _meta dict when hiding the annotation.

update_annotation()

Update the mask annotation with the latest mask.