wed.chaptors.marquee module¶
This submodule contains a set of functions for editing the following image:
- class wed.chaptors.marquee.MarqueeEditor(upper_text: str = 'WEDNESDAY', lower_text: str = 'DOWNTOWN', ttfontname: str = '/Users/iwasakishuto/Github/portfolio/Wed-Downtown-OP/data/fonts/LeagueGothic-1.601/static/TTF/LeagueGothic-Regular.ttf', simple_cycler: wed.utils.generic_utils.Cycler = <wed.utils.generic_utils.Cycler object>, big_cycler: wed.utils.generic_utils.Cycler = <wed.utils.generic_utils.Cycler object>, slanted_cycler: wed.utils.generic_utils.Cycler = <wed.utils.generic_utils.Cycler object>, atol: int = 100)[source]¶
Bases:
wed.chaptors.base_editor.BaseWedOPEditor- SIMPLE_UPPER_LINE_TOP: int = 137¶
- SIMPLE_LOWER_LINE_TOP: int = 269¶
- BIG_UPPER_LINE_TOP: int = 100¶
- BIG_LOWER_LINE_TOP: int = 280¶
- SLANTED_UPPER_LINE_TOP: int = 187¶
- SLANTED_LOWER_LINE_TOP: int = 457¶
- edit(frame: numpy.ndarray[Any, numpy.dtype[numpy.uint8]], pos: int, span: int = 20) → numpy.ndarray[Any, numpy.dtype[numpy.uint8]][source]¶
Edit the image if it is an assigned chapter (
pos)- Parameters
frame (npt.NDArray[np.uint8]) – Current frame (BGR image) in the video.
pos (int) – Current position in the video.
- Returns
Edited frame.
- Return type
npt.NDArray[np.uint8]
- draw_text(frame: numpy.ndarray[Any, numpy.dtype[numpy.uint8]], text: str, pos: int, xy: Tuple[int, int], cycler: wed.utils.generic_utils.Cycler, textRGB: Union[str, Tuple] = 'white', span: int = 20, stroke_width: int = 5, stroke_fill: Optional[Union[str, Tuple]] = 'black', method: str = 'l2r', **kwargs) → numpy.ndarray[Any, numpy.dtype[numpy.uint8]][source]¶
Draw
textinframeusingwed.utils.image_utils.draw_text_in_pil().- Args:
frame (npt.NDArray[np.uint8]) : Input frame (BGR ndarray image). text (str) : Text to be drawn to
frame. pos (int) : The position of the frame to get. xy (Tuple, optional) : Where to write thetext. This value means the coordinates of (x,y). Defaults to(0, 0). cycler (Cycler) : Cycler that adjusts the size of each character intext. textRGB (Union[str, Tuple], optional) : The color of text. Defaults to"white". span (int, optional) : Span between characters. Defaults to20. stroke_width (int, optional) : The width of the text stroke. Defaults to5. stroke_fill (Optional[Union[str, Tuple]], optional) : Color to use for the text stroke. If not given, will default to thetextRGBparameter. Defaults toblack. method (str, optional) : How to drawtext. Please choose from["l2r", "bl2tr"]. Defaults to"l2r".- Returns:
npt.NDArray[np.uint8]:
framewithtextdrawn.
>>> from wed.chaptors import MarqueeEditor >>> from wed.utils import cv2plot >>> pos = 80 >>> editor = MarqueeEditor() >>> frame = editor.get_frame(pos) >>> fig, ax = plt.subplots() >>> ys, cycler, fontwidth = editor._get_args("simple") >>> for text,y in zip([editor.upper_texts, editor.lower_texts],ys): ... frame = editor.draw_text(frame=frame, text=text, pos=pos, xy=(40, y), cycler=cycler, span=fontwidth) >>> ax = cv2plot(frame, ax=ax) >>> fig.show()
- draw_text_l2r(frame: numpy.ndarray[Any, numpy.dtype[numpy.uint8]], text: str, pos: int, xy: Tuple[int, int], cycler: wed.utils.generic_utils.Cycler, textRGB: Union[str, Tuple] = 'white', span: int = 20, stroke_width: int = 5, stroke_fill: Optional[Union[str, Tuple]] = 'black', **kwargs) → numpy.ndarray[Any, numpy.dtype[numpy.uint8]][source]¶
- draw_text_bl2tr(frame: numpy.ndarray[Any, numpy.dtype[numpy.uint8]], text: str, pos: int, xy: Tuple[int, int], cycler: wed.utils.generic_utils.Cycler, textRGB: Union[str, Tuple] = 'white', span: int = 20, stroke_width: int = 5, stroke_fill: Optional[Union[str, Tuple]] = 'black', angle: int = - 33, **kwargs) → numpy.ndarray[Any, numpy.dtype[numpy.uint8]][source]¶