Beispiel #1
0
 def get_color_frames(self, color_type, suffix):
     frames = getattr(self.parent, f"frames_{color_type}_color{suffix}",
                      None)
     frames_levels = getattr(self.parent,
                             f"frames_{color_type}_color_levels{suffix}",
                             None)
     return sorted(merge_lists(frames, frames_levels))
def update_frame_names(parent,
                       data_types=None,
                       image_types=None,
                       update_local=True,
                       update_s3=True):
    """Updates frame names for given data types

    Args:
        parent: class instance
        data_types (list[str]): List of data types.
        image_types (list[str]): List of image types.
    """
    global verbose
    verbose = parent.verbose

    log(glog.green("Getting frame names..."))
    glog.check(len(parent.cameras) > 0, "No cameras found!")
    camera_ref = parent.cameras[0]
    if not data_types:
        data_types = ["bg", "video"]
    if not image_types:
        image_types = [
            "color", "color_levels", "disparity", "disparity_levels", "bin"
        ]
    for t in data_types:
        for d in image_types:
            if t == "bg" and d == "bin":
                continue
            suffix = f"{t}_{d}" if d != "bin" else d
            p = getattr(parent, f"path_{suffix}", None)
            if "_levels" in d:
                p = posixpath.join(p, "level_0")

            if update_local:
                p_local = posixpath.join(p, camera_ref)
                setattr(
                    parent,
                    f"frames_{suffix}",
                    get_frame_names(parent, p_local, is_cache=True),
                )
                print_frame_range(parent, suffix)
            if update_s3 and parent.is_aws:
                # Cached frames are eventually synced to S3, so any frame in the
                # cache should be added to the S3 frames
                frames_s3 = get_frame_names(parent, p, is_cache=False)
                frames_cache = getattr(parent, f"frames_{suffix}", None)
                frames_s3 = sorted(merge_lists(frames_s3, frames_cache))
                setattr(parent, f"frames_{suffix}_s3", frames_s3)
                print_frame_range(parent, f"{suffix}_s3")
Beispiel #3
0
    def update_frame_names(self):
        """Updates dropdowns to account for available frames (on S3 or locally)."""
        data_types = ["bg"]
        image_types = ["disparity"]
        verify_data.update_frame_names(self.parent,
                                       data_types=data_types,
                                       image_types=image_types,
                                       update_s3=False)

        if self.parent.is_aws:
            # Background is only rendered in cache when using S3 but it will be
            # synced to S3. Add it to the S3 frame list
            self.parent.frames_bg_disparity_s3 = merge_lists(
                self.parent.frames_bg_disparity_s3,
                self.parent.frames_bg_disparity)
Beispiel #4
0
    def get_frame_names(self):
        """Finds all the frames in a local directory.

        Returns:
            list[str]: Sorted list of frame names in the directory.
        """
        s = "_s3" if self.is_aws and self.is_farm else ""
        frames_bin = getattr(self.parent, f"frames_bin{s}", None)
        data_type = self.dlg.dd_export_data_type.currentText()
        if not data_type:
            return frames_bin
        t = "bg" if data_type == "background_color" else "video"
        frames_color = getattr(self.parent, f"frames_{t}_color{s}", None)
        frames_disp = getattr(self.parent, f"frames_{t}_disparity{s}", None)

        return sorted(merge_lists(frames_color, frames_disp, frames_bin))
Beispiel #5
0
    def update_frame_names(self):
        """Updates dropdowns to account for available frames (on S3 or locally)."""
        update_s3 = self.is_aws and self.is_farm
        update_local = not update_s3
        image_types = ["disparity"]
        verify_data.update_frame_names(
            self.parent,
            image_types=image_types,
            update_s3=update_s3,
            update_local=update_local,
        )

        if self.is_aws:
            # Frame was rendered in cache but it will be synced to S3.
            # Add it to the S3 frame list
            self.parent.frames_video_disparity_s3 = merge_lists(
                self.parent.frames_video_disparity_s3,
                self.parent.frames_video_disparity,
            )
Beispiel #6
0
    def get_files(self, tag):
        """Retrieves file names corresponding to the desired attribute.

        Args:
            tag (str): Semantic name for the attribute.

        Returns:
            list[str]: List of file names.

        Raises:
            Exception: If a tag is requested with no associated files.
        """
        if tag == "frame_bg":
            p = self.parent
            return sorted(
                merge_lists(p.frames_bg_color, p.frames_bg_color_levels))
        elif tag == "camera":
            return self.parent.cameras
        else:
            raise Exception(f"Invalid tag: {tag}")