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(imageSource);
for (let result of results) {
for (let lineResult of result.lineResults) {
console.log(lineResult.text);
}
}
- Recognize continuous video frames
let labelRecognizer = await Dynamsoft.DLR.LabelRecognizer.createInstance({
runtimeSettings: "video-passportMRZ"
});
labelRecognizer.onFrameRead = results => {
for (let result of results) {
for (let lineResult of result.lineResults) {
console.log(lineResult.text);
}
}
};
labelRecognizer.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. |
UI Control
API Name | Description |
---|---|
getUIElement() | Returns the HTML element that is used by the LabelRecognizer instance. |
setUIElement() | Specifies an HTML element for the LabelRecognizer instance to use as its UI. |
defaultUIElementURL | Returns or sets the URL of the .html file that defines the default UI Element. |
highlightFillStyle | Specifies the color used inside the shape which highlights a found line of text. |
highlightStrokeStyle | Specifies the color used to paint the outline of the shape which highlights a found line of text. |
highlightLineWidth | Specifies the line width of the outline of the shape which highlights a found line of text. |
regionMaskFillStyle | Specifies the color used in the square-loop shape between the actual scanning area and the boundary of the video input. |
regionMaskStrokeStyle | Specifies the color used to paint the outline of the scanning region. |
regionMaskLineWidth | Specifies the width of the outline of the scanning region. |
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 |
---|---|
onUniqueRead | This event is triggered when a new, unduplicated label is found. |
onFrameRead | This event is triggered after the library finishes scanning a frame. |
recognizeCurrentFrame() | Scans the current frame of the video for labels. |
startScanning() | Starts continuous scanning of incoming frames. |
stopScanning() | Stops continuous scanning. |
Settings
Scan Settings
API Name | Description |
---|---|
whenToPlaySoundforSuccessfulRead | Sets when to play sound on text recognition. |
soundOnSuccessfullRead | Specifies the sound to play on text recognition. |
whenToVibrateforSuccessfulRead | Sets when to vibrate on text recognition. |
vibrateDuration | Returns or sets how long the vibration lastsin milliseconds. |
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. |
Auxiliary
API Name | Description |
---|---|
ifSaveOriginalImageInACanvas | Whether to save the original image into a < canvas> element. |
getOriginalImageInACanvas() | Returns an HTMLCanvasElement that holds the original image. |
Interfaces and Enumerations
In order to make the code more predictable and readable, the library defines a series of supporting interfaces and enumerations.