Skip to content

GMat

gapiclassOpenCV 5.0.0
import { GMat } from '@banou/opencv-wasm'

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

ARGUMENTSConstructor or factory
CLASSGMat
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods.

\addtogroup gapi_data_objects

G-API data objects used to build G-API expressions.

These objects do not own any particular data (except compile-time associated values like with cv::GScalar or cv::GArray<T>) and are used only to construct graphs.

Every graph in G-API starts and ends with data objects.

Once constructed and compiled, G-API operates with regular host-side data instead. Refer to the below table to find the mapping between G-API and regular data types when passing input and output data structures to G-API:

G-API data type I/O data type
cv::GMat cv::Mat, cv::UMat, cv::RMat
cv::GScalar cv::Scalar
cv::GArray<T> std::vector<T>
cv::GOpaque<T> T
cv::GFrame cv::MediaFrame
GMat class represents image or tensor data in the
graph.

GMat doesn't store any data itself, instead it describes a functional relationship between operations consuming and producing GMat objects.

GMat is a virtual counterpart of Mat and UMat, but it doesn't mean G-API use Mat or UMat objects internally to represent GMat objects -- the internal data representation may be backend-specific or optimized out at all.

See: Mat, GMatDesc

Constructors and members

static new

Empty constructor Constructs a value-initialized GMat

GMat may be associated with a buffer at graph construction time. It is useful when some operation has a Mat input which doesn't change during the program execution, and is set only once. In this case, there's no need to declare such GMat as graph input.

new(m: Mat): GMat;
2 available overloads
new(): GMat;
new(m: Mat): GMat;
m

a cv::Mat buffer to associate with this GMat object.

Returns

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

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this 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.