View Source Evision.Mat (Evision v0.1.9)

OpenCV Mat

Link to this section Summary

cv.Mat

This method does not change the underlying data. It only changes the steps when accessing the matrix.

The method returns the number of matrix channels.

Returns the depth of a matrix element.

Returns the size of each matrix element channel in bytes.

Returns the matrix element size in bytes.

Create Mat from binary (pixel) data

This function would convert the input tensor with dims [height, width, dims] to a dims-channel image with dims [height, width].

Create an Evision.Mat from list literals.

Returns the type of a matrix.

Returns the cv::MatSize of the matrix.

Returns the total number of array elements.

Returns the total number of array elements.

This method returns the type-tuple used by Nx. To get the raw value of cv::Mat.type(), please use Evision.Mat.raw_type/1.

Functions

Raising version of abs/1.

Raising version of add/2.

Raising version of add/3.

Raising version of as_shape/2.

Raising version of as_type/2.

Raising version of at/2.

Raising version of bitwise_not/1.

Raising version of bitwise_or/2.

Raising version of ceil/1.

This function does the opposite as to Evision.Mat.last_dim_as_channel/1.

Raising version of channels/1.

Raising version of clip/3.

Raising version of clone/1.

Raising version of cmp/3.

Raising version of depth/1.

Raising version of divide/2.

Raising version of divide/3.

Raising version of dot/2.

Raising version of elemSize1/1.

Raising version of elemSize/1.

Raising version of empty/0.

Raising version of expm1/1.

Raising version of eye/2.

Raising version of floor/1.

Raising version of full/3.

Raising version of isContinuous/1.

Raising version of isSubmatrix/1.

Raising version of literal/1.

Raising version of literal/2.

Raising version of logical_or/2.

Raising version of multiply/2.

Raising version of negate/1.

Raising version of number/2.

Raising version of ones/2.

Raising version of raw_type/1.

Raising version of reshape/2.

Raising version of round/1.

Raising version of setTo/3.

Raising version of shape/1.

Raising version of sign/1.

Raising version of size/1.

Raising version of squeeze/1.

Raising version of subtract/2.

Raising version of to_binary/1.

Raising version of to_binary/2.

Raising version of total/1.

Raising version of total/2.

Raising version of transpose/1.

Raising version of transpose/2.

Transpose a matrix

Raising version of type/1.

Raising version of zeros/2.

Link to this section Types

Link to this type

channels_from_binary()

View Source
@type channels_from_binary() :: 1 | 2 | 3 | 4
@type mat_type() ::
  {:u, 8}
  | {:u, 16}
  | {:s, 8}
  | {:s, 16}
  | {:s, 32}
  | {:f, 32}
  | {:f, 64}
  | {:f, 16}
  | :u8
  | :u16
  | :s8
  | :s16
  | :s32
  | :f32
  | :f64
  | :f16

Types for mat

@type t() :: %{__struct__: atom()}

Link to this section cv.Mat

This method does not change the underlying data. It only changes the steps when accessing the matrix.

If intended to change the underlying data to the new shape, please use Evision.Mat.reshape/2.

The method returns the number of matrix channels.

Returns the depth of a matrix element.

The method returns the identifier of the matrix element depth (the type of each individual channel). For example, for a 16-bit signed element array, the method returns CV_16S. A complete list of matrix types contains the following values:

  • CV_8U - 8-bit unsigned integers ( 0..255 )
  • CV_8S - 8-bit signed integers ( -128..127 )
  • CV_16U - 16-bit unsigned integers ( 0..65535 )
  • CV_16S - 16-bit signed integers ( -32768..32767 )
  • CV_32S - 32-bit signed integers ( -2147483648..2147483647 )
  • CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN )
  • CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN )

Returns the size of each matrix element channel in bytes.

The method returns the matrix element channel size in bytes, that is, it ignores the number of channels. For example, if the matrix type is CV_16SC3 , the method returns sizeof(short) or 2.

Returns the matrix element size in bytes.

The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3, the method returns 3*sizeof(short) or 6.

@spec floor(reference()) :: {:ok, reference()} | {:error, String.t()}
Link to this function

from_binary(binary, type, rows, cols, channels)

View Source
@spec from_binary(
  binary(),
  mat_type(),
  pos_integer(),
  pos_integer(),
  channels_from_binary()
) ::
  {:ok, reference()} | {:error, String.t()}

