Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'Avg SA': averageSurface
});
} else {
size = line.found;
}*/
}
/*console.log('Total similarity',result.totalSimilarity);
console.log('Total found',result.totalFound);
console.log('Total not found',result.totalNotFound);*/
// for the first line we just show the roiOptions
/*for (var roi of result.lines[1].rois) {
console.log(JSON.stringify(roi));
}*/
// console.log(`Parsing ${text}`);
var data = parse(text);
if (!data.isValid) {
return saveImage(images, codes.MRZ_PARSE_ERROR, filename, {
lines: getTextAndSize(ocrResult),
errors: data.error,
'Avg SA': averageSurface
});
}
return saveImage(images, codes.CORRECT, filename, {
'Avg SA': averageSurface
});
}
} else {
size = line.found;
}*/
}
/*console.log('Total similarity',result.totalSimilarity);
console.log('Total found',result.totalFound);
console.log('Total not found',result.totalNotFound);*/
// for the first line we just show the roiOptions
/*for (var roi of result.lines[1].rois) {
console.log(JSON.stringify(roi));
}*/
// console.log(`Parsing ${text}`);
var data, error;
try {
data = parse(text);
} catch (e) {
error = e;
}
if (error || !data.valid) {
return saveImage(images, codes.MRZ_PARSE_ERROR, filename, {
lines: getTextAndSize(ocrResult),
errors: error.message || data.error,
'Avg SA': averageSurface
});
}
return saveImage(images, codes.CORRECT, filename, {
'Avg SA': averageSurface
});
}
async function processFile(imagePath) {
try {
stats.total += 1;
const parsedPath = parsePath(imagePath);
const result = await readMrz(await IJS.load(imagePath), {
debug: true,
saveName: join(parsedPath.dir, '../multiMask/', parsedPath.base)
});
console.log(result);
const parsed = parse(result);
stats.couldParse += 1;
console.log('valid', parsed.valid);
if (!parsed.valid) {
console.log(parsed.details.filter((d) => !d.valid).map((d) => d.error));
} else {
stats.valid += 1;
}
console.log(imagePath);
const nameWithoutExt = parsedPath.base.replace(parsedPath.ext, '');
console.log(nameWithoutExt);
if (expected[nameWithoutExt]) {
const reference = expected[nameWithoutExt];
if (result.length !== reference.length) {
console.log(
`error: expected ${reference.length} lines, got ${result.length}`
);