Documentation
Table of contents

LabelRecognizer

class com.dynamsoft.dlr.LabelRecognizer

Initialization

Method Description
LabelRecognizer Initialization of LabelRecognizer object.
destroy Destroys an instance of LabelRecognizer object.
initLicense Sets the license and activates the SDK.

 

LabelRecognizer

Initialization of LabelRecognizer object.

LabelRecognizer() throws LabelRecognizerException;

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer recognizer = new LabelRecognizer();

 

destroy

Destroys an instance of LabelRecognizer object.

void destroy()	

Code Snippet

LabelRecognizer recognizer = new LabelRecognizer();
recognizer.destroy();

 

initLicense

Sets product key and activate the SDK.

static void initLicense(String license) throws LabelRecognizerException

Parameters

license: The product keys.

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");
LabelRecognizer recognizer = new LabelRecognizer();

Settings

Method Description
getRuntimeSettings Gets the current settings and saves it into a struct.
updateRuntimeSettings Updates runtime settings with a given struct.
resetRuntimeSettings Resets the runtime settings.
appendSettingsFromString Appends LabelRecognizerParameter settings in a string to the SDK object.
appendSettingsFromFile Appends LabelRecognizerParameter settings from a file to the SDK object.
outputSettingsToFile Outputs LabelRecognizerParameter settings into a file (JSON file).
clearAppendedSettings Clear all appended LabelRecognizerParameter settings in the SDK object.
updateReferenceRegionFromBarcodeResults Updates reference region which is defined with source type LST_BARCODE.
getModeArgument Get argument value for the specified mode parameter.
setModeArgument Set argument value for the specified mode parameter.

 

getRuntimeSettings

Get current settings and save them into a DLRRuntimeSettings class object.

PublicRuntimeSettings getRuntimeSettings () throws LabelRecognizerException

Return value

The class object of template settings.

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();
DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
recognizer.destroy();

 

updateRuntimeSettings

Update runtime settings with a given DLRRuntimeSettings class object.

void updateRuntimeSettings (DLRRuntimeSettings settings) throws LabelRecognizerException

Parameters

settings The class object of template settings.

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();

DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
settings.maxThreadCount = 4;
recognizer.updateRuntimeSettings(settings);
recognizer.destroy();

 

resetRuntimeSettings

Reset all runtime settings to default values.

void resetRuntimeSettings () throws LabelRecognizerException

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();
DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
settings.maxThreadCount = 4;
recognizer.updateRuntimeSettings(settings);
recognizer.resetRuntimeSettings();
recognizer.destroy();

 

outputSettingsToFile

Outputs runtime settings and save them into a settings file (JSON file).

void outputSettingsToFile (String filePath, String templateName) throws LabelRecognizerException

Parameters

filePath The path of the output file which stores current settings.
templateName A unique name for declaring current runtime settings.

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();
recognizer.appendSettingsFromString("{\"LabelRecognizerParameter\":{\"Name\":\"P1\", \"RegionPredetectionModes\":[{\"Mode\":\"RPM_GENERAL_HSV_CONTRAST\"}], \"ReferenceRegionNameArray\": [\"R1\"]},\"ReferenceRegion\":{\"Name\":\"R1\",\"Localization\":{\"SourceType\":\"LST_PREDETECTED_REGION\",\"RegionPredetectionModesIndex\":0},\"TextAreaNameArray\":[\"T1\"]},\"TextArea\":{\"Name\":\"T1\",\"CharacterModelName\":\"Number\"}}");
recognizer.outputSettingsToFile("your saving file path", "currentRuntimeSettings");
recognizer.destroy();

 

appendSettingsFromFile

Appends LabelRecognizerParameter settings in a file to the SDK object.

void appendSettingsFromFile (String filePath) throws LabelRecognizerException

Parameters

filePath The settings file path.

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();
recognizer.appendSettingsFromFile("your file path");
recognizer.destroy();

 

appendSettingsFromString

Append a new template string to the current label recognizer instance.

void appendSettingsFromString (String content) throws LabelRecognizerException

Parameters

content A JSON string that represents the content of the settings.

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();
recognizer.appendSettingsFromString("{\"LabelRecognizerParameter\":{\"Name\":\"P1\", \"RegionPredetectionModes\":[{\"Mode\":\"RPM_GENERAL_HSV_CONTRAST\"}], \"ReferenceRegionNameArray\": [\"R1\"]},\"ReferenceRegion\":{\"Name\":\"R1\",\"Localization\":{\"SourceType\":\"LST_PREDETECTED_REGION\",\"RegionPredetectionModesIndex\":0},\"TextAreaNameArray\":[\"T1\"]},\"TextArea\":{\"Name\":\"T1\",\"CharacterModelName\":\"Number\"}}");
recognizer.destroy();

 

clearAppendedSettings

Clear all appended parameter settings of the current label recognizer instance.

void clearAppendedSettings () throws LabelRecognizerException

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();
recognizer.clearAppendedSettings();

 

getModeArgument

Get argument value for the specified mode parameter.

String getModeArgument (String modesName, int index, String argumentName) throws LabelRecognizerException	

Parameters

  • modesName: The mode parameter name to get argument.
  • index: The array index of mode parameter to indicate a specific mode.
  • argumentName: The name of the argument to get.

Return value

the optional argument for a specified mode in Modes parameters.

