src/wai_data_tools/movie_to_images.py
def split_video_file_to_frame_files(video_filepath: Path,
                                    excel_dataframe: pd.DataFrame,
                                    label_config: Dict[str, Union[int, bool, str]]
                                    ) -> Dict[int, Dict[str, Union[np.ndarray, bool]]]:
    """
    Splits a video file into separate frames in the form of .jpeg files.
    :param video_filepath: Path to .mjpg video file
    :param excel_dataframe: Dataframe with file information
    :param label_config: Label configuration
    """

    label_name = label_config["name"]
    is_target = label_config["is_target"]
    sampling_frequency = label_config["sampling_frequency"]

    logging.debug("Splitting video file to frame files...")

    reader = get_video_reader(video_filepath=video_filepath)
    meta = reader.get_meta_data()

    logging.debug("Filtering dataframe based on label %s", label_name)
    excel_dataframe = excel_dataframe[excel_dataframe["label"] == label_name]
    video_row = excel_dataframe[excel_dataframe["filename"] == video_filepath.name]
    if video_row.shape[0] > 1:
        raise ValueError("More than 1 entry found that matches the query in the dataframe")

    if is_target:
        target_frames = calculate_frames_in_timespan(t_start=video_row["start"].values,
                                                     t_end=video_row["end"].values,
                                                     fps=meta["fps"])
    else:
        target_frames = []

    frames_dict = read_frames_in_video(video_reader=reader,
                                       frames_with_target=target_frames,
                                       sampling_frequency=sampling_frequency)
    return frames_dict

    Splits a video file into separate frames in the form of .jpeg files.
    :param video_filepath: Path to .mjpg video file
    :param excel_dataframe: Dataframe with file information
    :param label_config: Label configuration
    
Splits a video file into separate frames in the form of .jpeg files.
Splits a video file into separate frames in the form of . jpeg files .
def split_video_file_to_frame_files(video_filepath: Path,
                                    excel_dataframe: pd.DataFrame,
                                    label_config: Dict[str, Union[int, bool, str]]
                                    ) -> Dict[int, Dict[str, Union[np.ndarray, bool]]]:
    label_name = label_config["name"]
    is_target = label_config["is_target"]
    sampling_frequency = label_config["sampling_frequency"]
    logging.debug("Splitting video file to frame files...")
    reader = get_video_reader(video_filepath=video_filepath)
    meta = reader.get_meta_data()
    logging.debug("Filtering dataframe based on label %s", label_name)
    excel_dataframe = excel_dataframe[excel_dataframe["label"] == label_name]
    video_row = excel_dataframe[excel_dataframe["filename"] == video_filepath.name]
    if video_row.shape[0] > 1:
        raise ValueError("More than 1 entry found that matches the query in the dataframe")
    if is_target:
        target_frames = calculate_frames_in_timespan(t_start=video_row["start"].values,
                                                     t_end=video_row["end"].values,
                                                     fps=meta["fps"])
    else:
        target_frames = []
    frames_dict = read_frames_in_video(video_reader=reader,
                                       frames_with_target=target_frames,
                                       sampling_frequency=sampling_frequency)
    return frames_dict
def split_video_file_to_frame_files ( video_filepath : Path , excel_dataframe : pd . DataFrame , label_config : Dict [ str , Union [ int , bool , str ] ] ) -> Dict [ int , Dict [ str , Union [ np . ndarray , bool ] ] ] : label_name = label_config [ "name" ] is_target = label_config [ "is_target" ] sampling_frequency = label_config [ "sampling_frequency" ] logging . debug ( "Splitting video file to frame files..." ) reader = get_video_reader ( video_filepath = video_filepath ) meta = reader . get_meta_data ( ) logging . debug ( "Filtering dataframe based on label %s" , label_name ) excel_dataframe = excel_dataframe [ excel_dataframe [ "label" ] == label_name ] video_row = excel_dataframe [ excel_dataframe [ "filename" ] == video_filepath . name ] if video_row . shape [ 0 ] > 1 : raise ValueError ( "More than 1 entry found that matches the query in the dataframe" ) if is_target : target_frames = calculate_frames_in_timespan ( t_start = video_row [ "start" ] . values , t_end = video_row [ "end" ] . values , fps = meta [ "fps" ] ) else : target_frames = [ ] frames_dict = read_frames_in_video ( video_reader = reader , frames_with_target = target_frames , sampling_frequency = sampling_frequency ) return frames_dict
Splits a video file into separate frames in the form of .jpeg files.
Splits a video file into separate frames in the form of . jpeg files .
"""
    Splits a video file into separate frames in the form of .jpeg files.
    :param video_filepath: Path to .mjpg video file
    :param excel_dataframe: Dataframe with file information
    :param label_config: Label configuration
    """
video_filepath
Path
Path to .mjpg video file
Path to . mjpg video file
excel_dataframe
pd.DataFrame
Dataframe with file information
Dataframe with file information
label_config
Dict[str, Union[int, bool, str]]
None