setPolyToPoly method

bool setPolyToPoly(
  1. List<Point> src,
  2. List<Point> dst, {
  3. int? count,
})

Sets Matrix to map src to dst. count must be zero or greater, and four or less.

If count is zero, sets Matrix to identity and returns true.

If count is one, sets Matrix to translate and returns true.

If count is two or more, sets Matrix to map Point if possible; returns false

if Matrix cannot be constructed. If count is four, Matrix may include perspective.

@param src Point to map from @param dst Point to map to @param count number of Point in src and dst @return true if Matrix was constructed successfully

Implementation

bool setPolyToPoly(List<Point> src, List<Point> dst, {int? count}) {
  if (src.length != dst.length) {
    throw ArgumentError('src.length=${src.length} != dst.length=${dst.length}');
  }
  count ??= src.length;
  final srcPtr = calloc<c.mnn_cv_point_t>(count);
  final dstPtr = calloc<c.mnn_cv_point_t>(count);
  for (var i = 0; i < count; i++) {
    srcPtr[i] = src[i].ref;
    dstPtr[i] = dst[i].ref;
  }
  final result = c.mnn_cv_matrix_set_poly_to_poly(ptr, srcPtr, dstPtr, count);
  calloc.free(srcPtr);
  calloc.free(dstPtr);
  return result;
}