How to use mrz - 3 common examples

To help you get started, we’ve selected a few mrz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github image-js / mrz-detection / run / getStatistics_old.js View on Github external
'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
  });
}
github image-js / mrz-detection / run / MRZDetection.js View on Github external
} 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
    });
  }
github image-js / mrz-detection / run / readMrz.js View on Github external
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}`
          );

mrz

Parse MRZ (Machine Readable Zone) from identity documents

MIT
Latest version published 1 month ago

Package Health Score

76 / 100
Full package analysis

Popular mrz functions