Exceptions

LabelRecognizerException

Remark

Check follow link for available modes and arguments:

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();
DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
settings.furtherModes.regionPredetectionModes[0] = EnumRegionPredetectionMode.RPM_GENERAL_RGB_CONTRAST;
recognizer.updateRuntimeSettings(settings);
recognizer.setModeArgument("RegionPredetectionModes", 0, "AspectRatioRange", "100");
String argumentValue = recognizer.getModeArgument("RegionPredetectionModes", 0, "AspectRatioRange");
recognizer.destroy();

 

setModeArgument

Set argument value for the specified mode parameter.

void setModeArgument (String modesName, int index, String argumentName, String argumentValue)	throws LabelRecognizerException	

Parameters

  • modesName: The mode parameter name to set argument.
  • index: The array index of mode parameter to indicate a specific mode.
  • argumentName: The name of the argument to set.
  • argumentValue: The value of the argument to set.

Exceptions

LabelRecognizerException

Remark

Check follow link for available modes and arguments:

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();
DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
settings.furtherModes.regionPredetectionModes[0] = EnumRegionPredetectionMode.RPM_GENERAL_RGB_CONTRAST;
recognizer.updateRuntimeSettings(settings);
recognizer.setModeArgument("RegionPredetectionModes", 0, "AspectRatioRange", "100");
recognizer.destroy();

 

updateReferenceRegionFromBarcodeResults

Updates reference region which is defined with source type LST_BARCODE.

void updateReferenceRegionFromBarcodeResults (BarcodeResult[] barcodeResults, String templateName) throws LabelRecognizerException

Parameters

barcodeResults The barcode results used to localize reference region. See also BarcodeResult. templateName The template name. A template name is the value of key LabelRecognizerParameter.Name defined in JSON formatted settings. If no template name is specified, current runtime settings will be used.

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer.initLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();

recognizer.appendSettingsFromString("{\"LabelRecognizerParameter\":{\"Name\":\"P1\", \"RegionPredetectionModes\":[{\"Mode\":\"RPM_GENERAL_HSV_CONTRAST\"}], \"ReferenceRegionNameArray\": [\"R1\"]},\"ReferenceRegion\":{\"Name\":\"R1\",\"Localization\":{\"SourceType\":\"LST_BARCODE\"},\"TextAreaNameArray\":[\"T1\"]},\"TextArea\":{\"Name\":\"T1\",\"CharacterModelName\":\"Number\"}}");

//Get barcodeResults from Dynamsoft Barcode Reader SDK
recognizer.updateReferenceRegionFromBarcodeResults(barcodeResults, "P1");
recognizer.destroy();

Recognition Methods

Method Description
recognizeByBuffer Recognizes text from memory buffer containing image pixels in defined format.
recognizeByFile Recognizes text from a specified image file.

 

recognizeByBuffer

Recognizes text from the memory buffer containing image pixels in defined format.

DLRResult[] recognizeByBuffer(ImageData imageData, String templateName) throws LabelRecognizerException

Parameters

[in] imageData An object of ImageData that represents an image.
[in] templateName The template name. A template name is the value of key LabelRecognizerParameter.Name defined in JSON formatted settings. If no template name is specified, current runtime settings will be used.

Return value

All results organized in a DLR_Result array.

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer.InitLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();

// Generate imageData from somewhere else...
DLRResult[] result = recognizer.recognizeByBuffer(imageData, "");
recognizer.destroy();

 

recognizeByFile

Recognizes text from a specified image file.

DLRResult[] recognizeByFile (String fileName, String templateName) throws LabelRecognizerException	

Parameters

fileName A string defining the file name.
templateName The template name. A template name is the value of key LabelRecognizerParameter.Name defined in JSON formatted settings. If no template name is specified, current runtime settings will be used.

Return value

All results organized in a DLR_Result array.

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer.InitLicense("t0260NwAAAHV***************");

LabelRecognizer recognizer = new LabelRecognizer();
DLRResult[] result = recognizer.recognizeByFile("full file path", "");
recognizer.destroy();

General

Method Description
getVersion Returns the version number string for the SDK.

 

getVersion

Get version information of SDK.

String getVersion()	

Return value

The version information string.

Code Snippet

LabelRecognizer recognizer = new LabelRecognizer();
String versionInfo = recognizer.getVersion();
recognizer.destroy();

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article:

latest version

    • Latest version
    • Version 3.x
      • Version 3.2.30
      • Version 3.2.20
      • Version 3.2.10
      • Version 3.2.0
      • Version 3.0.30
      • Version 3.0.20
      • Version 3.0.10
      • Version 3.0.0
    • Version 2.x
      • Version 2.2.20
      • Version 2.2.11
      • Version 2.2.10
      • Version 2.2.0
      • Version 2.0.0
      • Version 2.2.20
      • Version 2.2.11
      • Version 2.2.10
      • Version 2.2.0
      • Version 2.0.0
      • Version 2.0.0
      • Version 2.2.10
      • Version 2.0.0
    • Version 1.x
      • Version 1.2.1
      • Version 1.2
      • Version 1.0
      • Version 1.2.1
      • Version 1.2
      • Version 1.0
      • Version 1.2.1
      • Version 1.2
      • Version 1.0
      • Version 1.2.1
    • Documentation Homepage
    Change +