Parameter and Runtime Settings Advanced Methods
Method | Description |
---|---|
initRuntimeSettingsWithFile |
Initialize runtime settings with the settings in a given JSON file. |
initRuntimeSettingsWithString |
Initialize runtime settings with the settings in a given JSON string. |
appendTplFileToRuntimeSettings |
Append a new template file to the current runtime settings. |
appendTplStringToRuntimeSettings |
Append a new template string to the current runtime settings. |
allParameterTemplateNames |
Gets the parameter templates name array. |
outputSettingsToFile |
Output runtime settings to a settings file (JSON file). |
outputSettingsToString |
Output runtime settings to a string. |
setModeArgument |
Sets the optional argument for a specified mode in Modes parameters. |
getModeArgument |
Gets the optional argument for a specified mode in Modes parameters. |
initRuntimeSettingsWithFile
Initialize runtime settings with the parameters obtained from a JSON file.
- Objective-C
- Swift
- (BOOL)initRuntimeSettingsWithFile:(NSString* _Nonnull)fileName conflictMode:(EnumConflictMode)conflictMode error:(NSError* _Nullable * _Nullable)error;
func initRuntimeSettingsWithFile(_ fileName: String, conflictMode: EnumConflictMode) throws
Parameters
[in] fileName
: The settings file path.
[in] conflictMode
: The parameter setting mode, which decides whether to inherit parameters from previous template settings or to overwrite previous settings with the new template.
[in,out] error
: A pointer to an error object.
An error occurs when:
- The file is not found.
- There exists parameters that are invalid or out of range.
- The template name is invalid.
Code Snippet
- Objective-C
- Swift
[barcodeReader initRuntimeSettingsWithFile:@"your template file path" conflictMode:EnumConflictModeOverwrite error:nil];
do{ try barcodeReader.initRuntimeSettingsWithFile("your template file path", conflictMode:EnumConflictMode.overwrite) }catch{ // Add your code to deal with exceptions }
initRuntimeSettingsWithString
Initialize runtime settings with the parameters obtained from a JSON string.
- Objective-C
- Swift
- (BOOL)initRuntimeSettingsWithString:(NSString* _Nonnull)content conflictMode:(EnumConflictMode)conflictMode error:(NSError* _Nullable * _Nullable)error;
func initRuntimeSettingsWithString(_ content: String, conflictMode: EnumConflictMode) throws
Parameters
[in] content
: A JSON string that represents the content of the settings.
[in] conflictMode
: The parameter setting mode, which decides whether to inherit parameters from previous template setting or to overwrite previous settings with the new template.
[in,out] error
: A pointer to an error object.
An error occurs when:
- The library failed to parse the JSON string.
- There exists parameters that are invalid or out of range.
- The template name is invalid.
Code Snippet
- Objective-C
- Swift
[barcodeReader initRuntimeSettingsWithString:@"{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}" conflictMode:EnumConflictModeOverwrite error:nil];
do{ try barcodeReader.initRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", conflictMode:EnumConflictMode.overwrite) }catch{ // Add your code to deal with exceptions }
appendTplFileToRuntimeSettings
Append a new template file to the current runtime settings.
- Objective-C
- Swift
- (BOOL)appendTplFileToRuntimeSettings:(NSString * _Nonnull)fileName conflictMode:(EnumConflictMode)conflictMode error:(NSError * _Nullable *_Nullable)error;
func appendTplFileToRuntimeSettings(_ fileName: String, conflictMode: EnumConflictMode) throws
Parameters
[in] fileName
: The settings file path.
[in] conflictMode
: The parameter setting mode, which decides whether to inherit parameters from previous template settings or to overwrite previous settings with the new template.
[in,out] error
: A pointer to an error object.
An error occurs when:
- The file is not found.
- There exists parameters that are invalid or out of range.
- The template name is invalid.
Code Snippet
- Objective-C
- Swift
[barcodeReader appendTplFileToRuntimeSettings:@"your template file path" conflictMode:EnumConflictModeIgnore error:nil];
do{ try barcodeReader.appendTplFileToRuntimeSettings("your template file path", conflictMode:EnumConflictMode.ignore, error:&error) }catch{ // Add your code to deal with exceptions }
appendTplStringToRuntimeSettings
Append a new template string to the current runtime settings.
- Objective-C
- Swift
- (BOOL)appendTplStringToRuntimeSettings:(NSString * _Nonnull)content conflictMode:(EnumConflictMode)conflictMode error:(NSError *_Nullable *_Nullable)error;
func appendTplStringToRuntimeSettings(_ content: String, conflictMode: EnumConflictMode) throws
Parameters
[in] content
: A JSON string that represents the content of the settings.
[in] conflictMode
: The parameter setting mode, which decides whether to inherit parameters from previous template setting or to overwrite previous settings with the new template.
[in,out] error
: A pointer to an error object.
An error occurs when:
- The library failed to parse the JSON string.
- There exists parameters that are invalid or out of range.
- The template name is invalid.
Code Snippet
- Objective-C
- Swift
[barcodeReader initRuntimeSettingsWithString:@"{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}" conflictMode:EnumConflictModeOverwrite error:nil]; [barcodeReader appendTplStringToRuntimeSettings:@"{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_OneD\"], \"ExpectedBarcodesCount\":20}}" conflictMode:EnumConflictModeIgnore error:nil];
do{ try barcodeReader.initRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", conflictMode:EnumConflictMode.Overwrite) try barcodeReader.appendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_OneD\"], \"ExpectedBarcodesCount\":20}}", conflictMode:EnumConflictMode.ignore) }catch{ // Add your code to deal with exceptions }
allParameterTemplateNames
Get count of parameter templates.
- Objective-C
- Swift
- (NSArray<NSString*>* _Nullable)allParameterTemplateNames: (NSError *__autoreleasing _Nullable * _Nullable)error;
func allParameterTemplateNames() throws -> [String]
Parameters
[in,out] error
: A pointer to an error object.
An error occurs when:
- The library failed to get all template names.
Return Value
The template name array.
Code Snippet
- Objective-C
- Swift
NSArray* allTplNames = [barcodeReader allParameterTemplateNames:nil];
let allTplNames = do{ try barcodeReader.allParameterTemplateNames() }catch{ // Add your code to deal with exceptions }
outputSettingsToFile
Outputs runtime settings and save them into a settings file (JSON file).
- Objective-C
- Swift
- (BOOL)outputSettingsToFile:(NSString *_Nullable)filePath settingsName:(NSString*_Nonnull)settingsName error:(NSError*_Nullable *_Nullable)error;
func outputSettingsToFile(_ filePath: String?, settingsName: String) throws
Parameters
[in] filePath
The path of the output file which stores current settings.
[in] settingsName
A unique name for declaring current runtime settings.
[in,out] error
: A pointer to an error object.
An error occurs when:
- The file path is not found.
- The library failed to output the settings.
Code Snippet
- Objective-C
- Swift
settingsName = [barcodeReader outputSettingsToFile:@"your saving file path" settingsName:@"currentRuntimeSettings" error:nil];
do{ let settingsName = try barcodeReader.outputSettingsToFile("your saving file path", settingsName:"currentRuntimeSettings") }catch{ // Add your code to deal with exceptions }
outputSettingsToString
Output runtime settings to a string.
- Objective-C
- Swift
- (NSString *_Nullable)outputSettingsToString:(NSString*_Nonnull)settingsName error:(NSError* _Nullable * _Nullable)error;
func outputSettingsToString(_ settingsName: String) throws -> String
Parameters
[in] settingsName
A unique name for declaring current runtime settings.
[in,out] error
: A pointer to an error object.
An error occurs when:
- The library failed to output the settings.
Return Value
The output string which stores the content of current settings.
Code Snippet
- Objective-C
- Swift
settingsName = [barcodeReader outputSettingsToString:@"currentRuntimeSettings" error:nil];
do{ let settingsName = try barcodeReader.outputSettingsToString("currentRuntimeSettings") }catch{ // Add your code to deal with exceptions }
setModeArgument
Sets the optional argument for a specified mode in Modes parameters.
- Objective-C
- Swift
- (BOOL)setModeArgument:(NSString* _Nonnull)modeName index:(NSInteger)index argumentName:(NSString* _Nonnull)argumentName argumentValue:(NSString* _Nonnull)argumentValue error:(NSError* _Nullable * _Nullable)error;
func setModeArgument(_ modeName: String, index: Int, argumentName: String, argumentValue: String) throws
Parameters
[in] modesName
The mode parameter name to set argument.
[in] index
The array index of mode parameter to indicate a specific mode.
[in] argumentName
The name of the argument to set.
[in] argumentValue
The value of the argument to set.
[in,out] error
: A pointer to an error object.
An error occurs when:
- The library failed to set the mode argument. It might because you input incorrect
modeName
,index
,argumentName
orargumentValue
.
Code Snippet
- Objective-C
- Swift
iPublicRuntimeSettings *settings = [barcodeReader getRuntimeSettings:nil]; settings.binarizationModes = @[@(EnumBinarizationModeLocalBlock)]; [barcodeReader updateRuntimeSettings:settings error:nil]; [barcodeReader setModeArgument:@"BinarizationModes" index:0 argumentName:@"EnableFillBinaryVacancy" argumentValue:"1" error:nil];
do{ let settings = try barcodeReader.getRuntimeSettings() settings.binarizationModes = [EnumBinarizationMode.localBlock] try barcodeReader.updateRuntimeSettings(settings) try barcodeReader.setModeArgument("BinarizationModes", index: 0, argumentName: "EnableFillBinaryVacancy", argumentValue: "1") }catch{ // Add your code to deal with exceptions }
Remarks
Check follow link for available modes and arguments:
BarcodeColourModes
BinarizationModes
ColourClusteringModes
ColourConversionModes
DeformationResistingModes
ImagePreprocessingModes
IntermediateResultSavingMode
LocalizationModes
RegionPredetectionModes
ScaleUpModes
TextFilterModes
TextureDetectionModes
getModeArgument
Gets the optional argument for a specified mode in Modes parameters.
- Objective-C
- Swift
-(NSString* _Nonnull)getModeArgument:(NSString* _Nonnull)modeName index:(NSInteger)index argumentName:(NSString* _Nonnull)argumentName error:(NSError* _Nullable * _Nullable)error;
func getModeArgument(_ modeName: String, index: Int, argumentName: String) throws -> String
Parameters
[in] modesName
The mode parameter name to get arguments.
[in] index
The array index of mode parameter to indicate a specific mode.
[in] argumentName
The name of the argument to get.
[in,out] error
: A pointer to an error object.
An error occurs when:
- The library failed to get the mode argument. It might because you input incorrect
modeName
,index
orargumentName
.
Return Value
the optional argument for a specified mode
Code Snippet
- Objective-C
- Swift
iPublicRuntimeSettings *settings = [barcodeReader getRuntimeSettings:nil]; settings.binarizationModes = @[@(EnumBinarizationModeLocalBlock)]; [barcodeReader updateRuntimeSettings:settings error:nil]; [barcodeReader setModeArgument:@"BinarizationModes" index:0 argumentName:@"EnableFillBinaryVacancy" argumentValue:"1" error:nil]; argumentValue = [barcodeReader getModeArgument:@"BinarizationModes" index:0 argumentName:@"EnableFillBinaryVacancy" error:&error];
let settings = do{ try barcodeReader.getRuntimeSettings() settings.binarizationModes = [EnumBinarizationMode.localBlock] try barcodeReader.updateRuntimeSettings(settings) try barcodeReader.setModeArgument("BinarizationModes", index: 0, argumentName: "EnableFillBinaryVacancy", argumentValue: "1") let argumentValue = try barcodeReader.getModeArgument("BinarizationModes", index: 0, argumentName: "EnableFillBinaryVacancy") }catch{ // Add your code to deal with exceptions }
Remarks
Check follow link for available modes and arguments: