Beispiel #1
0
def temporal_filter_callback(msg):
    """Runs temporal filtering according to parameters read from the message.

    Args:
        msg (dict[str, str]): Message received from RabbitMQ publisher.
    """
    print("Running temporal filtering...")

    # If such frames do not exist, S3 simply does not download them
    msg_cp = copy(msg)
    frames = get_frame_range(msg["filter_first"], msg["filter_last"])
    image_types_to_level = [("color", msg["level"]),
                            ("disparity", msg["level"])]
    if msg["use_foreground_masks"]:
        image_types_to_level.append(("foreground_masks", msg["level"]))

    ran_download = download_rig(msg)
    ran_download |= download_image_types(msg, image_types_to_level, frames)

    msg_cp[
        "disparity"] = ""  # disparity_level is automatically populated by app
    _run_bin(msg_cp)
    processed_frames = get_frame_range(msg["first"], msg["last"])
    ran_upload = upload_image_type(msg,
                                   "disparity_time_filtered",
                                   processed_frames,
                                   level=msg["level"])
    _clean_worker(ran_download, ran_upload)
Beispiel #2
0
    def _get_missing_chunks(self, params, frame_chunks):
        if params["force_recompute"]:
            return frame_chunks

        print(f"Checking cache for {params['app']}...")
        if isinstance(params["dst_level"], list):
            missing_frames = set()
            for dst_level in params["dst_level"]:
                new_missing_chunks = self._get_missing_chunks_level(
                    params, dst_level, frame_chunks)
                if new_missing_chunks is None:
                    return frame_chunks
                missing_frames = missing_frames.union(new_missing_chunks)
        else:
            missing_frames = self._get_missing_chunks_level(
                params, params["dst_level"], frame_chunks)
            if missing_frames is None:
                return frame_chunks
        if len(missing_frames) == 0:
            return []

        missing_frame_chunks = []
        for frame_chunk in frame_chunks:
            for frame in get_frame_range(frame_chunk["first"],
                                         frame_chunk["last"]):
                if frame in missing_frames:
                    missing_frame_chunks.append(frame_chunk)
                    break
        return missing_frame_chunks
Beispiel #3
0
def simple_mesh_renderer_callback(msg):
    print("Generating exports...")

    msg_cp = copy(msg)
    frames = get_frame_range(msg_cp["first"], msg_cp["last"])
    ran_download = download_rig(msg)

    ran_download = download_image_type(msg, msg_cp["color_type"], frames)
    ran_download |= download_image_type(msg, msg_cp["disparity_type"], frames)
    msg_cp["color"] = local_image_type_path(msg, msg_cp["color_type"])
    msg_cp["disparity"] = local_image_type_path(msg, msg_cp["disparity_type"])
    msg_cp["output"] = local_image_type_path(msg, msg_cp["dst_image_type"])
    msg_cp["position"] = '"0.0 0.0 0.0"'
    msg_cp["forward"] = '"-1.0 0.0 0.0"'
    msg_cp["up"] = '"0.0 0.0 1.0"'

    _run_bin(msg_cp)
    ran_upload = upload_image_type(msg, msg_cp["dst_image_type"], frames)
    _clean_worker(ran_download, ran_upload)
Beispiel #4
0
def transfer_callback(msg):
    """Runs transfer according to parameters read from the message.

    Args:
        msg (dict[str, str]): Message received from RabbitMQ publisher.
    """
    print("Running rearranging...")

    rig_cameras = get_cameras(msg, "cameras")
    frames = get_frame_range(msg["first"], msg["last"])
    copy_image_level(
        msg,
        msg["src_image_type"],
        msg["dst_image_type"],
        rig_cameras,
        frames,
        msg["src_level"],
        msg["dst_level"],
    )
Beispiel #5
0
    def _get_missing_chunks_level(self, params, level, frame_chunks):
        dst_dir = remote_image_type_path(params, params["dst_image_type"],
                                         level)
        dst_frames = get_frame_range(frame_chunks[0]["first"],
                                     frame_chunks[-1]["last"])
        remote = Address(dst_dir)

        uncompressed = remote.protocol != "s3"
        try:
            expected_frame_fns = set(
                get_frame_fns(params, dst_frames, uncompressed, dst_dir))
            actual_frame_fns = listdir(dst_dir,
                                       run_silently=True,
                                       recursive=True)
        except Exception as e:
            print(e)
            return None

        missing_frames_fns = expected_frame_fns - actual_frame_fns
        missing_frames = [
            os.path.splitext(os.path.basename(frames_fn))[0]
            for frames_fn in missing_frames_fns
        ]
        return missing_frames