normalizeBuffer method

Future<NormalizedImage?> normalizeBuffer(
  1. Uint8List bytes,
  2. int width,
  3. int height,
  4. int stride,
  5. int format,
  6. dynamic points,
)

Normalize documents. file - path to the file. points - points of the document. Returns a NormalizedImage.

Implementation

Future<NormalizedImage?> normalizeBuffer(Uint8List bytes, int width,
    int height, int stride, int format, dynamic points) async {
  List<dynamic> jsOffsets = points.map((Offset offset) {
    return {'x': offset.dx, 'y': offset.dy};
  }).toList();

  dynamic jsonObj = jsonEncode({
    "quad": {"points": jsOffsets}
  });

  NormalizedImage? image;
  // if (_normalizer != null) {
  //   _normalizedDocument =
  //       await handleThenable(_normalizer!.normalize(file, parse(jsonObj)));

  //   if (_normalizedDocument != null) {
  //     Image result = _normalizedDocument!.image;
  //     dynamic data = result.data;
  //     Uint8List bytes = Uint8List.fromList(data);
  //     image = NormalizedImage(bytes, result.width, result.height);
  //     return image;
  //   }
  // }

  return image;
}