Web Demos

BARCODE READER SDK DEMO

Explore the flexibe barcode reading settings to optimize for your specific usage scenario.

WEB TWAIN SDK DEMO

Try the most popular web scanner features: scan images, import local images and PDF files, edit, save to local, upload to database, and etc.

BARCODE READER JAVASCRIPT DEMO

Transform any camera-equipped devices into real-time, browser-based barcode and QR code scanners.

MRZ SCANNER WEB DEMO

Detects the machine-readable zone of a passport, scans the text, and parses into human-readable data.

APP STORE DEMOS

BARCODE READER SDK FOR IOS

BARCODE READER SDK FOR ANDROID

VIEW MORE DEMOS >
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.

DynamsoftLabelRecognizer

@interface DynamsoftLabelRecognizer : NSObject 

Initialization Method Summary

Method Description
init Create an instance of Dynamsoft Label Recognizer.
initLicense Initializes the label Recognizer license.

Settings Method Summary

Method Description
getRuntimeSettings Gets the current settings and saves it into a class.
updateRuntimeSettings Updates runtime settings with a given class.
initRuntimeSettings Initialize LabelRecognizerParameter settings from a JSON string.
initRuntimeSettingsFromFile Initialize LabelRecognizerParameter settings from a JSON file.
outputRuntimeSettings Outputs LabelRecognizerParameter settings as a string.
outputRuntimeSettingsToFile Outputs LabelRecognizerParameter settings into a JSON file.
resetRuntimeSettings Resets the runtime settings.
getModeArgument Get argument value for the specified mode parameter.
setModeArgument Set argument value for the specified mode parameter.
updateReferenceRegionFromBarcodeResults Updates reference region which is defined with source type LST_BARCODE.
appendCharacterModel Appends CharacterModel to the SDK object.

Video Scanning Method Summary

Method Description
setImageSource Set an instance of ImageSource as the source of video label scanning. User can either implement the interface ImageSource or use DynamsoftCameraEnhancer.
setLabelResultListener Register a LabelResultListener to obtain video label recognition results.
startScanning Start video label recognition.
stopScanning Stop video label recognition.

Recognition Method Summary

Method Description
recognizeBuffer Recognizes text from memory buffer containing image pixels in defined format.
recognizeFile Recognizes text from a specified image file.
recognizeImage Recognizes text from a UIImage.
recognizeFileInMemory Recognizes text from an image file in memory.

General Method Summary

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

 

Initialization Method Details

init

Initializes DynamsoftLabelRecognizer.

- (instancetype _Nonnull)init;

Return value

The instance of DynamsoftLabelRecognizer.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    
  2. let recognizer = DynamsoftLabelRecognizer.init()
    

 

initLicense

Initializes the label Recognizer license.

+ (void)initLicense:(NString* _Nullable)license verificationDelegate:(id _Nullable)connectionDelegate;

Parameters

[in] license The product keys.
[in,out] connectionDelegate The delegate to handle callback when license server returns.

Code Snippet

  • Objective-C
  • Swift
  1. [DynamsoftLabelRecognizer initLicense:@"t0260NwAAAHV***************" verificationDelegate:self];
    - (void)DLRLicenseVerificationCallback:(bool)isSuccess error:(NSError * )error
    {
    //TODO: add your code for license verification
    }
    
  2. DynamsoftLabelRecognizer.initLicense(license:"t0260NwAAAHV***************", verificationDelegate: self)
    func DLRLicenseVerificationCallback(_ isSuccess: Bool, error: Error?)
    {
    //TODO: add your code for license verification
    }
    

Settings Method Details

initRuntimeSettings

Initialize LabelRecognizerParameter settings from a JSON string.

- (BOOL)initRuntimeSettings:(NSString*)content
                              error:(NSError* _Nullable * _Nullable)error;

Parameters

