perspectiveTransform
import { perspectiveTransform } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Performs the perspective matrix transformation of vectors.
The function cv::perspectiveTransform transforms every element of src by treating it as a 2D or 3D vector, in the following way:
(x, y, z) \rightarrow (x'/w, y'/w, z'/w)
where
(x', y', z', w') = \texttt{mat} \cdot \begin{bmatrix} x & y & z & 1 \end{bmatrix}
and
w = \fork{w'}{if \(w' \ne 0\)}{\infty}{otherwise}
Here a 3D vector transformation is shown. In case of a 2D vector transformation, the z component is omitted.
Note: The function transforms a sparse set of 2D or 3D vectors. If you want to transform an image using perspective transformation, use warpPerspective . If you have an inverse problem, that is, you want to compute the most probable perspective transformation out of several pairs of corresponding points, you can use getPerspectiveTransform or findHomography .
See: transform, warpPerspective, getPerspectiveTransform, findHomography
perspectiveTransform(src: Mat, dst: Mat, m: Mat): void;srcinput two-channel or three-channel floating-point array; each element is a 2D/3D vector to be transformed.
dstOutput destination, filled by the native operation. output array of the same size and type as src.
m3x3 or 4x4 floating-point transformation matrix.
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.