Documentation
Table of contents

Thanks for downloading Dynamsoft Label Recognizer Package!

Your download will start shortly. If your download does not begin, click here to retry.

JavaScript API Reference

The primary class of the library is LabelRecognizer . The following code snippets shows the basic usage.

  • Recognize a still image
let labelRecognizer = await Dynamsoft.DLR.LabelRecognizer.createInstance();
let results = await labelRecognizer.recognize(imagePath);
for (let result of results) {
    for (let lineResult of result.lineResults) {
        console.log(lineResult.text);
    }
}
  • Recognize continuous video frames
let cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance();
await cameraEnhancer.setUIElement(document.getElementById('div-ui-container'));
let recognizer = await Dynamsoft.DLR.LabelRecognizer.createInstance();
recognizer.setImageSource(cameraEnhancer);
await recognizer.updateRuntimeSettingsFromString("video-MRZ");
recognizer.onImageRead = results => {
    for (let result of results) {
        for (let lineResult of result.lineResults) {
            console.log(lineResult.text);
        }
    }
};
recognizer.startScanning(true);

The APIs for this class include

Initialization Control

The following static methods and properties help to set up the runtime environment for the library.

API Name Description
engineResourcePath Specifies the path from where the recognition engine and models, etc. can be loaded.
loadWasm() Loads the recognition engine and models.
isWasmLoaded() Returns whether the recognition engine and models have been loaded.
getVersion() Returns the version of the library.
detectEnvironment() Assess the running environment regarding the features the library requires to run.

Create and Destroy Instances

API Name Description
createInstance() Creates a LabelRecognizer instance.
destroyContext() Destroies the LabelRecognizer instance.
isContextDestroyed() Returns whether the instance has been destroyed.

License Control

API Name Description
license Use an alphanumeric string to specify the license.

Recognition

Recognize Labels from Still Images

API Name Description
recognize() Decodes labels from an image.
recognizeBase64String() Decodes labels from a base64-encoded image (with or without MIME).
recognizeUrl() Decodes labels from an image specified by its URL.
recognizeBuffer() Decodes labels from raw image data.

Recognize Labels from Video Frames

API Name Description
setImageSource Sets an image source for continous scanning.
onUniqueRead This event is triggered when a new, unduplicated label is found when scanning via video.
onImageRead This event is triggered after the library finishes scanning an image.
onMRZRead This event is triggered after the library finishes scanning a frame with the built-in templates passportMRZ , video-passportMRZ , visaMRZ , video-visaMRZ , MRZ or video-MRZ .
onVINRead This event is triggered after the library finishes scanning an image based on one of the built-in templates VIN, video-VIN, VIN_NA or video-VIN_NA.
startScanning() Starts continuous scanning of incoming images.
stopScanning() Stops continuous scanning.
pauseScanning() Pause continuous scanning but keep the video stream.
resumeScanning() Resumes continuous scanning.

Settings

Scan Settings

API Name Description
getScanSettings() Returns the current scan settings.
updateScanSettings() Changes scan settings with the object passed in.

Runtime Settings

API Name Description
updateRuntimeSettingsFromString() Updates runtime settings with a template represented by a JSON string.
outputRuntimeSettingsToString() Output the current runtime settings to a JSON string.
updateReferenceRegionFromBarcodeResults() Updates reference region which is defined with source type DLR_LST_BARCODE.

Auxiliary

API Name Description
ifSaveOriginalImageInACanvas Whether to save the original image into a < canvas> element.
getOriginalImageInACanvas() Returns an HTMLCanvasElement that holds the original image.
onResourcesLoadStarted This event is triggered when the resource file (.data) for a particular template starts to load.
onResourcesLoadProgress This event is triggered multiple times when the resource file (.data) for a particular template is being loaded.
onResourcesLoaded This event is triggered when the resource file (.data) for a particular template finishes loading.

Interfaces and Enumerations

In order to make the code more predictable and readable, the library defines a series of supporting interfaces and enumerations.

Interfaces

Enumerations

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

version 2.2.31

  • Latest version
  • Version 3.x
    • Version 3.0.30(latest)
  • Version 2.x
    • Version 2.2.31
    • Version 2.2.30
    • Version 2.2.11
    • Version 2.2.10
    • Version 2.2.4
    • Version 2.2.2
    • Version 2.2.1
    • Version 2.2.0
Change +
© 2003–2024 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support