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, ColorMode color) async {
List<dynamic> jsOffsets = points.map((Offset offset) {
return {'x': offset.dx, 'y': offset.dy};
}).toList();
NormalizedImage? image;
if (_cvr != null) {
try {
dynamic rawSettings = await handleThenable(
_cvr!.getSimplifiedSettings("NormalizeDocument_Default"));
dynamic params = dartify(rawSettings);
params['roi']['points'] = jsOffsets;
params['roiMeasuredInPercentage'] = 0;
params['documentSettings']['colourMode'] = color.index;
await handleThenable(
_cvr!.updateSettings("NormalizeDocument_Default", jsify(params)));
} catch (e) {
return image;
}
NormalizedResult normalizedResult =
await handleThenable(_cvr!.capture(file, "NormalizeDocument_Default"))
as NormalizedResult;
image = _createNormalizedImage(normalizedResult);
}
return image;
}