|
facebook360_dep
Facebook360 Depth Estimation Pipeline
|
Functions | |
| def | browse_dir (caption="Select directory") |
| def | browse_file (caption="Select file", filter="") |
| def | setup_file_explorer (tree, path="") |
| def | preview_file (model, tree, frame, label, prefix="") |
| def | grab_flag_value_from_file (flagfile_fn, flag_name) |
| def | extract_flag_from_string (str, var_name) |
| def | write_flagfile (flagfile_fn, flags) |
| def | update_flagfile (flagfile_fn, flag_name, flag_value) |
| def | grab_variances_from_flagfile (flagfile) |
| def | camel_to_snake (str) |
| def | get_first_file_path (dir, ext=".*") |
| def | get_first_image_path (dir) |
| def | get_level_image_path (dir, cam_id, frame, level=0) |
| def | get_image_path (dir, cam_id, frame) |
| def | listdir_nohidden (dir) |
| def | is_dir_empty (dir) |
| def | remove_prefix (str, prefix) |
| def | get_files_ext (dir, ext, needle="") |
| def | check_image_existance (image_dir, recursive=True) |
| def | get_stem (p) |
| def | get_frame_list (dir) |
| def | get_cam_ids_from_json (json_fn) |
| def | get_dict_value_no_prefix (dict, key, prefix) |
| def | get_qt_button_suffix (gb, suffix) |
| def | get_qt_lineedit_suffix (gb, suffix) |
| def | get_qt_dropdown_suffix (gb, suffix) |
| def | get_qt_checkbox_suffix (gb, suffix) |
| def | get_qt_textedit_suffix (gb, suffix) |
| def | update_qt_dropdown (dd, value, add_if_missing=False) |
| def | update_qt_dropdown_from_flags (flags, key, prefix, dd) |
| def | update_qt_lineedit_from_flags (flags, key, prefix, le) |
| def | update_qt_checkbox_from_flags (flags, key, prefix, cb) |
| def | update_qt_label_from_flags (flags, key, prefix, label) |
| def | setup_read_only_checkbox (checkbox) |
| def | disconnect (signal) |
| def | scale_image (image, scale) |
| def | load_image_resized (filename, width) |
| def | convert_to_float (image) |
| def | run_subprocess (cmd) |
| def | animate_resize (object, size_start, size_end, duration_ms=250) |
| def | switch_objects_prefix (parent, prefixes, state) |
| def | get_tooltip (app_path) |
| def | populate_dropdown (dd, ps, prefix="") |
| def | switch_tab (tab_widget, suffix) |
| def | set_tab_enabled (tab_widget, suffix, enabled) |
| def | is_tab_enabled (tab_widget, suffix) |
| def | get_timestamp (format="%Y%m%d%H%M%S") |
| def | is_host_up (hostname) |
| def | set_integer_validator (qt_element) |
| def | popup_message (parent, text, title="", icon=QMessageBox.Information) |
| def | get_local_frame_width (dir) |
| def | set_full_size_widths (parent) |
Variables | |
| dir_scripts = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| dir_root = os.path.dirname(dir_scripts) | |
| def dep_util.animate_resize | ( | object, | |
| size_start, | |||
| size_end, | |||
duration_ms = 250 |
|||
| ) |
Create resize animation on the UI.
Args:
object (App(QDialog)): UI element to be resized.
size_start (QSize): QT tuple of the window size at start.
size_end (QSize): QT tuple of the window size after resizing.
duration_ms (int, optional): Length of the animation in ms.
| def dep_util.browse_dir | ( | caption = "Select directory" | ) |
Creates a dialog allowing directory selection.
Args:
caption (str, optional): Caption to prefix the displayed directory.
Returns:
QtWidgets.QFileDialog: Dialog with the selected directory.
| def dep_util.browse_file | ( | caption = "Select file", |
|
filter = "" |
|||
| ) |
Creates a dialog allowing file selection.
Args:
caption (str, optional): Caption to prefix the displayed dialog.
filter (str, optional): Regex filter to select a subset of files.
Returns:
QtWidgets.QFileDialog: Dialog with the selected directory.
| def dep_util.camel_to_snake | ( | str | ) |
Convert from a camel case string to snake case.
Args:
str (str): Camel case string to be converted.
Returns:
str: Snake case string with same contents.
| def dep_util.check_image_existance | ( | image_dir, | |
recursive = True |
|||
| ) |
Check if we have at least one image in the directory.
Args:
image_dir (str): Path to the local directory.
recursive (bool, optional): Whether or not to check through all contained dirs.
Returns:
str: Extension of the first file encountered.
| def dep_util.convert_to_float | ( | image | ) |
Converts the image to an equivalent float representation.
Args:
image (np.array[_]): Any valid cv2 image.
Returns:
np.array[_]: Floating point equivalent representation of the input image. The
original image is returned if it is already given in floating point.
| def dep_util.disconnect | ( | signal | ) |
Disconnect all signals, ignore if not connected.
Args:
signal (signal.signal): Computer signals sent to this process.
| def dep_util.extract_flag_from_string | ( | str, | |
| var_name | |||
| ) |
Parse a flag value from a string formatted as a flagfile is.
Args:
str (str): String expected to be in the format of a flagfile, i.e.
--a=a.val --b=b.val
flag_name (str): Name of the flag.
Returns:
_: Value corresponding to the flag. If the flag does not exist in
the flagfile, an empty result will be given.
| def dep_util.get_cam_ids_from_json | ( | json_fn | ) |
Finds camera names assuming the standard rig JSON format.
Args:
json_fn (str): Path to a valid rig json.
Returns:
list[str]: Names of cameras. If an invalid JSON is passed in, an empty
result is returned.
| def dep_util.get_dict_value_no_prefix | ( | dict, | |
| key, | |||
| prefix | |||
| ) |
Finds the value in a dictionary with the prefix stripped.
Args:
dict (dict[str, str]): Any map of values.
key (str): Key whose value is to be stripped.
prefix (str): Prefix to remove from the key's value.
Returns:
str: Value with the prefix stripped.
| def dep_util.get_files_ext | ( | dir, | |
| ext, | |||
needle = "" |
|||
| ) |
Returns list of file in dir with given extension, and optionally
filters entries that match needle.
Args:
dir (str): Path to the local directory.
ext (TYPE): Extension of files to be returned.
needle (str, optional): Regex filter to select a subset of files.
Returns:
list[str]: Filenames matching the criteria passed in.
| def dep_util.get_first_file_path | ( | dir, | |
ext = ".*" |
|||
| ) |
Gets the first file in a directory.
Args:
dir (str): Path to the local directory.
ext (str, optional): Regex of the files to be filtered from the directory.
Returns:
str: Name of the first file matching the extension. An empty result
is returned if no such file exists.
| def dep_util.get_first_image_path | ( | dir | ) |
Gets the first file in a directory corresponding to an image.
Args:
dir (str): Path to the local directory.
Returns:
str: Name of the first image file. An empty result is returned
if no such file exists.
| def dep_util.get_frame_list | ( | dir | ) |
Gets a list of frames by picking the stem of any file with an extension, recursively.
Args:
dir (str): Directory containing frame files.
Returns:
list[str]: List of frames.
| def dep_util.get_image_path | ( | dir, | |
| cam_id, | |||
| frame | |||
| ) |
Gets the path to a full-size image assuming the standard structure.
Args:
dir (str): Path to the local directory.
cam_id (str): Name of the camera.
frame (str): Name of the frame (0-padded, six digits).
Returns:
str: Name of the image file matching the description. An empty result is returned
if no such file exists.
| def dep_util.get_level_image_path | ( | dir, | |
| cam_id, | |||
| frame, | |||
level = 0 |
|||
| ) |
Gets the path to a resized level image assuming the standard structure.
Args:
dir (str): Path to the local directory.
cam_id (str): Name of the camera.
frame (str): Name of the frame (0-padded, six digits).
level (int, optional): Level of the resized image.
Returns:
str: Name of the image file matching the description. An empty result is returned
if no such file exists.
| def dep_util.get_local_frame_width | ( | dir | ) |
Finds the width of an image.
Args:
dir (str): Path to a local directory.
Returns:
int: Camera image width.
| def dep_util.get_qt_button_suffix | ( | gb, | |
| suffix | |||
| ) |
Gets the button associated with a tab and suffix.
Args:
gb (QtWidgets.QGroupBox): Group box for the tab.
suffix (str): Text appended to UI element search query.
Returns:
QtWidgets.QPushButton: Button matching btn_{tag}_{suffix}.
| def dep_util.get_qt_checkbox_suffix | ( | gb, | |
| suffix | |||
| ) |
Gets the checkbox associated with a tab and suffix.
Args:
gb (QtWidgets.QGroupBox): Group box for the tab.
suffix (str): Text appended to UI element search query.
Returns:
QtWidgets.QCheckBox: Dropdown matching cb_{suffix}.
| def dep_util.get_qt_dropdown_suffix | ( | gb, | |
| suffix | |||
| ) |
Gets the dropdown associated with a tab and suffix.
Args:
gb (QtWidgets.QGroupBox): Group box for the tab.
suffix (str): Text appended to UI element search query.
Returns:
QtWidgets.QComboBox: Dropdown matching dd_{tag}_{suffix}.
| def dep_util.get_qt_lineedit_suffix | ( | gb, | |
| suffix | |||
| ) |
Gets the line edit associated with a tab and suffix.
Args:
gb (QtWidgets.QGroupBox): Group box for the tab.
suffix (str): Text appended to UI element search query.
Returns:
QtWidgets.QLineEdit: LineEdit matching val_{tag}_{suffix}.
| def dep_util.get_qt_textedit_suffix | ( | gb, | |
| suffix | |||
| ) |
Gets the textedit associated with a tab and suffix.
Args:
gb (QtWidgets.QGroupBox): Group box for the tab.
suffix (str): Text appended to UI element search query.
Returns:
QtWidgets.QPlainTextEdit: Textedit matching text_{tag}_{suffix}.
| def dep_util.get_stem | ( | p | ) |
Gets the name of a file without its extension.
Args:
p (str): File path.
Returns:
str: Basename of the file (i.e. without its extension).
| def dep_util.get_timestamp | ( | format = "%Y%m%d%H%M%S" | ) |
Formatted current time.
Args:
format (str, optional): Format to parse the time.
Returns:
str: Current time in the specified format.
| def dep_util.get_tooltip | ( | app_path | ) |
Creates the contents of a help tooltip.
Args:
app_path (str): Path to the application binary.
Returns:
str: Help displayed when running --help on the binary.
| def dep_util.grab_flag_value_from_file | ( | flagfile_fn, | |
| flag_name | |||
| ) |
Parse a flag value from a flagfile.
Args:
flagfile_fn (str): Path to the flagfile.
flag_name (str): Name of the flag.
Returns:
_: Value corresponding to the flag. If the flag does not exist in
the flagfile, an empty result will be given.
| def dep_util.grab_variances_from_flagfile | ( | flagfile | ) |
Parses variances from a flagfile.
Args:
flagfile (str): Path to the flagfile.
Returns:
tuple[float, float]: Noise and threshold variances.
| def dep_util.is_dir_empty | ( | dir | ) |
Whether or not there exist non-hidden files in a directory.
Args:
dir (str): Path to the local directory.
Returns:
bool: If any non-hidden file exists in the directory.
| def dep_util.is_host_up | ( | hostname | ) |
Whether or not a host is up. Useful only in LAN farms.
Args:
hostname (str): IP of the host.
Returns:
bool: Whether the host is pingable.
| def dep_util.is_tab_enabled | ( | tab_widget, | |
| suffix | |||
| ) |
Determines the interactivity of a tab.
Args:
tab_widget (QtWidgets.QTabWidget): Widget for the tab being made active.
suffix (str): Filters UI elements by those ending with this string.
Returns:
bool: Whether or not the tab is interactable.
| def dep_util.listdir_nohidden | ( | dir | ) |
Gets the non-hidden files of a directory.
Args:
dir (str): Path to the local directory.
Returns:
list[str]: Filenames in the directory that are not hidden.
| def dep_util.load_image_resized | ( | filename, | |
| width | |||
| ) |
Resizes an image when loading it from disk, retaining its aspect ratio.
Args:
filename (str): Path to the image on disk.
width (int): Desired width of the image.
Returns:
np.array[_]: Scaled image (resized with inter-area interpolation).
| def dep_util.populate_dropdown | ( | dd, | |
| ps, | |||
prefix = "" |
|||
| ) |
Populates the dropdown with an appended prefix.
Args:
dd (QtWidgets.QComboBox): Dropdown UI element.
ps (list[str]): Contents of the dropdown.
prefix (str, optional): Prefix for all the list elements.
| def dep_util.popup_message | ( | parent, | |
| text, | |||
title = "", |
|||
icon = QMessageBox.Information |
|||
| ) |
Creates a pop-up with the desired text.
Args:
parent (App(QDialog)): Object corresponding to the parent UI element.
text (str): Text displayed in the message.
title (str, optional): Text in the message header.
icon (QMessageBox.Icon, optional): Icon in the message header.
| def dep_util.preview_file | ( | model, | |
| tree, | |||
| frame, | |||
| label, | |||
prefix = "" |
|||
| ) |
Displays the file and its label on the UI.
Args:
model (QFileSystemModel): File explorer model.
tree (QTreeView): Populated tree tied to the file explorer.
frame (QtWidgets.QLabel): Image display UI element.
label (QtWidgets.QLabel): Text label for the display UI element.
prefix (str, optional): Prefix for label displayed.
Returns:
bool: Success of the image preview.
| def dep_util.remove_prefix | ( | str, | |
| prefix | |||
| ) |
Removes a prefix from a string.
Args:
str (str): Any string to be separated from a prefix.
prefix (str): Part to be stripped off the front.
Returns:
str: String with the prefix removed. If the string doesn't start
with the specified prefix, this is a no-op.
| def dep_util.run_subprocess | ( | cmd | ) |
Runs a process synchronously in the terminal.
Args:
cmd (str): Command to be executed.
Returns:
str: Output of the executed command. An error is returned if it failed.
| def dep_util.scale_image | ( | image, | |
| scale | |||
| ) |
Resizes an image retaining its aspect ratio.
Args:
image (np.array[_]): Any image loaded through cv2.
scale (float): Ratio to resize image.
Returns:
np.array[_]: Scaled image (resized with inter-area interpolation).
| def dep_util.set_full_size_widths | ( | parent | ) |
| def dep_util.set_integer_validator | ( | qt_element | ) |
Create validator to ensure the input is an int.
Args:
qt_element (QtElement): Any element with input.
| def dep_util.set_tab_enabled | ( | tab_widget, | |
| suffix, | |||
| enabled | |||
| ) |
Toggles the interactivity of a tab.
Args:
tab_widget (QtWidgets.QTabWidget): Widget for the tab being made active.
suffix (str): Filters UI elements by those ending with this string.
enabled (bool): Whether or not it is enabled.
| def dep_util.setup_file_explorer | ( | tree, | |
path = "" |
|||
| ) |
Creates the file explorer rooted at a particular path.
Args:
tree (QTreeView): Tree to be populated tied to the file explorer.
path (str, optional): Path to the root of the project.
Returns:
tuple[QFileSystemModel, QTreeView]: File system UI element and tied populated
file tree.
| def dep_util.setup_read_only_checkbox | ( | checkbox | ) |
Creates checkbox that cannot be modified.
Args:
checkbox (QtWidgets.QCheckBox): Checkbox UI element.
| def dep_util.switch_objects_prefix | ( | parent, | |
| prefixes, | |||
| state | |||
| ) |
Toggle objects starting with any number of prefixes.
Args:
parent (App(QDialog)): Object corresponding to the parent UI element.
prefixes (list[str]): Prefixes to be used for filtering elements.
state (bool): Whether or not the elements should be enabled.
| def dep_util.switch_tab | ( | tab_widget, | |
| suffix | |||
| ) |
Switches the active tab.
Args:
tab_widget (QtWidgets.QTabWidget): Widget for the tab being switched to.
suffix (str): Filters UI elements by those ending with this string.
| def dep_util.update_flagfile | ( | flagfile_fn, | |
| flag_name, | |||
| flag_value | |||
| ) |
Updates a flagfile on disk to a new value.
Args:
flagfile_fn (str): Path to the flagfile.
flag_name (str): Name of the flag.
flag_value (_): New value of the flag.
| def dep_util.update_qt_checkbox_from_flags | ( | flags, | |
| key, | |||
| prefix, | |||
| cb | |||
| ) |
Updates values in checkboxes from a flagfile with prefixes stripped.
Args:
flags (dict[str, _]): Flags and their corresponding values.
key (str): Key whose value is to be updated.
prefix (str): Prefix to remove from the key's value.
cb (QtWidgets.QCheckBox): Checkbox UI element.
Returns:
str: Error message (if any) to display.
| def dep_util.update_qt_dropdown | ( | dd, | |
| value, | |||
add_if_missing = False |
|||
| ) |
Adds a new value to a dropdown if requested or invalidates request.
Args:
dd (QtWidgets.QComboBox): Dropdown UI element.
value (str): Value being queried from the dropdown.
add_if_missing (bool, optional): Whether or not to add the value to the
dropdown if it does not exist (True) or reject the request (False).
Returns:
str: Error message (if any) to display.
| def dep_util.update_qt_dropdown_from_flags | ( | flags, | |
| key, | |||
| prefix, | |||
| dd | |||
| ) |
Updates values in dropdowns from a flagfile with prefixes stripped.
Args:
flags (dict[str, _]): Flags and their corresponding values.
key (str): Key whose value is to be updated.
prefix (str): Prefix to remove from the key's value.
dd (QtWidgets.QComboBox): Dropdown UI element.
Returns:
str: Error message (if any) to display.
| def dep_util.update_qt_label_from_flags | ( | flags, | |
| key, | |||
| prefix, | |||
| label | |||
| ) |
Updates values in labels from a flagfile with prefixes stripped.
Args:
flags (dict[str, _]): Flags and their corresponding values.
key (str): Key whose value is to be updated.
prefix (str): Prefix to remove from the key's value.
label (QtWidgets.QLabel): Label UI element.
| def dep_util.update_qt_lineedit_from_flags | ( | flags, | |
| key, | |||
| prefix, | |||
| le | |||
| ) |
Updates values in LineEdits from a flagfile with prefixes stripped.
Args:
flags (dict[str, _]): Flags and their corresponding values.
key (str): Key whose value is to be updated.
prefix (str): Prefix to remove from the key's value.
le (QtWidgets.QLineEdit): LineEdit UI element.
| def dep_util.write_flagfile | ( | flagfile_fn, | |
| flags | |||
| ) |
Write a flags dictionary to disk in gflags format.
Args:
flagfile_fn (str): Path to the flagfile.
flags (dict[str, _]): Flags and their corresponding values.
| dep_util.dir_root = os.path.dirname(dir_scripts) |
| dep_util.dir_scripts = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
1.8.15