mapPoints method

List<Point> mapPoints(
  1. List<Point> src, {
  2. bool inplace = false,
})

Maps src Point array of length count to dst Point array of equal or greater length. Point are mapped by multiplying each Point by Matrix. Given:

         | A B C |        | x |
Matrix = | D E F |,  pt = | y |
         | G H I |        | 1 |

where

for (i = 0; i < count; ++i) {
    x = src[i].fX
    y = src[i].fY
}

each dst Point is computed as:

              |A B C| |x|                               Ax+By+C   Dx+Ey+F
Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , -------
              |G H I| |1|                               Gx+Hy+I   Gx+Hy+I

src and dst may point to the same storage.

@param dst storage for mapped Point @param src Point to transform @param count number of Point to transform

Implementation

List<Point> mapPoints(List<Point> src, {bool inplace = false}) {
  final count = src.length;
  final srcPtr = calloc<c.mnn_cv_point_t>(count);
  for (var i = 0; i < count; i++) {
    srcPtr[i] = src[i].ref;
  }
  if (inplace) {
    c.mnn_cv_matrix_map_points_inplace(ptr, srcPtr, count);
    for (var i = 0; i < count; i++) {
      src[i] = Point.fromNative(srcPtr[i]);
    }
    calloc.free(srcPtr);
    return src;
  }

  final dstPtr = calloc<c.mnn_cv_point_t>(count);
  c.mnn_cv_matrix_map_points(ptr, srcPtr, dstPtr, count);
  final result = List<Point>.generate(count, (index) => Point.fromNative(dstPtr[index]));
  calloc.free(srcPtr);
  calloc.free(dstPtr);
  return result;
}