src/wai_data_tools/movie_to_images.py
def save_frames(frames_dict: Dict[int, Dict[str, Union[np.ndarray, bool]]],
                src_video_filestem: str,
                label_name: str,
                dst_frame_dir: pathlib.Path) -> None:
    """
    Saves frames in a frame list to a destination root directory. folder location will depend on label presence.
    :param frames_dict: List of dict containing where each dict contains frame array and target presence information.
    :param src_video_filestem: filename stem of source video
    :param label_name: Target class label name
    :param dst_frame_dir: destination root directory to save frames
    """
    logging.debug("Saving frames")

    for frame_ind, frame_dict in frames_dict.items():
        frame_img = frame_dict["image"]
        if frame_dict["contains_target"]:
            label_folder_name = label_name
        else:
            label_folder_name = f"background"

        output_filename = f"{src_video_filestem}___{frame_ind}.jpeg"
        output_label_dir = dst_frame_dir / src_video_filestem / label_folder_name
        output_label_dir.mkdir(parents=True, exist_ok=True)
        imageio.imwrite(output_label_dir / output_filename, frame_img)

    Saves frames in a frame list to a destination root directory. folder location will depend on label presence.
    :param frames_dict: List of dict containing where each dict contains frame array and target presence information.
    :param src_video_filestem: filename stem of source video
    :param label_name: Target class label name
    :param dst_frame_dir: destination root directory to save frames
    
Saves frames in a frame list to a destination root directory. folder location will depend on label presence.
Saves frames in a frame list to a destination root directory . folder location will depend on label presence .
def save_frames(frames_dict: Dict[int, Dict[str, Union[np.ndarray, bool]]],
                src_video_filestem: str,
                label_name: str,
                dst_frame_dir: pathlib.Path) -> None:
    logging.debug("Saving frames")
    for frame_ind, frame_dict in frames_dict.items():
        frame_img = frame_dict["image"]
        if frame_dict["contains_target"]:
            label_folder_name = label_name
        else:
            label_folder_name = f"background"
        output_filename = f"{src_video_filestem}___{frame_ind}.jpeg"
        output_label_dir = dst_frame_dir / src_video_filestem / label_folder_name
        output_label_dir.mkdir(parents=True, exist_ok=True)
        imageio.imwrite(output_label_dir / output_filename, frame_img)
def save_frames ( frames_dict : Dict [ int , Dict [ str , Union [ np . ndarray , bool ] ] ] , src_video_filestem : str , label_name : str , dst_frame_dir : pathlib . Path ) -> None : logging . debug ( "Saving frames" ) for frame_ind , frame_dict in frames_dict . items ( ) : frame_img = frame_dict [ "image" ] if frame_dict [ "contains_target" ] : label_folder_name = label_name else : label_folder_name = f"background" output_filename = f"{src_video_filestem}___{frame_ind}.jpeg" output_label_dir = dst_frame_dir / src_video_filestem / label_folder_name output_label_dir . mkdir ( parents = True , exist_ok = True ) imageio . imwrite ( output_label_dir / output_filename , frame_img )
Saves frames in a frame list to a destination root directory.
Saves frames in a frame list to a destination root directory .
"""
    Saves frames in a frame list to a destination root directory. folder location will depend on label presence.
    :param frames_dict: List of dict containing where each dict contains frame array and target presence information.
    :param src_video_filestem: filename stem of source video
    :param label_name: Target class label name
    :param dst_frame_dir: destination root directory to save frames
    """
frames_dict
Dict[int, Dict[str, Union[np.ndarray, bool]]]
List of dict containing where each dict contains frame array and target presence information.
List of dict containing where each dict contains frame array and target presence information .
src_video_filestem
str
filename stem of source video
filename stem of source video
label_name
str
Target class label name
Target class label name
dst_frame_dir
pathlib.Path
destination root directory to save frames
destination root directory to save frames