veditor.elements.image module

class veditor.elements.image.ImageElement(x: Union[str, numpy.ndarray[Any, numpy.dtype[numpy.uint8]]], pos_frames: Tuple[int, Optional[int]] = (0, None), margin: Union[numbers.Number, List[numbers.Number]] = 0, width: Optional[int] = None, height: Optional[int] = None, top: Optional[Union[veditor.elements.base.BaseElement, int]] = None, right: Optional[Union[veditor.elements.base.BaseElement, int]] = None, left: Optional[Union[veditor.elements.base.BaseElement, int]] = None, bottom: Optional[Union[veditor.elements.base.BaseElement, int]] = None)[source]

Bases: veditor.elements.base.FixedElement

calc_element_size(x: Union[str, numpy.ndarray[Any, numpy.dtype[numpy.uint8]]], width: Optional[int] = None, height: Optional[int] = None, **kwargs)Tuple[int, int][source]

Basic method for calculating the element size.

Parameters
  • width (Optional[int], optional) – Element width. Defaults to None.

  • height (Optional[int], optional) – Element height. Defaults to None.

Returns

Tu

Return type

Tuple[int, int]

set_image_attributes(x: Union[str, numpy.ndarray[Any, numpy.dtype[numpy.uint8]]])None[source]

Set attributes for an image.

Parameters
  • x (Union[str, npt.NDArray[np.uint8]]) – An image like array or the path to the image file.

  • margin (Optional[Union[Number, List[Number]]], optional) – Margin. Defaults to None.

  • margin_default (Number, optional) – Default value for margin. Defaults to 0.

Raises

FileNotFoundError – When file is not found.

Examples

>>> from veditor.utils import SampleData
>>> from veditor.elements import ImageElement
>>> element = ImageElement(x=SampleData().IMAGE_PATH)
>>> hasattr(element, "arr") and hasattr(element, "pil")
True
edit(frame: numpy.ndarray[Any, numpy.dtype[numpy.uint8]], pos: int)numpy.ndarray[Any, numpy.dtype[numpy.uint8]][source]

Edit a pos-th frame in the video vide_path.

Parameters
  • frame (npt.NDArray[np.uint8]) – The current frame (BGR image) in the video.

  • pos (int) – The current position in the video.

Returns

An editied frame.

Return type

npt.NDArray[np.uint8]

show_image_arr(ax: Optional[matplotlib.axes._axes.Axes] = None)matplotlib.axes._axes.Axes[source]

Show image_arr using cv2plot

Parameters

ax (Optional[Axes], optional) – An Axes instance. Defaults to None.

Returns

An Axes instance with frame drawn.

Return type

Axes