Canvas

class ocvproto.misc.canvas.Canvas(width: int = 640, height: int = 480, *, channels: int = 3, color: Union[int, str, Tuple[int, int, int]] = None)

Represents a canvas.

Parameters:
  • width
  • height
  • channels
  • color
absdiff(frame: Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7f886e166da0>, Frame]) → ocvproto.frame.Frame

Returns absolute difference between the current and a given frame as a new Source.

Parameters:frame
blur(ksize: Tuple[int, int]) → ocvproto.frame.Frame

Blures the current frame inplace.

Parameters:ksize – Kernel size tuple (width, height)
canny(thr_1: int, thr_2: int) → ocvproto.frame.Frame

Applies Canny Edge Detection algorithm to the current frame inplace.

Parameters:
  • thr_1
  • thr_2
dilate(element: Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7f886e166da0>, Frame], iterations: int = None) → ocvproto.frame.Frame

Dilates the current frame inplace.

Parameters:
  • element
  • iterations
draw_rectangle(*, pos: Tuple[int, int], width: int, height: int, color: Union[int, str, Tuple[int, int, int]] = None)

Draws a rectangle.

Parameters:
  • pos – Top left corner (x, y).
  • width
  • height
  • color
dump(fpath: Union[str, pathlib.Path] = None)

Dumps frame into a file.

Parameters:fpath – Filepath to store image into. If not set, name is generated automatically.
fill(color: Union[int, str, Tuple[int, int, int]])

Fills the canvas with the given color.

Parameters:color
height

Height

make_gray() → ocvproto.frame.Frame

Makes the current frame grayscale inplace.

make_rgb() → ocvproto.frame.Frame

Makes the current frame RGB inplace.

resize(width: int, height: int) → ocvproto.frame.Frame

Resizes the current frame inplace.

Parameters:
  • width
  • height
width

Width