Skip to content

solve

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

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

ARGUMENTSsrc1, src2, dst, flags
FUNCTIONsolve
RETURN TYPEboolean
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Solves one or more linear systems or least-squares problems.

The function cv::solve solves a linear system or least-squares problem (the latter is possible with SVD or QR methods, or by specifying the flag #DECOMP_NORMAL ):

\texttt{dst} =  \arg \min _X \| \texttt{src1} \cdot \texttt{X} -  \texttt{src2} \|

If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1 if src1 (or \texttt{src1}^T\texttt{src1} ) is non-singular. Otherwise, it returns 0. In the latter case, dst is not valid. Other methods find a pseudo-solution in case of a singular left-hand side part.

Note: If you want to find a unity-norm solution of an under-defined singular system \texttt{src1}\cdot\texttt{dst}=0 , the function solve will not do the work. Use SVD::solveZ instead.

See: invert, SVD, eigen

solve(src1: Mat, src2: Mat, dst: Mat, flags: number): boolean;
2 available overloads
solve(src1: Mat, src2: Mat, dst: Mat): boolean;
solve(src1: Mat, src2: Mat, dst: Mat, flags: number): boolean;
src1

input matrix on the left-hand side of the system.

src2

input matrix on the right-hand side of the system.

dst

Output destination, filled by the native operation. output solution.

flags

solution (matrix inversion) method (#DecompTypes)

Returns

The boolean result.

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.