Skip to content

setIdentity

Core and matricesfunctionOpenCV 5.0.0
import { setIdentity } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSmtx, s
FUNCTIONsetIdentity
RETURN TYPEvoid
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Initializes a scaled identity matrix.

The function cv::setIdentity initializes a scaled identity matrix:

\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}

The function can also be emulated using the matrix initializers and the matrix expressions:

    Mat A = Mat::eye(4, 3, CV_32F)*5;
    // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]

See: Mat::zeros, Mat::ones, Mat::setTo, Mat::operator=

setIdentity(mtx: Mat, s: Scalar): void;
2 available overloads
setIdentity(mtx: Mat): void;
setIdentity(mtx: Mat, s: Scalar): void;
mtx

Input/output value, modified by the native operation. matrix to initialize (not necessarily square).

s

value to assign to diagonal elements.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.