Skip to content

gapi_warpPerspective

gapifunctionOpenCV 5.0.0
import { gapi_warpPerspective } from '@banou/opencv-wasm'

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

ARGUMENTSsrc, M, dsize, flags
FUNCTIONgapi_warpPerspective
RETURN TYPEGMat
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Applies a perspective transformation to an image.

The function warpPerspective transforms the source image using the specified matrix:

\texttt{dst} (x,y) =  \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} ,
     \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )

when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert and then put in the formula above instead of M. The function cannot operate in-place.

See: warpAffine, resize, remap, getRectSubPix, perspectiveTransform

gapi_warpPerspective(src: GMat, M: Mat, dsize: Size, flags: number, borderMode: number, borderValue: Scalar): GMat;
4 available overloads
gapi_warpPerspective(src: GMat, M: Mat, dsize: Size): GMat;
gapi_warpPerspective(src: GMat, M: Mat, dsize: Size, flags: number): GMat;
gapi_warpPerspective(src: GMat, M: Mat, dsize: Size, flags: number, borderMode: number): GMat;
gapi_warpPerspective(src: GMat, M: Mat, dsize: Size, flags: number, borderMode: number, borderValue: Scalar): GMat;
src

input image.

M

3\times 3 transformation matrix.

dsize

size of the output image.

flags

combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( \texttt{dst}\rightarrow\texttt{src} ).

borderMode

pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE).

borderValue

value used in case of a constant border; by default, it equals 0.

Returns

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