frameviewer module
Handles the display of frames in the Frame Viewer section of Faceswap’s Manual Tool.
frame module
Module Summary
The left hand action frame holding the action buttons. |
|
|
The background image of the canvas |
The main video display frame (top left section of GUI). |
|
Annotation onto tkInter Canvas. |
|
|
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:
Frame
The left hand action frame holding the action buttons.
- Parameters:
parent (
DisplayFrame
) – The Display frame that the Actions reside in
- property actions
The available action names as a tuple of strings.
- Type:
tuple
- add_optional_buttons(editors)
Add the optional editor specific action buttons
- property 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
- property 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:
Frame
The main video display frame (top left section of GUI).
- Parameters:
parent (
ttk.PanedWindow
) – The paned window that the display frame resides intk_globals (
TkGlobals
) – The tkinter variables that apply to the whole of the GUIdetected_faces (
tools.manual.detected_faces.DetectedFaces
) – The detected faces stored in the alignments file
- property active_editor
The current editor in use based on
selected_action
.- Type:
Editor
- cycle_filter_mode()
Cycle the navigation mode combo entry
- property editors
All of the
Editor
that the canvas holds- Type:
dict
Class that handles frame Navigation and transport.
- Type:
- pack_threshold_slider()
Display or hide the threshold slider depending on the current filter mode. For misaligned faces filter, display the slider. Hide for all other filters.
- set_action(key)
Set the current action based on keyboard shortcut
- Parameters:
key (str) – The pressed key
- property tk_control_colors
Editor key with
tkinter.StringVar
containing the selected color hex code for each annotation- Type:
dict
- property tk_selected_action
The variable holding the currently selected action
- Type:
tkinter.StringVar
- property 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:
Canvas
Annotation onto tkInter Canvas.
- Parameters:
parent (
tkinter.ttk.Frame
) – The parent frame for the canvastk_globals (
TkGlobals
) – The tkinter variables that apply to the whole of the GUIdetected_faces (
AlignmentsData
) – The alignments data for this manual sessionactions (tuple) – The available actions from
ActionFrame.actions
tk_action_var (
tkinter.StringVar
) – The variable holding the currently selected action
- property active_editor
The current editor in use based on
selected_action
.- Type:
Editor
- property annotation_formats
The selected formatting options for each annotation
- Type:
dict
- property 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
- property editor_display
List of editors and any additional annotations they should display.
- Type:
dict
- property editors
All of the
Editor
objects that exist- Type:
dict
- property key_bindings
dictionary of key bindings for each editor for access from all editors.
- Type:
dict
- property offset
The (width, height) offset of the canvas based on the size of the currently displayed image
- Type:
tuple
- property selected_action
The name of the currently selected Editor action
- Type:
str
control module
Module Summary
The background image of the canvas |
|
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.
Bases:
object
Handles playback and frame navigation for the Frame Viewer Window.
- Parameters:
display_frame (
DisplayFrame
) – The parent frame viewer window
Update The frame navigation position to the previous frame based on filter.
Go to the first frame that meets the filter criteria.
Go to the last frame that meets the filter criteria.
Handle the play button.
Switches the
tk_is_playing
variable.
Update The frame navigation position to the next frame based on filter.
Adjust transport slider scale for different filters. Hide or display optional filter controls.
Stop play back if playing
Whether the stream is currently playing.
- Type:
tkinter.BooleanVar
editor package
_base module
Module Summary
Parent Class for Object Editors. |
|
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 annotationsdetected_faces (
DetectedFaces
) – The _detected_faces data for this manual sessioncontrol_text (str) – The text that is to be displayed at the top of the Editor’s control panel.
- property 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.
- property 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 adjustoffset (bool, optional) –
True
if the offset should be calculated otherwiseFalse
. 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.
- property 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:
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 annotationsdetected_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:
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 annotationsdetected_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:
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 annotationsdetected_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
The Landmarks Editor. |
|
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:
Editor
The Landmarks Editor.
Adjust individual landmark points and re-generate Extract Box.
- Parameters:
canvas (
tkinter.Canvas
) – The canvas that holds the image and annotationsdetected_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:
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 annotationsdetected_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:
Editor
The mask Editor.
Edit a mask in the alignments file.
- Parameters:
canvas (
tkinter.Canvas
) – The canvas that holds the image and annotationsdetected_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.