src/wai_data_tools/movie_to_images.py
def read_frames_in_video(video_reader: Any,
                         frames_with_target: np.ndarray,
                         sampling_frequency: int = 1) -> Dict[int, Dict[str, Union[np.ndarray, bool]]]:
    """
    Reads the frames in a video by iterating a video reader object.
    :param video_reader: imageio reader for the video to filter.
    :param frames_with_target: array with frame indices for frames that should be marked as containing a target class.
    :param sampling_frequency: How often in video to read frame in video, i.e. sampling frequency of 2 is every
                               second frame and sampling frequency 4 is every fourth frame. Default is 1.
    :return: a dict of dicts where the key in root dict is the frame index and values is dicts with frame information.
             Each frame information dict follows schema:
             {"image": numpy array for frame image,
              "contains_target": boolean if label is present in image}
    """

    logging.debug("Filtering frames in video to label and non label frames")
    frames_dict = {}
    for frame_ind, frame_img in enumerate(video_reader):
        if frame_ind % sampling_frequency != 0:
            continue
        if frame_ind in frames_with_target:
            contains_label = True
        else:
            contains_label = False

        frame_information_dict = {
            "image": frame_img,
            "contains_target": contains_label
        }
        frames_dict[frame_ind] = frame_information_dict
    return frames_dict

    Reads the frames in a video by iterating a video reader object.
    :param video_reader: imageio reader for the video to filter.
    :param frames_with_target: array with frame indices for frames that should be marked as containing a target class.
    :param sampling_frequency: How often in video to read frame in video, i.e. sampling frequency of 2 is every
                               second frame and sampling frequency 4 is every fourth frame. Default is 1.
    :return: a dict of dicts where the key in root dict is the frame index and values is dicts with frame information.
             Each frame information dict follows schema:
             {"image": numpy array for frame image,
              "contains_target": boolean if label is present in image}
    
Reads the frames in a video by iterating a video reader object.
Reads the frames in a video by iterating a video reader object .
def read_frames_in_video(video_reader: Any,
                         frames_with_target: np.ndarray,
                         sampling_frequency: int = 1) -> Dict[int, Dict[str, Union[np.ndarray, bool]]]:
    logging.debug("Filtering frames in video to label and non label frames")
    frames_dict = {}
    for frame_ind, frame_img in enumerate(video_reader):
        if frame_ind % sampling_frequency != 0:
            continue
        if frame_ind in frames_with_target:
            contains_label = True
        else:
            contains_label = False
        frame_information_dict = {
            "image": frame_img,
            "contains_target": contains_label
        }
        frames_dict[frame_ind] = frame_information_dict
    return frames_dict
def read_frames_in_video ( video_reader : Any , frames_with_target : np . ndarray , sampling_frequency : int = 1 ) -> Dict [ int , Dict [ str , Union [ np . ndarray , bool ] ] ] : logging . debug ( "Filtering frames in video to label and non label frames" ) frames_dict = { } for frame_ind , frame_img in enumerate ( video_reader ) : if frame_ind % sampling_frequency != 0 : continue if frame_ind in frames_with_target : contains_label = True else : contains_label = False frame_information_dict = { "image" : frame_img , "contains_target" : contains_label } frames_dict [ frame_ind ] = frame_information_dict return frames_dict
Reads the frames in a video by iterating a video reader object.
Reads the frames in a video by iterating a video reader object .
"""
    Reads the frames in a video by iterating a video reader object.
    :param video_reader: imageio reader for the video to filter.
    :param frames_with_target: array with frame indices for frames that should be marked as containing a target class.
    :param sampling_frequency: How often in video to read frame in video, i.e. sampling frequency of 2 is every
                               second frame and sampling frequency 4 is every fourth frame. Default is 1.
    :return: a dict of dicts where the key in root dict is the frame index and values is dicts with frame information.
             Each frame information dict follows schema:
             {"image": numpy array for frame image,
              "contains_target": boolean if label is present in image}
    """
a dict of dicts where the key in root dict is the frame index and values is dicts with frame information.
Each frame information dict follows schema:
{"image": numpy array for frame image,
"contains_target": boolean if label is present in image}
a dict of dicts where the key in root dict is the frame index and values is dicts with frame information . Each frame information dict follows schema : { " image " : numpy array for frame image " contains_target " : boolean if label is present in image }
video_reader
Any
imageio reader for the video to filter.
imageio reader for the video to filter .
frames_with_target
np.ndarray
array with frame indices for frames that should be marked as containing a target class.
array with frame indices for frames that should be marked as containing a target class .
sampling_frequency
int
None