normalizeFile method
Normalize documents.
file
- path to the file.
points
- points of the document.
Returns a NormalizedImage.
Implementation
Future<NormalizedImage?> normalizeFile(String file, 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;
}