Skip to content

imdecode

Image codecsfunctionOpenCV 5.0.0
import { imdecode } from '@banou/opencv-wasm'

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

ARGUMENTSbuf, flags
FUNCTIONimdecode
RETURN TYPEMat
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Reads an image from a buffer in memory.

The function imdecode reads an image from the specified buffer in the memory. If the buffer is too short or contains invalid data, the function returns an empty matrix ( Mat::data==NULL ).

See cv::imread for the list of supported formats and flags description.

Note: In the case of color images, the decoded images will have the channels stored in B G R order.

imdecode(buf: Mat, flags: number): Mat;
buf

Input array or vector of bytes.

flags

Flag that can take values of cv::ImreadModes.

Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

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.