Usage

Introduction

ElkycDocumentSDK will help you to scan document, barcode, QR code, or take a person selfie, the goal is to build easy steps which you can run and get the result to your system or in your application.

Don't forget that framework depends on ElkycCoreSDK. Please read the documentation there first.

The whole process is going synchronously from the first to the last step. During the process, data will be sent to our or your backend. The process will stop if any of the steps will return an error.

Before starting using library you should always check for database update. If you don't want to download and update database you can add it manually to your project and skip this step. Use DocumentReader class for this. Note: you can pass a databaseID parameter if needed, by default DocumentReader downloading full database.

DocumentReader.loadDatabase { progress in
    print("\(Float(progress.fractionCompleted))")
} completion: { _, _ in

}

Add Documents Database manually

This option is perfect for those types of apps that need to work offline. Follow next steps:

  1. Request access and download Database file.

  2. Add file db.dat to the project and link it to required target (do not modify file name).

Once you build and run the project, database will be located inside the application and processed by the SDK automatically.

DocumentResult

DocumentResult is a struct returned by DocumentImageScan, DocumentScan, UkrPassportScan, CaptureWithConfirm and RfidDocumentScan steps. This structure contains all information regarding document scan.

public struct DocumentResult: Encodable {
    public enum DocumentStepType: String, Encodable {
        case document = "DOCUMENT_CAPTURE"
        case documentRfid = "DOCUMENT_RFID_CAPTURE"
        case barCode = "BARCODE_CAPTURE"
        case creditCard = "CREDIT_CARD_CAPTURE"
    }

    public let elapsedTime: Int
    public let elapsedTimeRFID: Int
    public let overallResult: Int
    public let morePagesAvailable: Int
    public let types: [DocType]
    public let graphics: [DocumentGraphic]
    public let texts: [DocumentText]
    public let stepType: DocumentStepType
    public let hasRFID: Bool
}
  • elapsedTime - time passed during the scan

  • elapsedTimeRFID - time passed during RFID scan

  • overallResult - validation result, CheckResult

  • morePagesAvailable - if document has more pages to scan

  • types - information about document type

  • graphics - information about images in the document or at RFID

  • texts - information about text scanned visually, from MRZ or RFID

  • stepType - document type, mostly used internally

  • hasRFID - boolean indicated if this document has rfid or not

DocType

DocType struct represents a document type.

public struct DocType: Encodable {
    public let name: String?
    public let pageIndex: Int
    public let hasMRZ: Bool
    public let icao: String?
    public let type: Int
    public let year: String?
    public let format: Int
}
  • name - document name

  • pageIndex - an index of the document page whence results are received

  • hasMRZ - flag for MRZ presence on a document

  • icao - document issuing country ICAO code

  • type - document type, DocType

  • year - document issue year

  • format - document format, DocFormat

DocumentGraphic

DocumentGraphic struct represents a document image.

public struct DocumentGraphic: Encodable {
    public let fieldType: Int
    public let sourceType: Int
    public let pageIndex: Int
    public let image: String
    public let originalImage: UIImage
}
  • fieldType - graphic field logical type, GraphicFieldType

  • sourceType - identifies zone whence data is extracted, ResultType

  • pageIndex - an index of the document page whence the graphic field is extracted

  • image - an base64 encoded image

  • originalImage - an image

DocumentText

DocumentText struct represents a document text field.

public struct DocumentText: Encodable {
    public let status: Int
    public let fieldType: Int
    public let lcid: Int
    public let values: [DocumentTextValue]
}
  • status - textual field check result, CheckResult

  • fieldType - textual field logical type, FieldType

  • lcid - ID of language-culture to differentiate one field of the same type from another (for example Belarus Passport Page # 31 – Belarusian and Russian fields of the same type), Lcid

  • values - an array of values

DocumentTextValue

DocumentTextValue struсt represents a document text value

public struct DocumentTextValue: Encodable {
    public let pageIndex: Int
    public let probability: Int
    public let value: String
    public let validity: Int
    public let sourceType: Int
    public let comparison: [Int: Int]
}
  • pageIndex - an index of the document page whence the textual field is extracted

  • probability - textual field recognition probability (0 - 100, %)

  • value - a value

  • validity - verification result, FieldVerificationResult

  • sourceType - identifies zone whence data is extracted, ResultType

  • comparison - a comparison result of a textual field values where the key is one of ResultType values and the value is one of FieldVerificationResult values

Last updated