Skip to content

yushulx/mrz4nodejs

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
lib
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Node.js MRZ Scanner SDK

The Node.js MRZ (Machine Readable Zone) Scanner SDK is Node binding to Dynamsoft MRZ C++ SDK. It helps developers to build Node.js applications for scanning passport, Visa, ID card and travel documents on Windows and Linux.

License Key

Get a 30-day FREE trial license to activate the SDK.

Pre-requisites

  • Node.js

  • Platform-specific C/C++ compiler

  • TypeScript

    npm install -g typescript
    npm install --save @types/node
  • node-gyp

    npm i node-gyp -g
    

Supported Platforms

  • Windows
  • Linux

Usage

Basic steps:

  1. Set the license key.

    MrzScanner.initLicense('DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==');
  2. Create an MRZ scanner object.

    var obj = new MrzScanner();
  3. Load the MRZ model via the mrz4nodejs module path.

    var ret = obj.loadModel(path.dirname(require.resolve('mrz4nodejs')));
  4. Call decodeFileAsync() method to recognize MRZ from an image file.

    (async function () {
        try {
            var result = await obj.decodeFileAsync('<image-file-path>');
            console.log(result);
        } catch (error) {
            console.log(error);
        }
    })();
  5. Parse the MRZ information:

    if (result.length == 2) {
        console.log(obj.parseTwoLines(result[0].text, result[1].text));
    }
    else if (result.length == 3) {
        console.log(obj.parseThreeLines(result[0].text, result[1].text, result[2].text));
    }

Sample Code

https://github.com/yushulx/mrz4nodejs/tree/main/examples

Node.js MRZ scanner SDK