Capture Data from Documents

Documentation Menu

This section details the steps necessary to create an iOS application which captures data from a document of a known type, without actually snapping a picture.

How it Works

The fact that we know the type of the document beforehand helps increase recognition accuracy in data capture scenarios. Before starting processing, you select the correct data capture profile to specify the document type. The Real-Time Recognition SDK engine for iOS automatically requests frames from the device camera and processes them, trying to match one of the result schemes corresponding to the selected profile. Every frame requested from the video stream is used to check and refine the already accumulated recognition result, until a scheme is matched and the result stability reaches the required level.

  • A data capture profile is the general type of document you specify to the engine — for example, a bank card or some document with a machine-readable zone (MRZ).
  • A result scheme is a more specific identifier of the recognized document, returned by the engine — for example, an embossed or unembossed bank card, or a specific MRZ (from a passport, visa, travel document, and so on).

Consequently, for some profiles several result schemes are possible — for example, if a country has recently changed the ID form, and both forms are still in circulation. See Supported Documents for the list of supported countries and documents, and Data Capture Profiles for a full specification of all data capture profiles and result schemes.

note Note: Predefined data capture profiles are available only in the extended version of the library.Note that Real-Time Recognition library for iOS also allows you to create custom data capture profiles for documents that are not supported out-of-the-box. See Capture a Custom Data Field for the description of this scenario.

Supported Documents

Real-Time Recognition SDK provides predefined data capture profiles for many types of data, including:

  • machine-readable zone (MRZ) in various documents,
  • international bank account numbers (IBAN),
  • bank card details,
  • data from ID documents:
    • ID cards,
    • passports,
    • driver's licenses, and other.

Recognizing with predefined profiles does not require you to set specific rules or specify regular expressions that should match document fields. You simply specify a data capture profile (the general type of a document) and get recognized data with a more specific result scheme identifying the recognized document.


Real-Time Recognition SDK can automatically detect and recognize the machine-readable zone (MRZ) on various ID documents: passports, ID cards, travel documents, and other. For details on supported MRZ types and recognized data, see MRZ profiles.



For example, when recognizing a 2-line or 3-line MRZ of a passport or an ID document, Real-Time Recognition SDK will recognize and extract the following data:

  • Document type and subtype
  • Document number
  • The country where the document was issued
  • Document holder's first and last name, date of birth, sex and nationality
  • Document holder's personal number
  • Document expiry date


Real-Time Recognition SDK allows to automatically detect and extract international bank account numbers for Germany, France, Spain, and the United Kingdom. IBAN can be extracted from any document.


Bank card

Real-Time Recognition SDK can capture data from debit and credit cards, embossed and unembossed.



When recognizing a bank card, Real-Time Recognition SDK will detect and extract the card number, cardholder's full name, and date of expiry.

ID documents

Real-Time Recognition SDK can automatically extract data from various ID documents such as ID cards, driver's licenses, passports, and other documents from different countries (see Data Capture Profiles for detailed information).


For example, when recognizing the front side of a German ID card, Real-Time Recognition SDK will detect and extract the following data:

  • Document number
  • Document holder's first and last name, nationality, date and place of birth
  • RFID number
  • Document expiry date

The rest of the data in the German ID card scheme is recognized from the back side of the card; note that the data capture profile you specify and the result data scheme are the same for both card sides.


note Note: Before you begin, see Build your application with the OCR library for iOS.

To implement the document data capture scenario, follow these steps:

    1. Implement a delegate conforming to the RTRDataCaptureServiceDelegate protocol. The delegate will handle messages from the data capture service. Here are the recommendations on what its methods should do:
    2. Create an RTREngine object using the sharedEngineWithLicenseData: method. The method requires an NSData object containing your license data. For example, you can use dataWithContentsOfFile: to create a data object, then pass this object to the sharedEngineWithLicenseData: method.
    3. Use the createDataCaptureServiceWithDelegate:profile: method of the RTREngine object to create a background recognition service. Set the type of document you are going to capture using the profile parameter — for example, "IBAN" or "MRZ". The service is created and will further work with this profile (for a full list of available profiles, see Data Capture Profiles).
      Only one instance of the service per application is necessary: multiple threads will be started internally.
    4. We recommend calling the setAreaOfInterest: method to specify the rectangular area on the frame where the document is likely to be found. For example, your application may show a highlighted rectangle in the UI into which the end user will try to fit the page they are capturing. The best result is achieved when the area of interest does not touch the boundaries of the frame but has a margin of at least half the size of a typical printed character.
    5. Implement a delegate that adopts the AVCaptureVideoDataOutputSampleBufferDelegate protocol. Instantiate an AVCaptureSession object, add video input and output and set the video output delegate. When the delegate receives a video frame via the captureOutput:didOutputSampleBuffer:fromConnection: method, pass this frame on to the data capture service by calling the addSampleBuffer: method.
      We recommend using the AVCaptureSessionPreset1280x720 preset for your AVCaptureSession.
      Also note that your video output must be configured to use the kCVPixelFormatType_32BGRA video pixel format.
    6. Process the messages sent by the service to the RTRDataCaptureServiceDelegate delegate object. The result will be delivered via the onBufferProcessedWithDataScheme:dataFields:resultStatus: method:
      • an RTRDataScheme object; use its id property to determine what recognition scheme has been applied to the document (some profiles provide two or more recognition result schemes), and its name property to display a human-readable description to the user, if needed. For details on recognition schemes corresponding to the profile you selected, see Data Capture Profiles.

warning Important! If nil is passed instead of a valid RTRDataScheme object, the data scheme has not yet been matched, which may mean that the document the user is trying to recognize is not a passport. In this case, the results are not usable.

    • an array of RTRDataField objects, each representing one of the fields found and recognized. An RTRDataField object provides the identifier and the human-readable name for the field, the field text, and its location.
    • the result stability status, which indicates if the result is available and if it is likely to be improved by adding further frames. Use it to determine whether the application should stop processing and display the result to the user. We do not recommend using the result until the stability level has reached at least RTRResultStabilityAvailable and the data scheme has been matched.
  1. Save the results for the recognized page. Call the stopTasks method to stop processing and clean up image buffers. The data capture service keeps its configuration settings (such as area of interest) and necessary resources. The processing will start automatically on the new call to the addSampleBuffer: method.

See the description of classes and methods in the API Reference section.