Create Mat from binary (pixel) data

  • binary. The binary pixel data
  • type. type={t, l} is one of [{:u, 8}, {:s, 8}, {:u, 16}, {:s, 16}, {:s, 32}, {:f, 32}, {:f, 64}]
  • rows. Number of rows (i.e., the height of the image)
  • cols. Number of cols (i.e., the width of the image)
  • channels. Number of channels, only valid if in [1, 3, 4]
Link to this function

from_binary_by_shape(binary, type, shape)

View Source
Link to this function

last_dim_as_channel(mat)

View Source

This function would convert the input tensor with dims [height, width, dims] to a dims-channel image with dims [height, width].

Note that OpenCV has limitation on the number of channels. Currently the maximum number of channels is 512.

Create an Evision.Mat from list literals.

example

Example

Creating Evision.Mat from empty list literal ([]) is the same as calling Evision.Mat.empty().

iex> Evision.Mat.literal!([])
%Evision.Mat{
  channels: 1,
  dims: 0,
  type: {:u, 8},
  raw_type: 0,
  shape: {},
  ref: #Reference<0.1204050731.2031747092.46781>
}

By default, the shape of the Mat will stay as is.

iex> Evision.Mat.literal!([[[1,1,1],[2,2,2],[3,3,3]]], :u8)
%Evision.Mat{
  channels: 1,
  dims: 3,
  type: {:u, 8},
  raw_type: 0,
  shape: {1, 3, 3},
  ref: #Reference<0.512519210.691404819.106300>
}

Evision.Mat.literal/3 will return a vaild 2D image if the keyword argument, as_2d, is set to true and if the list literal can be represented as a 2D image.

iex> Evision.Mat.literal!([[[1,1,1],[2,2,2],[3,3,3]]], :u8, as_2d: true)
%Evision.Mat{
  channels: 3,
  dims: 2,
  type: {:u, 8},
  raw_type: 16,
  shape: {1, 3, 3},
  ref: #Reference<0.512519210.691404820.106293>
}
Link to this function

matrix_multiply(lhs, rhs, out_type \\ nil)

View Source
Link to this function

multiply(lhs, rhs, type)

View Source

Returns the type of a matrix.

As Evision.Mat.type/1 returns the type used by Nx, this method gives the raw value of cv::Mat.type()

Returns the cv::MatSize of the matrix.

The method returns a tuple {dims, p} where dims is the number of dimensions, and p is a list with dims elements.

Link to this function

subtract(lhs, rhs, type)

View Source
Link to this function

to_binary(mat, limit \\ 0)

View Source

Returns the total number of array elements.

The method returns the number of array elements (a number of pixels if the array represents an image).

Link to this function

total(mat, start_dim, end_dim \\ 4_294_967_295)

View Source

Returns the total number of array elements.

The method returns the number of elements within a certain sub-array slice with start_dim <= dim < end_dim

This method returns the type-tuple used by Nx. To get the raw value of cv::Mat.type(), please use Evision.Mat.raw_type/1.

Link to this section Functions

Raising version of abs/1.

Raising version of add/2.

Raising version of add/3.

Link to this function

arange!(from, to, step, type)

View Source

Raising version of arange/4.

Link to this function

arange!(from, to, step, type, shape)

View Source

Raising version of arange/5.

Link to this function

arange(from, to, step, type)

View Source
Link to this function

arange(from, to, step, type, shape)

View Source
Link to this function

as_shape!(mat, as_shape)

View Source

Raising version of as_shape/2.

Raising version of as_type/2.

Raising version of at/2.

Raising version of bitwise_and/2.

Raising version of bitwise_not/1.

Raising version of bitwise_or/2.

Raising version of bitwise_xor/2.

Link to this function

broadcast_to!(mat, to_shape)

View Source

Raising version of broadcast_to/2.

Link to this function

broadcast_to!(mat, to_shape, force_src_shape)

View Source

Raising version of broadcast_to/3.

Link to this function

broadcast_to(mat, to_shape)

View Source
Link to this function

broadcast_to(mat, to_shape, force_src_shape)

View Source

Raising version of ceil/1.

Link to this function

channel_as_last_dim!(mat)

View Source

Raising version of channel_as_last_dim/1.

Link to this function

channel_as_last_dim(mat)

View Source

This function does the opposite as to Evision.Mat.last_dim_as_channel/1.

