How to use the image-js.Image.load function in image-js

To help you get started, we’ve selected a few image-js 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 / writeCharacters.js View on Github external
async function processFile(imagePath) {
    let shouldAdd = getCharacterCounter(argv.maxCount);
    try {
      const parsedPath = parsePath(imagePath);
      const image = await IJS.load(imagePath);
      const result = getLinesFromImage(image, {
        roiOptions,
        fingerprintOptions: {}
      });

      const name = parsedPath.base.replace(parsedPath.ext, '');
      const asExpected = matchesExpected(name, result.lines);
      if (asExpected) {
        console.log('looks good, write chars');
        for (let i = 0; i < result.lines.length; i++) {
          const line = result.lines[i];
          // eslint-disable-next-line no-await-in-loop
          for (let j = 0; j < line.rois.length; j++) {
            const char = asExpected ? expected[name][i][j] : '';
            if (asExpected && !shouldAdd(char)) continue;
            const roi = line.rois[j];
github image-js / mrz-detection / src / classifier / detection.js View on Github external
randomColors: true
  };

  const swtOptions = {
    scaleInvariant: false,
    breakdown: false,
    size: 5,
    aspectRatio: 5,
    lowThresh: 100,
    highThresh: 300,
    heightRatio: 2,
    distanceRatio: 4,
    thicknessRatio: 2.0,
  };

  var testImage = (await Image.load(filename));/*.gaussianFilter({
    radius: 2
  });*/
  // getAllMethods(testImage);
  console.log(`filename: ${filename}`);
  console.time("SWT time");
  var rois = strokeWidthTransform(testImage, swtOptions);
  console.timeEnd("SWT time")

  drawRois(testImage, rois);
  var masks = new Array(rois.length);
  for (var i = 0; i < rois.length; ++i) {
    masks[i] = testImage.extract(rois[i].getMask()).grey();
  }

  var predictions = new Array(masks.length);
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]) {
github image-js / mrz-detection / run / getMrz.js View on Github external
} else if (argv.dir) {
    const dirname = path.resolve(argv.dir);
    const files = (await fs.readdir(dirname)).filter((f) => {
      f = f.toLowerCase();
      return f.endsWith('jpg') || f.endsWith('png') || f.endsWith('jpeg');
    });
    const out = path.join(dirname, 'out');
    const toSave = [];
    await fs.emptyDir(out);
    for (let file of files) {
      console.log(`process ${file}`);
      const imagePath = path.join(dirname, file);
      console.time(imagePath);
      const result = {};
      try {
        getMrz(await Image.load(imagePath), {
          debug: true,
          out: result
        });
      } catch (e) {
        console.error(e);
      }
      console.timeEnd(imagePath);
      await saveImages(imagePath, result, out);
      toSave.push([imagePath, result]);
    }
    await saveReports(toSave, out);
  }
}
github image-js / mrz-detection / run / getMRZdata_old.js View on Github external
var promises = files.map((elem) => IJS.load(readPath + elem));
var table = [];

image-js

Image processing and manipulation in JavaScript

MIT
Latest version published 4 months ago

Package Health Score

76 / 100
Full package analysis