def trim( *, target_list: List[str], is_colored: bool = False, times: Optional[Tuple[float, float]] = None, ): """api to trim movies (note: keyword-only argument) Args: target_list (List[str]): list of movie-file paths. is_colored (bool, optional): flag to output in color. Defaults to False. times (Optional[Tuple[float, float]], optional): [start, stop] parameters for trimming movie (s). Start must be smaller than stop. Defaults to None. If this variable is None, this will be selected using GUI window Returns: return (List[str], optional): list of processed movies. if no process is executed, None is returned """ if not target_list: sys.exit("no target is given!") m_list, p_list, d_list = process.sort_target_type(target_list) return_list: List[str] = [] if not m_list: sys.exit("no movie is given!") if m_list: r = process.TrimmingMovie( target_list=m_list, is_colored=is_colored, times=times ).execute() if r is not None: return_list.extend(r) return return_list if return_list else None
def hist_luminance(*, target_list: List[str], is_colored: bool = False): """api to create histgram of luminance (bgr or gray) of picture (note: keyword-only argument) Args: target_list (List[str]): list of paths of pictures or directories where pictures are stored. is_colored (bool, optional): flag to output in color. Defaults to False. Returns: return (List[str], optional): list of processed pictures, directories where pictures are stored, and movies. if no process is executed, None is returned """ if not target_list: sys.exit("no target is given!") m_list, p_list, d_list = process.sort_target_type(target_list) return_list: List[str] = [] if not p_list and not d_list: sys.exit("no picture, directory is given!") if p_list: r = process.CreatingLuminanceHistgramPicture( target_list=p_list, is_colored=is_colored ).execute() if r is not None: return_list.extend(r) if d_list: r = process.CreatingLuminanceHistgramPictureDirectory( target_list=d_list, is_colored=is_colored ).execute() if r is not None: return_list.extend(r) return return_list if return_list else None
def subtitle( *, target_list: List[str], is_colored: bool = False, text: Optional[str] = None, position: Optional[Tuple[int, int]] = None, size: Optional[float] = None, time: Optional[Tuple[float, float]] = None, ): """api to subtitle movie/picture (note: keyword-only argument) Args: target_list (List[str]): list of movies, pictures or directories where pictures are stored. is_colored (bool, optional): flag to output in color. Defaults to False. text (Optional[str], optional): text to be added into movie/picture. Defaults to None. position (Optional[Tuple[int, int]], optional): position of left end of text (int) [pixel]. Defaults to None. if this is not given, you will select this in GUI window. size (Optional[float], optional): size of text. Defaults to None. if this is not given, you will select this in GUI window. time (Optional[Tuple[float, float]]): time at beginning and end of subtitling (float) [s]. this argument is neglected for picture or directory. Defaults to None. if this is not given, you will select this in GUI window. Returns: return (List[str], optional): list of processed pictures, directories where pictures are stored, and movies. if no process is executed, None is returned """ if not target_list: sys.exit("no target is given!") m_list, p_list, d_list = process.sort_target_type(target_list) return_list: List[str] = [] if not m_list and not p_list and not d_list: sys.exit("no movie, picture, directory is given!") if m_list: r = process.SubtitlingMovie( target_list=m_list, is_colored=is_colored, text=text, position=position, size=size, time=time, ).execute() if r is not None: return_list.extend(r) if p_list: r = process.SubtitlingPicture( target_list=p_list, is_colored=is_colored, text=text, position=position, size=size ).execute() if r is not None: return_list.extend(r) if d_list: r = process.SubtitlingPictureDirectory( target_list=d_list, is_colored=is_colored, text=text, position=position, size=size ).execute() if r is not None: return_list.extend(r) return return_list if return_list else None
def call_capture(args: argparse.Namespace, parser: argparse.ArgumentParser): """call function when capture sub-command is given """ check_arg_subcommand("capture", args, parser) m_list, p_list, d_list = process.sort_target_type(args.target) if not m_list: sys.exit("no movie is given!") if m_list: process.CapturingMovie(target_list=m_list, is_colored=args.color, times=args.time).execute()
def resize( *, target_list: List[str], is_colored: bool = False, scales: Optional[Tuple[float, float]] = None, ): """api to resize movie/picture (note: keyword-only argument) Args: target_list (List[str]): list of movies, pictures or directories where pictures are stored. is_colored (bool, optional): flag to output in color. Defaults to False. scales (Optional[Tuple[float, float]], optional): [x, y] ratios in each direction to scale movie/picture. Defaults to None. if this is not given, you will select this in GUI window Returns: return (List[str], optional): list of processed pictures, directories where pictures are stored, and movies. if no process is executed, None is returned """ if not target_list: sys.exit("no target is given!") m_list, p_list, d_list = process.sort_target_type(target_list) return_list: List[str] = [] if not m_list and not p_list and not d_list: sys.exit("no movie, picture, directory is given!") if m_list: r = process.ResizingMovie( target_list=m_list, is_colored=is_colored, scales=scales ).execute() if r is not None: return_list.extend(r) if p_list: r = process.ResizingPicture( target_list=p_list, is_colored=is_colored, scales=scales ).execute() if r is not None: return_list.extend(r) if d_list: r = process.ResizingPictureDirectory( target_list=d_list, is_colored=is_colored, scales=scales ).execute() if r is not None: return_list.extend(r) return return_list if return_list else None
def crop( *, target_list: List[str], is_colored: bool = False, positions: Optional[Tuple[int, int, int, int]] = None, ): """api to crop movie/picture (note: keyword-only argument) Args: target_list (List[str]): list of movies, pictures or directories where pictures are stored. is_colored (bool, optional): flag to output in color. Defaults to False. postisions (Tuple[int, int, int, int], optional): [x_1, y_1,x_2, y_2] two positions to crop movie/picture. position_1 must be smaller than position_2 Defaults to None. If this variable is None, this will be selected using GUI window Returns: return (List[str], optional): list of processed pictures, directories where pictures are stored, and movies. if no process is executed, None is returned """ if not target_list: sys.exit("no target is given!") m_list, p_list, d_list = process.sort_target_type(target_list) return_list: List[str] = [] if not m_list and not p_list and not d_list: sys.exit("no movie, picture, directory is given!") if m_list: r = process.CroppingMovie( target_list=m_list, is_colored=is_colored, positions=positions ).execute() if r is not None: return_list.extend(r) if p_list: r = process.CroppingPicture( target_list=p_list, is_colored=is_colored, positions=positions ).execute() if r is not None: return_list.extend(r) if d_list: r = process.CroppingPictureDirectory( target_list=d_list, is_colored=is_colored, positions=positions ).execute() if r is not None: return_list.extend(r) return return_list if return_list else None
def call_hist_luminance(args: argparse.Namespace, parser: argparse.ArgumentParser): """call function when hist_luminance sub-command is given """ check_arg_subcommand("hist-luminance", args, parser) m_list, p_list, d_list = process.sort_target_type(args.target) if not p_list and not d_list: sys.exit("no picture, directory is given!") if p_list: process.CreatingLuminanceHistgramPicture( target_list=p_list, is_colored=args.color).execute() if d_list: process.CreatingLuminanceHistgramPictureDirectory( target_list=d_list, is_colored=args.color).execute()
def animate( *, target_list: List[str], is_colored: bool = False, fps: Optional[float] = None, ): """api to animate pictures (note: keyword-only argument) Args: target_list (List[str]): list of pictures or directories where pictures are stored. is_colored (bool, optional): flag to output in color. Defaults to False. fps (Optional[float], optional): fps of created movie. Defaults to None. if this is not given, you will select this in GUI window Returns: return (List[str], optional): list of processed pictures, directories where pictures are stored, and movies. if no process is executed, None is returned """ if not target_list: sys.exit("no target is given!") m_list, p_list, d_list = process.sort_target_type(target_list) return_list: List[str] = [] if not m_list and not p_list and not d_list: sys.exit("no movie, picture, directory is given!") if m_list: r = process.AnimatingMovie( target_list=p_list, is_colored=is_colored, fps=fps ).execute() if r is not None: return_list.extend(r) if p_list: r = process.AnimatingPicture( target_list=p_list, is_colored=is_colored, fps=fps ).execute() if r is not None: return_list.extend(r) if d_list: r = process.AnimatingPictureDirectory( target_list=d_list, is_colored=is_colored, fps=fps ).execute() if r is not None: return_list.extend(r) return return_list if return_list else None
def concatenate( *, target_list: List[str], is_colored: bool = False, number_x: Optional[int] = None, ): """api to concatenate movie/picture (note: keyword-only argument) Args: target_list (List[str]): list of movies, pictures or directories where pictures are stored. is_colored (bool, optional): flag to output in color. Defaults to False. number_x (int, optional): number of targets concatenated in x direction. max is 5. if this variable is None, this will be selected using GUI window Returns: return (List[str], optional): list of processed pictures, directories where pictures are stored, and movies. if no process is executed, None is returned """ if not target_list: sys.exit("no target is given!") m_list, p_list, d_list = process.sort_target_type(target_list) return_list: List[str] = [] if not m_list and not p_list and not d_list: sys.exit("no movie, picture, directory is given!") if m_list: r = process.ConcatenatingMovie( target_list=m_list, is_colored=is_colored, number_x=number_x ).execute() if r is not None: return_list.extend(r) if p_list: r = process.ConcatenatingPicture( target_list=p_list, is_colored=is_colored, number_x=number_x ).execute() if r is not None: return_list.extend(r) if d_list: r = process.ConcatenatingPictureDirectory( target_list=d_list, is_colored=is_colored, number_x=number_x ).execute() if r is not None: return_list.extend(r) return return_list if return_list else None
def call_binarize(args: argparse.Namespace, parser: argparse.ArgumentParser): """call function when binarize sub-command is given """ check_arg_subcommand("binarize", args, parser) m_list, p_list, d_list = process.sort_target_type(args.target) if not m_list and not p_list and not d_list: sys.exit("no movie, picture, directory is given!") if m_list: process.BinarizingMovie(target_list=m_list, thresholds=args.threshold).execute() if p_list: process.BinarizingPicture(target_list=p_list, thresholds=args.threshold).execute() if d_list: process.BinarizingPictureDirectory( target_list=d_list, thresholds=args.threshold).execute()
def binarize( *, target_list: List[str], thresholds: Optional[Tuple[int, int]] = None, ): """api to binarize movie/picture (note: keyword-only argument) Args: target_list (List[str]): list of movies, pictures or directories where pictures are stored. thresholds (Optional[Tuple[int, int]], optional): [low, high] threshold values to be used to binarize movie/picture. Low threshold must be smaller than high one. If this variable is None, this will be selected using GUI window. Defaults to None. Returns: return (List[str], optional): list of processed pictures, directories where pictures are stored, and movies. if no process is executed, None is returned """ if not target_list: sys.exit("no target is given!") m_list, p_list, d_list = process.sort_target_type(target_list) return_list: List[str] = [] if not m_list and not p_list and not d_list: sys.exit("no movie, picture, directory is given!") if m_list: r = process.BinarizingMovie(target_list=m_list, thresholds=thresholds).execute() if r is not None: return_list.extend(r) if p_list: r = process.BinarizingPicture(target_list=p_list, thresholds=thresholds).execute() if r is not None: return_list.extend(r) if d_list: r = process.BinarizingPictureDirectory( target_list=d_list, thresholds=thresholds ).execute() if r is not None: return_list.extend(r) return return_list if return_list else None
def call_animate(args: argparse.Namespace, parser: argparse.ArgumentParser): """call function when animate sub-command is given """ check_arg_subcommand("animate", args, parser) m_list, p_list, d_list = process.sort_target_type(args.target) if not m_list and not p_list and not d_list: sys.exit("no movie, picture, directory is given!") if m_list: process.AnimatingMovie(target_list=m_list, is_colored=args.color, fps=args.fps).execute() if p_list: process.AnimatingPicture(target_list=p_list, is_colored=args.color, fps=args.fps).execute() if d_list: process.AnimatingPictureDirectory(target_list=d_list, is_colored=args.color, fps=args.fps).execute()
def call_subtitle(args: argparse.Namespace, parser: argparse.ArgumentParser): """call function when subtitle sub-command is given """ check_arg_subcommand("subtitle", args, parser) m_list, p_list, d_list = process.sort_target_type(args.target) if not m_list and not p_list and not d_list: sys.exit("no movie, picture, directory is given!") if m_list: process.SubtitlingMovie( target_list=m_list, is_colored=args.color, text=args.text, position=args.position, size=args.size, time=args.time, ).execute() if p_list: process.SubtitlingPicture( target_list=p_list, is_colored=args.color, text=args.text, position=args.position, size=args.size, ).execute() if d_list: process.SubtitlingPictureDirectory( target_list=d_list, is_colored=args.color, text=args.text, position=args.position, size=args.size, ).execute()