If the number of channels of the input Evision.Mat is greater than 1, then this function would convert the input Evision.Mat with dims dims=list(int()) to a 1-channel Evision.Mat with dims [dims | channels].

If the number of channels of the input Evision.Mat is equal to 1,

  • if dims == shape, then nothing happens
  • otherwise, a new Evision.Mat that has dims=[dims | channels] will be returned

Raising version of channels/1.

Link to this function

clip!(mat, lower, upper)

View Source

Raising version of clip/3.

Raising version of clone/1.

Raising version of cmp/3.

Raising version of depth/1.

Raising version of divide/2.

Raising version of divide/3.

Raising version of dot/2.

Raising version of elemSize1/1.

Raising version of elemSize/1.

Raising version of empty/0.

Raising version of expm1/1.

Raising version of eye/2.

Raising version of floor/1.

Link to this function

from_binary!(binary, type, rows, cols, channels)

View Source

Raising version of from_binary/5.

Link to this function

from_binary_by_shape!(binary, type, shape)

View Source

Raising version of from_binary_by_shape/3.

Link to this function

full!(shape, number, type)

View Source

Raising version of full/3.

Link to this function

full(shape, number, type)

View Source

Raising version of isContinuous/1.

Raising version of isSubmatrix/1.

Link to this function

last_dim_as_channel!(mat)

View Source

Raising version of last_dim_as_channel/1.

Raising version of literal/1.

Raising version of literal/2.

Link to this function

literal!(literal, type, opts)

View Source

Raising version of literal/3.

Link to this function

literal(literal, type, opts \\ [])

View Source
@spec literal(list(), mat_type(), Keyword.t()) ::
  {:ok,
   %Evision.Mat{
     channels: term(),
     dims: term(),
     raw_type: term(),
     ref: term(),
     shape: term(),
     type: term()
   }}
  | {:error, String.t()}

Raising version of logical_and/2.

Raising version of logical_or/2.

Raising version of logical_xor/2.

Link to this function

matrix_multiply!(lhs, rhs)

View Source

Raising version of matrix_multiply/2.

Link to this function

matrix_multiply!(lhs, rhs, out_type)

View Source

Raising version of matrix_multiply/3.

Raising version of multiply/2.

Link to this function

multiply!(lhs, rhs, type)

View Source

Raising version of multiply/3.

Raising version of negate/1.

Raising version of number/2.

Raising version of ones/2.

Raising version of raw_type/1.

Raising version of reshape/2.

Raising version of round/1.

Link to this function

setTo!(mat, value, mask)

View Source

Raising version of setTo/3.

Raising version of shape/1.

Raising version of sign/1.

Raising version of size/1.

Raising version of squeeze/1.

Raising version of subtract/2.

Link to this function

subtract!(lhs, rhs, type)

View Source

Raising version of subtract/3.

Link to this function

to_batched!(mat, batch_size, opts)

View Source

Raising version of to_batched/3.

Link to this function

to_batched!(mat, batch_size, as_shape, opts)

View Source

Raising version of to_batched/4.

Link to this function

to_batched(mat, batch_size, opts)

View Source
Link to this function

to_batched(mat, batch_size, as_shape, opts)

View Source

Raising version of to_binary/1.

Raising version of to_binary/2.

Raising version of total/1.

Raising version of total/2.

Link to this function

total!(mat, start_dim, end_dim)

View Source

Raising version of total/3.

Raising version of transpose/1.

Raising version of transpose/2.

Link to this function

transpose!(mat, axes, opts)

View Source

Raising version of transpose/3.

Transpose a matrix

parameters

Parameters

  • mat. The matrix. by default it reverses the order of the axes.
Link to this function

transpose(mat, axes, opts \\ [])

View Source

Transpose a matrix

parameters

Parameters

  • mat. The matrix.

  • axes. list of ints. It must be a list which contains a permutation of [0,1,..,N-1] where N is the number of axes of mat. The i’th axis of the returned array will correspond to the axis numbered axes[i] of the input.

  • opts. Keyword options.

    • as_shape. A tuple or list which overwrites the shape of the matrix (the total number of elements must be equal to the one as in its original shape). For example, a 4x4 matrix can be treated as a 2x2x2x2 matrix and transposed with axes=[2,1,3,0] in a single call.

      When specified, it combines the reshape and transpose operation in a single NIF call.

Raising version of type/1.

Raising version of zeros/2.