Documentation
Table of contents

LabelRecognizer

class Dynamsoft.DLR.LabelRecognizer

Initialization

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

 

LabelRecognizer()

Initialization of LabelRecognizer object.

LabelRecognizer()

Exceptions

LabelRecognizerException

Code Snippet

LabelRecognizer recognizer = new LabelRecognizer();

 

Dispose

Destroys an instance of Dynamsoft Label Recognizer.

void Dispose()	

Code Snippet

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

 

InitLicense

Sets product key and activate the SDK.

static void InitLicense(string license)

Parameters

license: The product keys.

Exceptions

LabelRecognizerException

Code Snippet

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

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

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 in 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 DLR_RuntimeSettings class object.

DLR_RuntimeSettings GetRuntimeSettings()

Return value

The class object of runtime settings.

Exceptions

LabelRecognizerException

Code Snippet

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

LabelRecognizer recognizer = new LabelRecognizer();
DLR_RuntimeSettings settings = recognizer.GetRuntimeSettings();
recognizer.Dispose();

 

UpdateRuntimeSettings

Update runtime settings with a given DLR_RuntimeSettings class object.

void UpdateRuntimeSettings(DLR_RuntimeSettings settings)

Parameters

settings The class object of runtime settings.

Exceptions

LabelRecognizerException

Code Snippet

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

LabelRecognizer recognizer = new LabelRecognizer();
DLR_RuntimeSettings settings = recognizer.GetRuntimeSettings();
settings.MaxThreadCount = 4;
recognizer.UpdateRuntimeSettings(settings);
recognizer.Dispose();

 

ResetRuntimeSettings

Reset all runtime settings to default values.

void ResetRuntimeSettings ()

Exceptions

LabelRecognizerException

Code Snippet

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

LabelRecognizer recognizer = new LabelRecognizer();
DLR_RuntimeSettings settings = recognizer.GetRuntimeSettings();
settings.MaxThreadCount = 4;
recognizer.UpdateRuntimeSettings(settings);
recognizer.ResetRuntimeSettings();
recognizer.Dispose();

 

AppendSettingsFromString

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

void AppendSettingsFromString (string content)

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.Dispose();

 

AppendSettingsFromFile

Appends LabelRecognizerParameter settings in a file to the SDK object.

void AppendSettingsFromFile (string filePath)

Parameters

filePath The settings file path.

Exceptions

LabelRecognizerException

Code Snippet

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

LabelRecognizer recognizer = new LabelRecognizer();
recognizer.AppendSettingsFromFile("your file path");
recognizer.Dispose();

 

OutputSettingsToFile

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

void OutputSettingsToFile(string filePath, string templateName)

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.Dispose();

 

ClearAppendedSettings

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

void ClearAppendedSettings ()

Code Snippet

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

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

 

UpdateReferenceRegionFromBarcodeResults

Updates reference region which is defined with source type LST_BARCODE.

void UpdateReferenceRegionFromBarcodeResults(BarcodeResult[] barcodeResults, string templateName)

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.Dispose();

 

SetModeArgument

Set argument value for the specified mode parameter.

void SetModeArgument(string modesName, int index, string argumentName, string argumentValue)	

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();
DLR_RuntimeSettings settings = recognizer.GetRuntimeSettings();
settings.FurtherModes.RegionPredetectionModes[0] = EnumRegionPredetectionMode.RPM_GENERAL_RGB_CONTRAST;
recognizer.UpdateRuntimeSettings(settings);
recognizer.SetModeArgument("RegionPredetectionModes", 0, "AspectRatioRange", "100");
recognizer.Dispose();

 

GetModeArgument

Get argument value for the specified mode parameter.

string GetModeArgument (string modesName, int index, string argumentName)	

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();
DLR_RuntimeSettings 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.Dispose();

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.

DLR_Result[] RecognizeByBuffer(ImageData imageData, string templateName)

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
DLR_Result[] result = recognizer.RecognizeByBuffer(imageData, "");
recognizer.Dispose();

 

RecognizeByFile

Recognizes text from a specified image file.

DLR_Result[] RecognizeByFile (string fileName, string templateName)	

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();
DLR_Result[] result = recognizer.RecognizeByFile("full file path", "");
recognizer.Dispose();

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.Dispose();

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 +