View Source Evision.HighGui (Evision v1.1.1)

High-level Graphical User Interface

Summary

Functions

Converts an image to 8-bit RGB, scaling it the way imshow/2 displays it

Close all windows

Close a named window

Show a mat in a named window

Wait for user keyboard event for a delay amount of time (ms)

Functions

@spec convertToShow(Evision.Mat.t() | Nx.Tensor.t()) :: Evision.Mat.maybe_mat_out()

Converts an image to 8-bit RGB, scaling it the way imshow/2 displays it

This mirrors convertToShow in OpenCV's highgui. Results are rounded and saturated to 0..255:

  • {:s, 8}: abs(x + 127)
  • {:s, 16}: abs(x / 255 + 127)
  • {:u, 16}: x / 255
  • {:f, 32} and {:f, 64}: x * 255, for values in [0, 1]

Unlike OpenCV, {:f, 16} and {:bf, 16} are accepted and widened to {:f, 32} first.

The image is first passed through Evision.Mat.to_2d_image/1, then Evision.Mat.to_rgb/1.

@spec destroyAllWindows() :: :ok

Close all windows

@spec destroyWindow(String.t()) :: :ok | {:error, String.t()}

Close a named window

Positional Arguments

  • winname. String

    The name of the window.

@spec imshow(String.t(), Evision.Mat.maybe_mat_in() | Nx.Tensor.t()) ::
  :ok | {:error, String.t()}

Show a mat in a named window

Positional Arguments

Example

iex> mat = Evision.imread!("example.jpg")
iex> Evision.imshow("OpenCV", mat)
# the following line may be necessary on your system
# will try to improve this later
iex> Evision.waitkey(0)
@spec waitKey(integer()) :: :ok | {:error, String.t()}

Wait for user keyboard event for a delay amount of time (ms)

Positional Arguments

  • delay. int

    Wait for delay ms.