blobFromImage function

Mat blobFromImage(
  1. InputArray image, {
  2. double scalefactor = 1.0,
  3. (int, int) size = (0, 0),
  4. Scalar? mean,
  5. bool swapRB = false,
  6. bool crop = false,
  7. int ddepth = MatType.CV_32F,
})

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.

For further details, please see: https://docs.opencv.org/4.x/d6/d0f/group__dnn.html#ga29f34df9376379a603acd8df581ac8d7

Implementation

Mat blobFromImage(
  InputArray image, {
  double scalefactor = 1.0,
  (int, int) size = (0, 0),
  Scalar? mean,
  bool swapRB = false,
  bool crop = false,
  int ddepth = MatType.CV_32F,
}) {
  mean ??= Scalar.zeros;
  final blob = Mat.empty();
  cvRun(
    () => cffi.Net_BlobFromImage(
      image.ref,
      blob.ref,
      scalefactor,
      size.cvd.ref,
      mean!.ref,
      swapRB,
      crop,
      ddepth,
    ),
  );
  return blob;
}