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.

LabelRecognition

class com.dynamsoft.dlr.LabelRecognition

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

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

 

Initialization

Method Description
LabelRecognition Initialization of LabelRecognition object.
destroy Destroys an instance of LabelRecognition object.
initLicense Sets the license and activates the SDK.
initLicenseFromLTS Initializes the label recognition license and connects to the specified server for online verification.

LabelRecognition

Initialization of LabelRecognition object without or with a license.

LabelRecognition() throws LabelRecognitionException;
LabelRecognition(String license) throws LabelRecognitionException;

Exceptions

LabelRecognitionException

Remarks

If you initialize DynamsoftLabelRecognition without a license, the recognition results may be unreliable.

Code Snippet

LabelRecognition recognizer = new LabelRecognition();
LabelRecognition recognizer = new LabelRecognition("t0260NwAAAHV***************");

 

destroy

Destroys an instance of LabelRecognition object.

void destroy()	

Code Snippet

LabelRecognition recognizer = new LabelRecognition("t0260NwAAAHV***************");
recognizer.destroy();

initLicense

Sets product key and activate the SDK.

void initLicense(String license) throws LabelRecognitionException

Parameters license: The product keys.

Exceptions

LabelRecognitionException

Code Snippet

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

 

initLicenseFromLTS

Initializes the label recognition license and connects to the specified server for online verification.

void initLicenseFromLTS(DMLTSConnectionParameters ltsInfo) throws LabelRecognitionException

Parameters

  • ltsInfo: The struct DMLTSConnectionParameters with customized settings.

Exceptions

LabelRecognitionException

Code Snippet

LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters info = new DMLTSConnectionParameters();
info.organiztionID = "<your organization id got from Dynamsoft>";
recognizer.initLicenseFromLTS(info);

 

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 LabelRecognitionParameter settings in a string to the SDK object.
appendSettingsFromFile Appends LabelRecognitionParameter settings from a file to the SDK object.
outputSettingsToFile Outputs LabelRecognitionParameter settings into a file (JSON file).
clearAppendedSettings Clear all appended LabelRecognitionParameter settings in the SDK object.
updateReferenceRegionFromBarcodeResults Updates reference region which is defined with source type DLR_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 LabelRecognitionException

Return Value

The class object of template settings.

Exceptions

LabelRecognitionException

Code Snippet

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

 

updateRuntimeSettings

Update runtime settings with a given DLRRuntimeSettings class object.

void updateRuntimeSettings (DLRRuntimeSettings settings) throws LabelRecognitionException

Parameters settings The class object of template settings.

Exceptions

LabelRecognitionException

Code Snippet

LabelRecognition recognizer = new LabelRecognition();

DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
settings.linesCount = 1;
recognizer.updateRuntimeSettings(settings);
recognizer.destroy();

 

resetRuntimeSettings

Reset all runtime settings to default values.

void resetRuntimeSettings () throws LabelRecognitionException

Exceptions LabelRecognitionException

Code Snippet

LabelRecognition recognizer = new LabelRecognition();
DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
settings.linesCount = 1;
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 LabelRecognitionException

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

Exceptions

LabelRecognitionException

Code Snippet

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

 

appendSettingsFromFile

Appends LabelRecognitionParameter settings in a file to the SDK object.

void appendSettingsFromFile (String filePath) throws LabelRecognitionException

Parameters filePath The settings file path.

Exceptions

LabelRecognitionException

Code Snippet

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

 

appendSettingsFromString

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

void appendSettingsFromString (String content) throws LabelRecognitionException

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

Exceptions

LabelRecognitionException

Code Snippet

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

 

clearAppendedSettings

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

void clearAppendedSettings () throws LabelRecognitionException

Code Snippet

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

 

getModeArgument

Get argument value for the specified mode parameter.

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

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 LabelRecognitionException

Remark

Check follow link for available modes and arguments:

Code Snippet

LabelRecognition recognizer = new LabelRecognition();
DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
settings.regionPredetectionModes[0] = EnumRegionPredetectionMode.DLR_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 LabelRecognitionException	

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 LabelRecognitionException

Remark

Check follow link for available modes and arguments:

Code Snippet

LabelRecognition recognizer = new LabelRecognition();
DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
settings.regionPredetectionModes[0] = EnumRegionPredetectionMode.DLR_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 DLR_LST_BARCODE.

void updateReferenceRegionFromBarcodeResults (TextResult[] barcodeResults, String templateName) throws LabelRecognitionException

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

Exceptions

LabelRecognitionException

Code Snippet

LabelRecognition recognizer = new LabelRecognition();

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

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

 

Recognizing

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(DLRImageData imageData, String templateName) throws LabelRecognitionException

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

Return Value All results recognized successfully.

Exceptions

LabelRecognitionException

Code Snippet

LabelRecognition recognizer = new LabelRecognition();
// 1. init license...
// 2. 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 LabelRecognitionException	

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

Return Value All results recognized successfully.

Exceptions

LabelRecognitionException

Code Snippet

LabelRecognition recognizer = new LabelRecognition();
// 1. init license...
DLRResult[] result = recognizer.recognizeByFile("full file path", "");
recognizer.destroy();

 

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

    • Latest version(3.2.20)
    • Version 3.x
      • 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.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
    Change +
    © 2003–2024 Dynamsoft. All rights reserved.
    Privacy Statement / Site Map / Home / Purchase / Support