[in] content A stringified JSON data that stores runtime settings. [in,out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return Value

Whether the settings are updated successfully.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing *  error;
    [recognizer initRuntimeSettings:@"Your runtime settings in a JSON string" error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    try? recognizer.initRuntimeSettings("Your runtime settings in a JSON string")
    

initRuntimeSettingsFromFile

Initialize LabelRecognizerParameter settings from a JSON file.

- (BOOL)initRuntimeSettingsFromFile:(NSString*)filePath
                              error:(NSError* _Nullable * _Nullable)error;

Parameters

[in] filePath The path of a JSON file that stores runtime settings. [in,out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return Value

Whether the settings are updated successfully.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing *  error;
    [recognizer initRuntimeSettingsFromFile:@"Path of your JSON file" error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    try? recognizer.initRuntimeSettingsFromFile("Path of your JSON file")
    

getRuntimeSettings

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

- (iDLRRuntimeSettings*)getRuntimeSettings:(NSError**)error;

Parameters

[in,out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return value

The class object of runtime settings.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing *  error;
    iDLRRuntimeSettings* settings = [recognizer getRuntimeSettings:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    let settings = try? settings = recognizer.getRuntimeSettings()
    

 

updateRuntimeSettings

Update runtime settings with a given iDLRRuntimeSettings class object.

- (void)updateRuntimeSettings:(iDLRRuntimeSettings*)settings error:(NSError**)error

Parameters

[in] settings The class object of template settings.
[in,out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing *  error;
    iDLRRuntimeSettings *settings;
    settings.maxThreadCount = 4;
    [recognizer updateRuntimeSettings:settings error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    let settings = try? recognizer.getRuntimeSettings()
    settings.maxThreadCount = 4;
    try? recognizer.updateRuntimeSettings(settings);
    

 

appendCharacterModel

Appends CharacterModel to the SDK object.

+ (void)appendCharacterModel:(NSString*)name prototxtBuffer:(NSData*)prototxtBuffer txtBuffer:(NSData*)txtBuffer characterModelBuffer:(NSData*)characterModelBuffer

Parameters

[in] name A unique name for the appended CharacterModel.
[in] prototxtBuffer The .prototxt file data of the CharacterModel in a byte array.
[in] txtBuffer The .txt file data of the CharacterModel in a byte array.
[in] characterModelBuffer The .caffemodel file data of the CharacterModel in a byte array.

Code Snippet

  • Objective-C
  • Swift
  1. //construct prototxtBuffer, txtBuffer and characterModelBuffer
    [DynamsoftLabelRecognizer appendCharacterModel:@"your model name" prototxtBuffer: prototxtBuffer txtBuffer: txtBuffer characterModelBuffer: characterModelBuffer];
    
  2. //construct prototxtBuffer, txtBuffer and characterModelBuffer
    DynamsoftLabelRecognizer.appendCharacterModel("your model name", prototxtBuffer: prototxtBuffer, txtBuffer: txtBuffer, characterModelBuffer: characterModelBuffer)
    

 

getModeArgument

Get argument value for the specified mode parameter.

- (NSString* _Nonnull)getModeArgument:(NSString* _Nonnull)modeName index:(NSInteger)index argumentName:(NSString* _Nonnull)argumentName error:(NSError* _Nullable * _Nullable)error;

Parameters

[in] modeName The mode parameter name to get argument.
[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 Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return value

the optional argument for a specified mode in Modes parameters.

Remark

Check follow link for available modes and arguments:

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing *  error;
    NSString *argumentValue = [recognizer getModeArgument:@"RegionPredetectionModes" index:0 argumentName:@"AspectRatioRange" error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    let argumentValue = try? recognizer.getModeArgument("RegionPredetectionModes", index:0, argumentName:"AspectRatioRange")
    

 

outputRuntimeSettings

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

- (NSString* _Nullable)outputRuntimeSettings:(NSString* _Nonnull)settingsName
                                       error:(NSError* _Nullable * _Nullable)error;

Parameters

[in] settingsName The path of the output file which stores current settings.
[in,out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing *  error;
    NSString *settings = [recognizer outputRuntimeSettings:@"your settings name" error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    let settings = try? recognizer.outputRuntimeSettings("your settings name")
    

outputRuntimeSettingsToFile

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

- (BOOL)outputRuntimeSettingsToFile:(NSString* _Nullable)filePath
                       settingsName:(NSString* _Nonnull)settingsName
                              error:(NSError* _Nullable * _Nullable)error;

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 Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing *  error;
    [recognizer outputRuntimeSettingsToFile:@"your saving file path" error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    try? recognizer.outputRuntimeSettingsToFile("your saving file path")
    

 

resetRuntimeSettings

Reset all runtime settings to default values.

- (void)resetRuntimeSettings:(NSError**)error;

Parameters

[in,out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing *  error;
    [recognizer resetRuntimeSettings:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    try? recognizer.resetRuntimeSettings()
    

 

setModeArgument

Set argument value for the specified mode parameter.

- (void)setModeArgument:(NSString* _Nonnull)modeName index:(NSInteger)index argumentName:(NSString* _Nonnull)argumentName argumentValue:(NSString* _Nonnull)argumentValue error:(NSError* _Nullable * _Nullable)error;

Parameters

[in] modeName 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 Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Remark

Check follow link for available modes and arguments:

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing * _Nullable error;
    [recognizer setModeArgument:@"RegionPredetectionModes" index:0 argumentName:@"AspectRatioRange" argumentValue:"100" error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    try? recognizer.setModeArgument("RegionPredetectionModes", index:0, argumentName:"AspectRatioRange", argumentValue:"100")
    

 

updateReferenceRegionFromBarcodeResults

Updates reference region which is defined with source type LST_BARCODE.

- (void)updateReferenceRegionFromBarcodeResults:(NSArray<iBarcodeResult*>*)barcodeResults templateName:(NSString *)templateName error:(NSError**)error

Parameters

[in] barcodeResults The barcode results used to localize reference region. See also iBarcodeResult.
[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.
[in,out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSArray<iBarcodeResult*> *textResults;
    //get textResults from Dynamsoft Barcode Reader SDK
    NSError __autoreleasing *error;
    [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\"}}" error:&error];
    [recognizer updateReferenceRegionFromBarcodeResults:textResults templateName:@"P1" error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    var textResults = [iBarcodeResult]()
    //get textResults from Dynamsoft Barcode Reader SDK
    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\"}}", error:&error)
    try? recognizer.updateReferenceRegionFromBarcodeResults(textResults, templateName:"P1")
    

 

Video Scanning Method Details

setImageSource

Set an instance of ImageSource as the source of video label scanning. User can either implement the interface ImageSource or use DynamsoftCameraEnhancer.

- (void)setImageSource:(id<ImageSource>)source;

Parameters

[in] source A instance of protocol ImageSource.

Code Snippet

  • Objective-C
  • Swift
  1. @interface ViewController ()<LabelResultListener>
    @property (nonatomic, strong) DynamsoftLabelRecognizer *labelRecognizer;
    @property (nonatomic, strong) DynamsoftCameraEnhancer *cameraEnhancer;
    @property (nonatomic, strong) DCECameraView *dceView;
    - (void)configureDLR {
       // Setup Dynamsoft Camera Enhancer
       self.dceView = [[DCECameraView alloc] initWithFrame:self.view.bounds];
       self.cameraEnhancer = [[DynamsoftCameraEnhancer alloc] initWithView:self.dceView];
       [self.view addSubview:self.dceView];
       // Initialize Dynamsoft Label Recognizer
       recognizer = [[DynamsoftLabelRecognizer alloc] init];
       // Trigger setImageSource
       [self.labelRecognizer setImageSource:self.cameraEnhancer];
       [self.labelRecognizer setLabelResultListener:self];
       [self.cameraEnhancer open];
       [self.labelRecognizer startScanning];
    }
    - (void)labelResultCallback:(NSInteger)frameId imageData:(iImageData *)imageData results:(NSArray<iDLRResult *> *)results {
       // Add your code to do with label recognition results
    }
    
  2. class ViewController: BaseViewController, LabelResultListener {
       var labelRecognizer: DynamsoftLabelRecognizer!
       var cameraEnhancer: DynamsoftCameraEnhancer!
       var dceView: DCECameraView!
       func configureDLR() -> Void {
          // Setup Dynamsoft Camera Enhancer
          dceView = DCECameraView.init(frame: self.view.bounds)
          cameraEnhancer = DynamsoftCameraEnhancer.init(view: self.dceView)
          self.view.addSubview(self.dceView)
          // Initialize Dynamsoft Label Recognizer
          let recognizer = DynamsoftLabelRecognizer()
          // Trigger setImageSource
          labelRecognizer.setImageSource(self.cameraEnhancer)
          labelRecognizer.setLabelResultListener(self)
          cameraEnhancer.open()
          labelRecognizer.startScanning()
       }
       func labelResultCallback(_ frameId: Int, imageData: iImageData, results: [iDLRResult]?) {
          // Add your code to do with label recognition results
       }
    }
    

setLabelResultListener

Register a LabelResultListener to obtain video label recognition results.

- (void)setLabelResultListener:(nullable id<LabelResultListener>)listener

Parameters

[in] source A instance of protocol LabelResultListener.

Code Snippet

View the code snippet of setImageSource.

startScanning

Start video label recognition.

- (void)startScanning;

stopScanning

Stop video label recognition.

- (void)stopScanning;

Recognition Method Details

recognizeBuffer

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

- (NSArray<iDLRResult*>*)recognizeBuffer:(iImageData*)imageData templateName:(NSString*)templateName error:(NSError**)error

Parameters

[in] imageData An object of iImageData that represents an image.
[in,out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return value

All results recognized successfully.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    iImageData *imageData = [[iImageData alloc] init];
    //construct imageData
    NSError __autoreleasing *  error;
    NSArray<iDLRResult*>* result = [recognizer recognizeBuffer:imageData templateName:@"" error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    let imageData = iImageData.init()
    let error: NSError? = NSError()
    //construct imageData
    let result = recognizer.recognizeBuffer(imageData:imageData, templateName:"", error:&error)
    

 

recognizeFile

Recognizes text from a specified image file.

- (NSArray<iDLRResult*>*)recognizeFile:(NSString*)name templateName:(NSString*)templateName error:(NSError**)error

Parameters

[in] name A string defining the file path.
[in,out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return value

All results recognized successfully.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing *  error;
    NSArray<iDLRResult*>* result = [recognizer recognizeFile:@"your file path" templateName:@"" error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    let error: NSError? = NSError()
    let result = recognizer.recognizeFile("your file path", templateName:"", error:&error)
    

 

recognizeImage

Recognizes text from a UIImage.

- (NSArray<iDLRResult*>* _Nullable)recognizeImage:(UIImage* _Nonnull)image
                                            error:(NSError* _Nullable * _Nullable)error;

Parameters

[in] image An object of UIImage.
[in, out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return value

All results recognized successfully.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSError __autoreleasing *  error;
    UIImage *image = [[UIImage alloc] init];
    NSArray<iDLRResult*>* result = [recognizer recognizeImage:image withTemplate:@"" error:&error];
    
  2. let recognizer = DynamsoftLabelRecognizer()
    let error: NSError? = NSError()
    let image: UIImage? = UIImage()
    let result = recognizer.recognizeImage(image:image withTemplate:"" error:&error)
    

 

recognizeFileInMemory

Recognizes text from an image file in memory.

- (NSArray<iDLRResult*>* _Nullable)recognizeFileInMemory:(NSData* _Nonnull)fileBytes
                                                   error:(NSError**)error

Parameters

[in] fileBytes The image file in memory.
[in, out] error Input a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return value

All results recognized successfully.

Code Snippet

General Method Details

getVersion

Get version information of SDK.

- (NSString*)getVersion;

Return value

The version information string.

Code Snippet

  • Objective-C
  • Swift
  1. DynamsoftLabelRecognizer *recognizer;
    recognizer = [[DynamsoftLabelRecognizer alloc] init];
    NSString* versionInfo = [recognizer getVersion];
    
  2. let recognizer = DynamsoftLabelRecognizer.init()
    let versionInfo = recognizer.getVersion();
    

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
  • Version 2.2.20
  • Version 2.2.11
  • Version 2.2.10
  • Version 2.2.0
  • Version 2.0.0
  • Version 1.2.1
  • Version 1.2
  • Version 1.0
Change +
© 2003–2023 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support