dnn_blobFromImage
import { dnn_blobFromImage } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Creates 4-dimensional blob from image. Optionally resizes and crops image from center,
subtract mean values, scales values by scalefactor, swap Blue and Red channels.
if crop is true, input image is resized so one side after resize is equal to corresponding
dimension in size and another one is equal or larger. Then, crop from the center is performed.
If crop is false, direct resize without cropping and preserving aspect ratio is performed.
Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
dnn_blobFromImage(image: Mat, scalefactor: number, size: Size, mean: Scalar, swapRB: boolean, crop: boolean, ddepth: number): Mat;7 available overloads
dnn_blobFromImage(image: Mat): Mat;dnn_blobFromImage(image: Mat, scalefactor: number): Mat;dnn_blobFromImage(image: Mat, scalefactor: number, size: Size): Mat;dnn_blobFromImage(image: Mat, scalefactor: number, size: Size, mean: Scalar): Mat;dnn_blobFromImage(image: Mat, scalefactor: number, size: Size, mean: Scalar, swapRB: boolean): Mat;dnn_blobFromImage(image: Mat, scalefactor: number, size: Size, mean: Scalar, swapRB: boolean, crop: boolean): Mat;dnn_blobFromImage(image: Mat, scalefactor: number, size: Size, mean: Scalar, swapRB: boolean, crop: boolean, ddepth: number): Mat;imageinput image (with 1-, 3- or 4-channels).
scalefactormultiplier for
imagesvalues.sizespatial size for output image
meanscalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if
imagehas BGR ordering andswapRBis true.swapRBflag which indicates that swap first and last channels in 3-channel image is necessary.
cropflag which indicates whether image will be cropped after resize or not
ddepthDepth of output blob. Choose CV_32F or CV_8U.
4-dimensional Mat with NCHW dimensions order. 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.