sleap.gui.dialogs.importvideos¶
Interface to handle the UI for importing videos.
Usage:
>>> import_list = ImportVideos().ask()
This will show the user a file-selection dialog, and then a second dialog to select the import parameters for each file.
It returns a list with data about each file selected by the user.
In particular, we’ll have the name of the file and all of the parameters
relevant for that specific type of file. It also includes a reference
to the relevant method of Video
.
For each item in import_list, we can load the video by calling this method while passing the user-selected params as the named parameters:
>>> vid = item["video_class"](**item["params"])
-
class
sleap.gui.dialogs.importvideos.
ImportItemWidget
(file_path: str, import_type: dict, *args, **kwargs)[source]¶ Widget for selecting parameters with preview when importing video.
- Parameters
file_path (str) – Full path to selected video file.
import_type (dict) – Data about user-selectable import parameters.
-
get_data
() → dict[source]¶ Get all data (fixed and user-selected) for imported video.
- Returns
Dict with data for this video.
-
class
sleap.gui.dialogs.importvideos.
ImportParamDialog
(filenames: list, *args, **kwargs)[source]¶ Dialog for selecting parameters with preview when importing video.
- Parameters
filenames (list) – List of files we want to import.
-
class
sleap.gui.dialogs.importvideos.
ImportParamWidget
(file_path: str, import_type: dict, *args, **kwargs)[source]¶ Widget for allowing user to select video parameters.
- Parameters
file_path – file path/name
import_type – data about the parameters for this type of video
Note
Object is a widget with the UI for params specific to this video type.
-
get_values
(only_required=False)[source]¶ Method to get current user-selected values for import parameters.
- Parameters
only_required – Only return the parameters that are required for instantiating Video object
- Returns
Dict of param keys/values.
Note
It’s easiest if the return dict matches the arguments we need for the Video object, so we’ll add the file name to the dict even though it’s not a user-selectable param.
-
class
sleap.gui.dialogs.importvideos.
VideoPreviewWidget
(video: sleap.io.video.Video = None, *args, **kwargs)[source]¶ Widget to show video preview. Based on
Video
class.- Parameters
video – the video to show
- Returns
None.
Note
This widget is used by ImportItemWidget.
-
load_video
(video: sleap.io.video.Video, initial_frame=0, plot=True)[source]¶ Load the video preview and display label text.