C++ Objective-C++ Objective-C
Switch branches/tags
Nothing to show
Clone or download

README.md

Smart IDReader iOS SDK - Demo version

This is a DEMO version of Smart IDReader iOS SDK by Smart Engines which demonstrates the usage of Smart IDReader library/SDK without actually providing any recognition functionality. Instead, it outputs fake results for document search, field segmentation, recognition and photo image extraction.

Simply open SESmartIDSample.xcodeproj and run it to see the working example. You are free to change the code however you want.

More documentation is available in doc directory.

Free demonstrational applications with full functionality are available at App Store and Google Play.

If you'd like to obtain a trial or full version of Smart IDReader please contact us via:

Test and trial/full versions are only different in static library + configuration files so you wouldn't have to rewrite any code after you're finished integrating Smart IDReader SDK into your application.

Smart IDReader overview

Smart IDReader technology allows you to recognize identity and property rights documents while using video/photo cameras and scanners in mobile, desktop, server and terminal solutions. With this tecnhology you only need to present the document to the camera to let Smart IDReader recognize all required data in 1-3 seconds and then fill them in any file, form or a work sheet.

Key features:

  • Real time document recognition in video stream on mobile devices
  • Recognition of documents in various lighting conditions
  • White label license
  • Security: only device RAM is used, no personal data is being copied or sent over the internet (e.g. for processing on servers)

Supported platforms: iOS, Android, Windows, Linux, MacOS, Solaris and others
Supported programming languages: C++, C, C#, Objective-C, Java, Visual Basic and others
Supported architectures: armv7-v8, aarch64, x86, x86_64, SPARC, E2K and others

Smart IDReader SDK Integration Guide for iOS

1. Configuring Xcode project

  1. Add SESmartID folder containing Objective-C source files to your project, select Create groups in the menu
  2. Add SESmartIDCore/lib folder containing static library to your project, select Create groups in the menu
  3. Add SESmartIDCore/data-zip folder to your project, select Create folder references in the menu
  4. Add SESmartIDCore/include folder to the Header Search Paths in project settings

2. Sample code tutorial

  1. Make your ViewController (SESIDSampleViewController in sample project) conform to <SESIDViewControllerDelegate> and add an instance of SESIDViewController (for example, as a property). Note, that every .m file that includes SESIDViewController.h should be renamed to .mm to enable Objective-C++ compilation for this file.
// SESIDSampleViewController.h

#import "SESIDViewController.h"

@interface SESIDSampleViewController : UIViewController <SESIDViewControllerDelegate>

@property (nonatomic, strong) SESIDViewController *smartIdViewController;

// ...
@end

Another way is to use anonymous category inside implementation file (details: Apple Developer website). The advantage is that you'll need to rename only one file's extension to .mm

// SESIDSampleViewController.h

// left unchanged
@interface SESIDSampleViewController : UIViewController 
// ...
@end

// SESIDSampleViewController.mm

#import "SESIDViewController.h"

@interface SESIDSampleViewController () <SESIDViewControllerDelegate>

@property SESIDViewController *smartIdViewController;

@end
  1. Create and configure SESIDViewController instance
// SESIDSampleViewController.mm

// this might be called from viewDidLoad or similar methods, 
// depends on when do you want recognition core to be initialized.
// could be done in the background thread
- (void) initializeSmartIdViewController {
  // core configuration may take a while so it's better to be done
  // before displaying smart id view controller
  self.smartIdViewController = [[SESIDViewController alloc] init];
  
  // assigning self as delegate to get smartIdViewControlerDidRecognizeResult called
  self.smartIdViewController.delegate = self;
  
  // configure optional visualization properties (they are NO by default)
  self.smartIdViewController.displayDocumentQuadrangle = YES;
}
  1. Implement smartIdViewControllerDidRecognizeResult: method which will be called when SESIDViewController has successfully scanned a document and smartIdViewControllerDidCancel method which will be called when recognition has been cancelled by user
// SESIDSampleViewController.mm

- (void) smartIdViewControllerDidRecognizeResult:(const se::smartid::RecognitionResult &)result {
  // if result is not terminal we'd probably want to continue recognition until it becomes terminal
  // you can also check individual fields using result.GetStringField("field_name").IsAccepted()
  // in order to conditionally stop recognition when required fields are accepted
  if (!result.IsTerminal()) {
    return;
  }
  
  // dismiss Smart ID OCR view controller
  [self dismissViewControllerAnimated:YES completion:nil];
  
  // use recognition result, see sample code for details
  // ...
}

- (void) smartIdViewControllerDidCancel {
  // dismiss Smart ID OCR view controller
  [self dismissViewControllerAnimated:YES completion:nil];
  
  // ...
}

  1. Present SESIDViewController modally when needed, set enabled document types before presenting
// SESIDSampleViewController.mm

- (void) showSmartIdViewController {
  if (!self.smartIdViewController) {
    [self initializeSmartIdViewController];
  }

  // important!
  // setting enabled document types for this view controller
  // according to available document types for your delivery
  // these types will be passed to se::smartid::SessionSettings
  // with which se::smartid::RecognitionEngine::SpawnSession(...) is called
  // internally when Smart ID view controller is presented
  // you can specify a concrete document type or a wildcard expression (for convenience)
  // to enable or disable multiple types
  // by default no document types are enabled
  // if exception is thrown please read the exception message
  // see self.smartidViewController.supportedDocumentTypes,
  // se::smartid::SessionSettings and Smart IDReader documentation for further information
  [self.smartIdViewController removeEnabledDocumentTypesMask:"*"];

  //  [self.smartIdViewController addEnabledDocumentTypesMask:"*"];
  [self.smartIdViewController addEnabledDocumentTypesMask:"mrz.*"];
  //  [self.smartIdViewController addEnabledDocumentTypesMask:"card.*"];
  //  [self.smartIdViewController addEnabledDocumentTypesMask:"rus.passport.*"];
  //  [self.smartIdViewController addEnabledDocumentTypesMask:"deu.id.*"];
  //  [self.smartIdViewController addEnabledDocumentTypesMask:"gbr.drvlic.*"];
  //  ...
  
  // if needed, set a timeout in seconds
  self.smartIdViewController.sessionTimeout = 5.0f;
  
  // presenting OCR view controller
  [self presentViewController:self.smartIdViewController
                     animated:YES
                   completion:nil];
  
  // if you want to deinitialize view controller to save the memory, do this:
  // self.smartIdViewController = nil;
}