Thanks for downloading Dynamsoft Label Recognizer Package!
Your download will start shortly. If your download does not begin, click here to retry.
Android API Reference - Settings
You are viewing a history document page of Dynamsoft Label Recognizer Android v1.x.
Method | Description |
---|---|
appendCharacterModelBuffer |
Appends CharacterModel to the SDK object. |
appendSettingsFromFile |
Appends LabelRecognitionParameter settings in a file to the SDK object. |
appendSettingsFromString |
Appends LabelRecognitionParameter settings in a string to the SDK object. |
clearAppendedSettings |
Clears appended LabelRecognitionParameter settings. |
eraseAllCharacterModels |
Erases all CharacterModels the SDK object currently loaded. |
eraseCharacterModelByName |
Erases a name specified CharacterModel from the SDK object. |
getModeArgument |
Get argument value for the specified mode parameter. |
getRuntimeSettings |
Gets the current settings and saves it into a class object. |
outputSettingsToFile |
Outputs LabelRecognitionParameter settings into a file (JSON file). |
resetRuntimeSettings |
Resets the runtime settings. |
setModeArgument |
Set argument value for the specified mode parameter. |
updateReferenceRegionFromBarcodeResults |
Updates reference region which is defined with source type DLR_LST_BARCODE. |
updateRuntimeSettings |
Updates runtime settings with a given class object. |
appendCharacterModelBuffer
Appends CharacterModel to the SDK object.
void com.dynamsoft.dlr.LabelRecognition.appendCharacterModelBuffer (String name, byte[] prototxtBuffer, byte[] txtBuffer, byte[] characterModelBuffer) throws LabelRecognitionException
Parameters
name
A unique name for the appended CharacterModel.
prototxtBuffer
The .prototxt file data of the CharacterModel in a byte array.
txtBuffer
The .txt file data of the CharacterModel in a byte array.
characterModelBuffer
The .caffemodel file data of the CharacterModel in a byte array.
Exceptions
LabelRecognitionException
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
AssetManager manager = getAssets();
InputStream isPrototxt = manager.open("CharacterModel/NumberLetter.prototxt");
byte[] prototxt = new byte[isPrototxt.available()];
isPrototxt.read(prototxt);
isPrototxt.close();
InputStream isCharacterModel = manager.open("CharacterModel/NumberLetter.caffemodel");
byte[] characterModel = new byte[isCharacterModel.available()];
isCharacterModel.read(characterModel);
isCharacterModel.close();
InputStream isTxt = manager.open("CharacterModel/NumberLetter.txt");
byte[] txt = new byte[isTxt.available()];
isTxt.read(txt);
isTxt.close();
recognizer.appendCharacterModelBuffer("NumberLetter", prototxt, txt, characterModel);
recognizer.destroy();
appendSettingsFromFile
Appends LabelRecognitionParameter settings in a file to the SDK object.
void com.dynamsoft.dlr.LabelRecognition.appendSettingsFromFile (String filePath) throws LabelRecognitionException
Parameters
filePath
The settings file path.
Exceptions
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
recognizer.appendSettingsFromFile("your file path");
recognizer.destroy();
appendSettingsFromString
Append a new template string to the current label recognition instance.
void com.dynamsoft.dlr.LabelRecognition.appendSettingsFromString (String content) throws LabelRecognitionException
Parameters
content
A JSON string that represents the content of the settings.
Exceptions
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
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 com.dynamsoft.dlr.LabelRecognition.clearAppendedSettings () throws LabelRecognitionException
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
recognizer.clearAppendedSettings();
eraseAllCharacterModels
Erases all CharacterModels the SDK object currently loaded.
void com.dynamsoft.dlr.LabelRecognition.eraseAllCharacterModels () throws LabelRecognitionException
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
recognizer.eraseAllCharacterModels();
eraseCharacterModelByName
Erases a name specified CharacterModel from the SDK object.
void com.dynamsoft.dlr.LabelRecognition.eraseCharacterModelByName(String name) throws LabelRecognitionException
Parameters
name
A unique name representing the CharacterModel to erase.
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
recognizer.eraseCharacterModelByName("NumberLetter");
getModeArgument
Get argument value for the specified mode parameter.
String com.dynamsoft.dlr.LabelRecognition.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();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
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();
getRuntimeSettings
Get current settings and save them into a DLRRuntimeSettings
class object.
PublicRuntimeSettings com.dynamsoft.dlr.LabelRecognition.getRuntimeSettings () throws LabelRecognitionException
Return Value
The class object of template settings.
Exceptions
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
recognizer.destroy();
outputSettingsToFile
Outputs runtime settings and save them into a settings file (JSON file).
void com.dynamsoft.dlr.LabelRecognition.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
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
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();
resetRuntimeSettings
Reset all runtime settings to default values.
void com.dynamsoft.dlr.LabelRecognition.resetRuntimeSettings () throws LabelRecognitionException
Exceptions
LabelRecognitionException
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
settings.linesCount = 1;
recognizer.updateRuntimeSettings(settings);
recognizer.resetRuntimeSettings();
recognizer.destroy();
setModeArgument
Set argument value for the specified mode parameter.
void com.dynamsoft.dlr.LabelRecognition.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();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
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 com.dynamsoft.dlr.LabelRecognition.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
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
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();
updateRuntimeSettings
Update runtime settings with a given DLRRuntimeSettings
class object.
void com.dynamsoft.dlr.LabelRecognition.updateRuntimeSettings (DLRRuntimeSettings settings) throws LabelRecognitionException
Parameters
settings
The class object of template settings.
Exceptions
Code Snippet
LabelRecognition recognizer = new LabelRecognition();
DMLTSConnectionParameters parameters = new DMLTSConnectionParameters();
parameters.organizationID = "200001";
recognizer.initLicenseFromLTS(parameters, new DLRLTSLicenseVerificationListener() {
@Override
public void LTSLicenseVerificationCallback(boolean isSuccess, Exception error) {
if (!isSuccess) {
error.printStackTrace();
}
}
});
DLRRuntimeSettings settings = recognizer.getRuntimeSettings();
settings.linesCount = 1;
recognizer.updateRuntimeSettings(settings);
recognizer.destroy();