iOS - OCR Module¶
The OCR Module reads data from identity cards and passports through the rear camera. Visual object analysis, hologram detection, face photo reading, MRZ area reading, and verification of visual security elements are carried out by this module.
The OCR module performs a series of control operations such as analyzing visual objects on the identity card (ID or Passport) obtained from images taken by the rear camera, reading data on the face of the identity, and reading data in the MRZ area of the identity.
It is important for the identity to be correctly aligned with the camera during the analysis process. Additionally, the analysis time may vary depending on the device's performance and camera quality. This module offers an effective and reliable solution in identity verification processes.
Warning
When the OCR module is intended to be used, the Core Module must be added to the project. This is necessary to provide the basic functionality of the modules.
Integration Steps of EnQualifyOCR SDK into Project¶
This guide explains how to integrate the EnQualifyOCR SDK into the project. You can achieve quick and easy integration by following the steps below.
What is Core Module¶
Before adding the OCR module, the Core Module must be included in the project. You can visit the Core Module document to learn how to add the core module.
What is EnQualifyOCR¶
EnQualifyOCR is used for executing and managing processes related to identity (ID or Passport) checks and analysis. For details on how to use EnQualifyOcr, you can refer to the EnQualifyOCR Usage Guide section.
Quick Implementation¶
To achieve a quick integration in your project, you can refer to the How to Implement OCR Module? section.
Adding OCR Module to the Project¶
EnQualify iOS SDK can be integrated directly into the project:
- Method: Add the SDK by embedding it directly into the project as xcframework and loading the required dependencies through cocoapods.
// target 'MySampleProject' do
use_frameworks!
pod 'TensorFlowLiteSwift' # Identity detection
pod 'TensorFlowLiteSwift/Metal' # Identity detection
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = ""
config.build_settings['VALID_ARCHS'] = "arm64 x86_64"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.5'
config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
end
end
end
Explanation of Build Settings After Installation¶
BUILD_LIBRARY_FOR_DISTRIBUTION = YES:¶
Ensures that the framework is built for distribution, allowing it to be used as a binary or shared framework in other projects. This is particularly useful when creating XCFrameworks.
EXPANDED_CODE_SIGN_IDENTITY = "":¶
Clears the Code Signing Identity; ensuring that a specific certificate is not used during the build process.
CODE_SIGNING_REQUIRED = NO:¶
Disables the code signing requirement during the build process. This is useful in situations where signing is not required, such as during testing.
CODE_SIGNING_ALLOWED = NO:¶
Ensures that code signing is completely disabled.
EXCLUDED_ARCHS[sdk=iphonesimulator*] = "":¶
Removes all excluded architectures for the iPhone simulator. This setting ensures compatibility during the build process.
VALID_ARCHS = "arm64 x86_64":¶
Specifies valid architectures for the build. Here, arm64 (M Series) is used for Macs with M series chips and x86_64 is used for Macs with Intel processors.
IPHONEOS_DEPLOYMENT_TARGET = 14.0:¶
Sets the minimum iOS version that the application or framework supports. This ensures compatibility with devices running iOS 14.0 and later.
ONLY_ACTIVE_ARCH = YES:¶
Limits the build process to only the architecture of the active build device or simulator. This can speed up build times during development.
XCFrameworks¶
- To directly integrate the EnQualify SDK into your project, you can add the base SDK files
OCRModule.xcframework,NFCModule.xcframework,FaceModule.xcframework,CoreModule.xcframework, andVideoCallModule.xcframeworkdirectly to your project files. - Alternatively, if you have already copied the XCFrameworks into your project, you can go to Project Settings > General to select Embed and Sign for adding these frameworks to your project.
- For the dependencies of the EnQualify SDK added in this way, you need to include them in your project with version numbers specified in the "podspec" file or provided by the supplier.
How to Implement OCR Module?¶
1. Adding Modules¶
1.1 Implementation of Core Module¶
Before using the EnQualifyOCR Module, the Core Module must be included in the project. If you haven't added it yet, you can refer to the Core Module documentation for details.
1.2 Adding OCR Module to the Project¶
You can find the necessary instructions for OCR Module integration under the Adding OCR Module to Project heading. Follow these steps to include the OCR module in your project.
2. Permissions¶
2.1 Adding Camera Permission to Info.plist File¶
First, you need to add camera permission to the Info.plist file. This allows your application to access the camera hardware.
2.2 Requesting Runtime Permission¶
Camera permission is requested within the initialize function.
EnQualifyOCR.initialize(_ sender: Any?,
sessionModel: SessionModelOCR? = nil,
baseModel: BaseModelOCR? = nil)
If camera permission is not granted, the initializeFailed(with key: CustomNSError) delegate is triggered. If permission is granted, the initializeCompleted(moduleName: String) delegate is triggered.
3. Adding EnQualifyOCRDelegate Interface¶
EnQualifyOCRDelegate contains the necessary delegate methods to manage OCR operations. By implementing this interface, you can listen to and manage events related to OCR. For detailed information, refer to the EnQualifyOCR Usage Guide section.
3.1 Adding EnQualifyOCRDelegate to Class¶
3.2 Overriding Delegate Functions¶
class ViewController: EnQualifyOCRDelegate {
func hologramCheckVerified() {}
func idDocTypeCheckVerified(isFront: Bool, isHologramCheckEnable: Bool) {}
func idDocFrontCompleted(isBackSideAvailable: Bool) {}
func idDocBackCompleted() {}
func idDocCompleted() {}
func idDocFailed(error: EnQualifyOcrError) {}
func cameraSetupFailed(error: EnQualifyOcrError) {}
func initializeCompleted(moduleName: String) {}
func initializeFailed(with key: CustomNSError) {}
func deinitializeCompleted(moduleName: String) {}
func sessionCloseCompleted(status: String) {}
func sessionCloseFailed() {}
func tokenCreateCompleted() {}
func tokenCreateFailed() {}
func integrationAddCompleted() {}
func integrationAddFailed() {}
func sessionAddFailed() {}
func settingGetFailed() {}
func signingSetCompleted() {}
func signingCompleted() {}
func signingSetFailed(error: String) {}
}
4. Initializing EnQualifyOCR and Token, Settings, and Session Operations¶
Note
Before initialization of core;
- EnQualifyOCRDelegate methods must be added to the delegate field of the UIViewController where it will be used.
- SessionModelOCR is a model that contains the parameters to be used to initialize the OCR and this model should be added to the relevant field during the initialization process. For detailed information, please refer to the SessionModelOCR section.
- BaseModelOCR is a model that contains the certificate and basic URL information required for OCR and this model should be added to the relevant field during the initialization process. For detailed information, please refer to the BaseModelOCR section.
Before starting the OCR operations, the EnQualifyOCR class needs to be initialized. This process ensures the initialization of the required token, settings, and session operations. It is also important to inform the user that preparations for the OCR operation are complete and then initiate the process.
func initialize(_ sender: Any?,
sessionModel: SessionModelOCR? = nil,
baseModel: BaseModelOCR? = nil) {
Parameters¶
| Parameter | Type | Description |
|---|---|---|
delegate | Any? | Determines which UIViewController the application will be used in. |
sessionModel | SessionModelOCR | Contains the session information to be used during the OCR operation. |
baseModel | BaseModelOCR | This is the model that carries the basic data in the verification process. |
After EnQualifyOCR is initialized, an EnQualifyOCR instance is created and the necessary processes to create the token, settings, and session are initiated. After initialization, the token, settings, and session are managed by the SDK.
After the EnQualifyOCR instance is created, the following steps are carried out in order:
-
Token Creation
-
EnQualifyOCR initiates the token creation process.
- If an error occurs during the token creation process, the tokenCreateFailed delegate is triggered.
- When the token is successfully created, the process moves to the next step, which is the session operation.
-
Starting the Session Process
-
After the token is successfully obtained, the session initialization process begins.
- If an error occurs during session initialization, the sessionAddFailed delegate is triggered.
- When the session operation is successfully completed, the SDK will have established a connection with the backoffice and will be ready to initiate the process.
-
Retrieving Settings
-
Once the session is successfully created, the process of retrieving the settings defined on the backoffice is initiated.
- If an error occurs during this process, the settingsGetFailed delegate is triggered, and the error message is communicated to the client.
- When the settings are successfully retrieved, the SDK configures the relevant settings and initiates the session operation.
-
Completing the Process
-
When all steps are completed without issues, the initializeCompleted delegate is triggered. This indicates that the SDK has been successfully initialized and is ready for OCR operations.
This process is designed to ensure that EnQualifyOCR functions robustly. Possible errors are communicated to the client or user through the relevant delegates, facilitating the necessary actions to be taken.
5. Starting the OCR Process¶
In this section, we explain step by step how to start and manage OCR processes.
5.1 User Information¶
Before starting the OCR process, it is recommended to inform the user. For this, an OCRInfo page can be created.
This page provides the user with information about the OCR process and enhances the experience.
5.2 OCR Processes¶
For detailed information regarding the OCR functions and delegates, you can refer to the EnQualifyOCR User Guide.
- idDocTypeCheckStart(in vc: UIViewController, isFront: Bool)
- hologramCheckStart(in vc: UIViewController)
- idDocFrontStart(in vc: UIViewController, withVisualAnalysis: Bool)
- idDocBackStart(in vc: UIViewController, withVisualAnalysis: Bool)
- idDocComplete(withDelay delay: TimeInterval = 0.0)
- sessionClose(finished: Bool)
5.2.1 Performing Identity Type Recognition¶
The function idDocTypeCheckStart is used to initiate the identity type recognition process. This process is managed by the EnQualifyOCR API and is called as follows.
Delegate Mechanism
When the identity type recognition process is successfully completed, the delegate idDocTypeCheckVerified(isFront:isHologramCheckEnable:) is triggered. The isFront parameter indicates the identity face, and the isHologramCheckEnable parameter specifies whether the hologram check is enabled. The flow for the front side is identity type recognition → hologram check → identity front face scanning. If the hologram check is not enabled, the flow proceeds directly to the identity front face scanning step.
5.2.2 Performing Hologram Detection on the Identity Front Face¶
To initiate the detection process for the hologram found on the front face of the identity, the function hologramCheckStart is used. This process is managed by the EnQualifyOCR API and is called as follows.
Delegate Mechanism
When the hologram detection process on the identity front face is successfully completed, the delegate hologramCheckVerified is triggered. After this delegate, the flow continues to the identity front face scanning process.
5.2.3 Performing Scanning of the Identity Front Face¶
To initiate the scanning process of the identity front face, the function idDocFrontStart is used. This process is managed by the EnQualifyOCR API and is called as follows.
Delegate Mechanism
When the identity front face scanning process is successfully completed, the delegate idDocFrontCompleted(isBackSideAvailable: Bool) is triggered. The isBackSideAvailable parameter indicates whether the back side of the identity can be scanned. Within this delegate, other tasks to be completed after the process can be handled.
5.2.4 Performing Scanning of the Identity Back Face¶
To initiate the scanning process of the identity back face, the function idDocBackStart is used. This process is managed by the EnQualifyOCR API and is called as follows.
Delegate Mechanism
When the identity front face scanning process is successfully completed, the delegate idDocBackCompleted is triggered. Within this delegate, other tasks to be completed after the process can be handled.
5.2.5. Notifying Completion of the Identity Detection (OCR) Flow¶
When all identity detection steps are completed, the function idDocComplete is used to notify the SDK that the processes have ended. This function also stops the analyses taken from the camera, concludes the process, and initiates the submission of the read data to the back office.
When the submission of the read data to the back office is completed, the delegate idDocCompleted is triggered.
5.2.6. Closing the SDK Session¶
Closing the Session
To close the session used by SDKs for communication with backend services, the function sessionClose is used. This process is managed by the EnQualifyCore API, but is called by each SDK as follows.
Warning
After the session is closed by an SDK, if it is to be reused, the SDK must be reinitialized.
Delegate Mechanism
When the session closing process is successfully completed, the delegate sessionCloseCompleted is triggered. Within this delegate, other tasks to be completed after the process can be handled.
If the session closing process fails, the delegate sessionCloseFailed is triggered. Within this delegate, other tasks to be completed after the process can be handled.
5.2.7 Replace Sound¶
The replaceSound function is used to play another sound file instead of a specific sound file within the SDK or to prevent the related sound from being played.
This feature is specifically designed to provide dynamic sound control in certain situations during user flow (for example, when reaching a specific number of errors or changing the flow direction).
Parameters¶
| Parameter | Type | Description |
|---|---|---|
currentVoice | [String] | The name(s) of the current sound(s) to be replaced or prevented from playing. This parameter comes as an array because, for example, in OCR, NFC, or Face phases, multiple error types (such as timeout, fail, etc.) can be associated with different sounds. |
newVoice | String | The name of the new sound to be played instead of the sound(s) specified in the currentVoice parameter. If an empty ("") string is provided, the SDK skips this step silently and does not produce any sound. |
Usage Scenario¶
For example, if there is a scenario in your user flow that redirects to a video call after three failed OCR attempts, the sound "fail_ocr_voice" can be played on the first two failed attempts.
However, if you want the sound "go_to_videocall" to play on the third error instead of "fail_ocr_voice", you can use the replaceSound function as follows:
Note:¶
To display the read data on the results page, you can refer to the CustomerIdentity section. This section ensures that the read data is presented to the user clearly and understandably.
EnQualifyOCR User Guide¶
The EnQualifyOCR module is used to perform a series of control operations such as analyzing visual objects on the identity card (ID or Passport) from images captured by the rear camera, hologram analysis, reading data on the identity's face, and reading data in the MRZ area of the identity. Below, the relevant functions and delegates are explained.
Functions¶
initialize(...) : EnQualifyOCR
func initialize(_ sender: Any?,
sessionModel: SessionModelOCR? = nil,
baseModel: BaseModelOCR? = nil) {
To manage identity recognition operations, EnQualifyOCR must be initialized. When this API is initialized;
- sender: Any** :** Determines which class will handle the application's delegate methods.
- sessionModel: SessionModelOCR : Contains the session information to be used during the OCR operation.
- baseModel: BaseModelOCR : The model that carries the basic data during the verification process.
can be provided.
Since the API operates in a singleton structure, operations are performed through the same instance throughout the application session. This saves resources and increases process consistency. The initialization process automatically performs the following actions:
- Token creation
- Settings configuration
- Session start If there is an existing session, a new session is not created, and the existing session continues to be used.
Delegates¶
Token / Session / Settings Delegates¶
tokenCreateCompleted()
- Triggered when the token creation process is completed.
- If there is an existing token, it will not be recreated, and the existing token will be used.
tokenCreateFailed()
- Triggered if an error occurs while creating the token.
settingsGetFailed()
- Triggered if an error occurs while fetching the settings information.
sessionAddFailed()
- Triggered if an error occurs while creating a new session.
sessionCloseCompleted(status: String)
- Triggered when the session is closed.
-
Parameter:
-
status: The status information of the session when it is closed.
sessionCloseFailed()
- Triggered if an error occurs while closing the session.
integrationAddCompleted()
- Triggered when the request made to the IntegrationAdd service is completed.
integrationAddFailed()
- Triggered if an error occurs when a request is made to the IntegrationAdd service.
OCR Callbacks
IDDocFailed(error: EnQualifyOcrError)
public enum EnQualifyOcrError: Error {
case timeout(OCRState, String)
case idDocSave(String)
case idDocFailed(OCRState, String)
case cameraSetup(String)
case idDocConcealSave(String)
case luminosityFailed(String)
case crossCheckFailed(String)
public var ocrErrorDescription: String {
switch self {
case .timeout(let state, let message):
return "Timeout during \(state) state with \(message)"
case .idDocSave(let message):
return "Error while saving id document"
case .idDocFailed(let state, let message):
return "Authentication failed during \(state). Please try again."
case .cameraSetup(let message):
return "Camera setup failed: \(message)"
case .idDocConcealSave(let message):
return "Error while saving concealed id document: \(message)"
case .luminosityFailed(let message):
return "Luminosity check failed: \(message)"
case .crossCheckFailed(let message):
return "Cross-check failed: \(message)"
}
}
}
- Triggered when an error occurs or the identification process fails.
-
Parameters:
-
state:The OCR phase. ocrErrorDescription: Error message.
idDocTypeCheckVerified(isFront: Bool, isHologramCheckEnable: Bool)
- Triggered when the identity type is successfully determined after the idDocTypeCheckStart function is called to detect the identity type. The
isFrontparameter indicates the front of the identity, and theisHologramCheckEnableparameter indicates whether the hologram check is enabled. The workflow continues with the relevant identity scanning or hologram check step based on the parameter values.
hologramCheckVerified()
- Triggered when the hologram is successfully detected after the hologramCheckStart function is called to detect the hologram on the front of the identity.
idDocFrontCompleted(isBackSideAvailable: Bool)
- Triggered when the process is successfully completed after calling the idDocFrontStart function for recognizing the front of the identity and reading the data on it. The
isBackSideAvailableparameter indicates whether the back of the identity can be scanned.
idDocBackCompleted()
- Triggered when the process is successfully completed after calling the idDocBackStart function for recognizing the back of the identity and reading the data in the MRZ area.
idDocComplete(withDelay: 0.0)
- When all identity detection steps are completed, the idDocComplete function is used to inform the SDK that the processes have ended. This function also stops the analyses from the camera, terminates the process, and starts the process of sending the read data to the back office.
-
Parameter:
-
withDelay: Determines how long the camera session should delay before closing.
idDocCompleted()
- Triggered after the identity recognition process is successfully completed and the read data is successfully sent to the back office.
Models¶
BaseModelOCR¶
BaseModelOCR is the data model that contains certification information and server connection address used in verification processes. Signaling and MAPI (Mobile Application Programming Interface) certificates are stored in both file (.der) format and Base64 text format.
Model¶
class BaseModelOCR(
var signallingCertificateList: [String]? = nil
var mapiCertificateList: [String]? = nil
var signallingCertificateBase64List: [String]? = nil
var mapiCertificateBase64List: [String]? = nil
var signallingCertificatePublicKeyList: [String]? = nil
var mapiCertificatePublicKeyList: [String]? = nil
var baseURL: String? // Functionally required field
var locale: String? = nil
var mobileUser: String? = nil
var countryCode: String? = nil
)
Properties¶
| Property | Type | Description |
|---|---|---|
signallingCertificateList | [String]? | Array of signaling certificates. Certificates are stored in text format. |
mapiCertificateList | [String]? | Array of MAPI certificates. Certificates are stored in text format. |
signallingCertificateBase64List | [String]? | Encoded forms of signaling certificates in Base64 format. |
mapiCertificateBase64List | [String]? | Encoded forms of MAPI certificates in Base64 format. |
signallingCertificatePublicKeyList | [String]? | Array of public key values for signaling certificates. |
mapiCertificatePublicKeyList | [String]? | Array of public key values for MAPI certificates. |
baseURL | String? | The base server address used for API verification processes. Not required by the Swift compiler; however, functionally necessary for runtime and network operations. |
locale | String? | Determines the language of the voice guidance messages. |
mobileUser | String? | Represents the anonymous user information used during authorization. |
countryCode | String? | Used to obtain region-specific data when verification is done for a specific country or region. |
Usage Example¶
In the example below, a BaseModelOCR object is created, defining the certificate information and server address:
var baseModelOCR = BaseModelOCR(
signallingCertificateList: ["AI_CERT_1", "AI_CERT_2"],
mapiCertificateList: ["MAPI_CERT_1", "MAPI_CERT_2"],
signallingCertificateBase64List: ["QUlDRVJU...", "Q0VSVF8y..."],
mapiCertificateBase64List: ["TU9SRSB...", "Q0VSVF8z..."],
signallingCertificatePublicKeyList: ["SIGNALLING_PUBLIC_KEY_1", "SIGNALLING_PUBLIC_KEY_2"],
mapiCertificatePublicKeyList: ["MAPI_PUBLIC_KEY_1", "MAPI_PUBLIC_KEY_2"],
baseURL: "API_SERVER_URL",
locale: "tr",
mobileUser: "mobile",
countryCode: "TUR"
)
Explanations¶
- Certificates (
signallingCertificateList,mapiCertificateList): Certificate information is stored in plain text format. - Base64 Certificates (
signallingCertificateBase64List,mapiCertificateBase64List): Forms of the certificates converted to Base64 format. - Public Key Lists (
signallingCertificatePublicKeyList,mapiCertificatePublicKeyList): Contains public key values for signaling and MAPI certificates. - Server Connection (
baseURL): The server URL where verification or certification processes will be performed. The Swift type isString?; it is not required by the compiler, but it is functionally necessary for runtime and network operations.
SessionModelOCR¶
SessionModelOCR is the data model that contains user and identity information during a call session. It includes call type, user details, identity information, and additional parameters related to the session.
Model Definition¶
class SessionModelOCR(
var callType: String?,
var name: String? = nil,
var surname: String? = nil,
var phone: String? = nil,
var email: String? = nil,
var identityType: String? = nil,
var identityNo: String? = nil,
var reference: String?,
var canAutoClose: NSNumber?,
var _continue: NSNumber?,
var category: String? = nil,
var taxNumber: String? = nil,
var businessReference: String? = nil,
var handicapped: NSNumber
Features¶
| Feature | Type | Description |
|---|---|---|
callType | String? | Parameter indicating the call type (e.g., "NewCustomer"). Not enforced by the Swift compiler; however, it is functionally necessary for runtime and network operations. |
name | String? | User's name. Can be empty. |
surname | String? | User's surname. Can be empty. |
phone | String? | User's phone number. Can be empty. |
email | String? | User's email address. Can be empty. |
identityType | String? | Identity type (e.g., "I" (TC Identity Card), "P" (Passport)). Can be empty. |
identityNo | String? | User's identity number. Can be empty. |
reference | String? | Reference ID for the session. Not enforced by the Swift compiler; however, it is functionally necessary for runtime and network operations. |
canAutoClose | NSNumber? | Determines whether the session can auto-close. Can be given values 0 or 1. |
_continue | NSNumber? | Determines whether the session should continue. Can be given values 0 or 1. |
category | String? | Category that the session belongs to. Can be empty. |
taxNumber | String? | Tax number belonging to the user. Can be empty. |
businessReference | String? | Reference information related to the business. Can be empty. |
handicapped | NSNumber? | Flag indicating whether the user is disabled. Can be given values 0 or 1. |
Usage Example¶
In the example below, a SessionModelOCR object is created to define the session information:
var sessionModelOCR = SessionModelOCR(
callType: "NewCustomer",
name: "Enqura",
surname: "Information",
phone: "+905551234567",
email: "enqualifyplus@enqura.com",
identityType: "TC. Kimlik Kartı",
identityNo: "12345678901",
reference: "REF123456",
canAutoClose: 1,
_continue: 1,
category: "category",
taxNumber: "9876543210",
businessReference: "COMPANY",
handicapped: 0
)
Explanations¶
-
Functionally Required Fields: The
callType,reference, andbaseURLparameters are of typeString?. The Swift compiler does not require these fields; however, they must be provided with functional values for runtime and network operations. ThecanAutoClose,_continue, andhandicappedfields must be specified in the initializer. -
User Information: Fields like
name,surname,phone,emailare optional. - Identity Information:
identityTypeandidentityNocan be used in NFC verification or identity verification processes. - Disability Status: The
handicappedfield indicates whether the user has special needs by providing a value of0or1. - Auto Closure: The
canAutoClosefield can accept values0or1to enable automatic closure of the session when certain conditions are met. - Continuation Status: The
_continuefield indicates whether the session is a continuing operation by accepting values0or1.
CustomerIdentity¶
This class represents the data model where data read from a document (such as an identity card or passport) is stored.
Model¶
@objc public class CustomerIdentity: NSObject {
@objc public static let shared = CustomerIdentity()
@objc public func getIdentityType() -> String? {}
@objc public func getIssuingState() -> String? {}
@objc public func getDocumentNumber() -> String? {}
@objc public func getIdentityNumber() -> String? {}
@objc public func getDateOfBirthDay() -> String? {}
@objc public func getExpiryDate() -> String? {}
@objc public func getNationality() -> String? {}
@objc public func getSurname() -> String? {}
@objc public func getName() -> String? {}
@objc public func getFrontGender() -> String? {}
@objc public func getBackGender() -> String? {}
@objc public func getFrontImage() -> ConfidenceItem? {}
@objc public func getBackImage() -> ConfidenceItem? {}
@objc public func getPersonImage() -> ConfidenceItem? {}
@objc public func getHoloFrontImage() -> ConfidenceItem? {}
@objc public func getFrontIdentityNumber() -> String? {}
@objc public func getFrontDateOfBirthDay() -> String? {}
@objc public func getTuri1fFlag() -> ConfidenceItem? {}
@objc public func getTuri1fMli() -> ConfidenceItem? {}
@objc public func getTuri1fSignature() -> ConfidenceItem? {}
@objc public func getTuri1fHologram1() -> ConfidenceItem? {}
@objc public func getTuri1bBarcod() -> ConfidenceItem? {}
@objc public func getTuri1bChip() -> ConfidenceItem? {}
@objc public func getTuri1bICAOlogo() -> ConfidenceItem? {}
}
Usage Example¶
In the example below, data is retrieved from the model and displayed on the OCR results page after the OCR process:
func setCustomerChipValues() {
let customerCard = CustomerIdentity.shared
chipData[0].value = customerDoc.getName() ?? ""
chipData[1].value = customerDoc.getSurname() ?? ""
chipData[2].value = (customerDoc.getFrontDateOfBirthDay() ?? "").convertDateFormat()
chipData[3].value = customerDoc.getIdentityNumber() ?? ""
chipData[4].value = customerDoc.getDocumentNumber() ?? ""
chipData[5].value = customerDoc.getFrontGender() ?? ""
chipData[6].value = customerDoc.getBackGender() ?? ""
chipData[7].value = customerDoc.getNationality() ?? ""
chipData[8].value = (customerDoc.getExpiryDate() ?? "").convertDateFormat()
ocrImageData.holoPage = customerDoc.getHoloFrontImage()?.image ?? UIImage()
ocrImageData.frontPage = customerDoc.getFrontImage()?.image ?? UIImage()
ocrImageData.backPage = customerDoc.getBackImage()?.image ?? UIImage()
}
Touch Test¶
The touch test process is initiated after successfully completing the OCR step for the relevant identity.
How to Implement the Touch Test?¶
1. Adding Modules¶
Adding the OCR Module to the Project¶
Touch test should not be used before the OCR Module is included in the project. If you have not added it yet, you can refer to the OCR Module documentation for details.
2. Adding the EnQualifyOCRDelegate Interface¶
EnQualifyOCRDelegate contains the necessary delegate methods to manage the touch test. By implementing this interface, you can listen to and manage events related to the touch test. For detailed information, you can check the Touch Test User Guide section.
2.1 Adding EnQualifyOCRDelegate to the Class¶
2.2 Override Delegate Functions¶
class ViewController: EnQualifyOCRDelegate {
// Other delegate methods added for OCR
// ...
func frontCrescentConcealVerified() {}
func frontMLIConcealVerified() {}
func frontSignatureConcealVerified() {}
func backOVIConcealVerified() {}
func idDocConcealCompleted() {}
func idDocConcealFailed() {}
}
3. Managing Touch Test¶
In this section, we explain step by step how to manage Touch test procedures.
3.1 User Notification¶
Before starting the touch test, it is recommended to inform the user. For this purpose, a Touch Test Info page can be created.
This page provides the user with information about the touch test procedure and enhances their experience.
3.2 Touch Test Procedures¶
For detailed information about touch test functions and delegates, you can check the Touch Test User Guide.
- performFrontCrescentConceal(in vc: UIViewController)
- performFrontMLIConceal(in vc: UIViewController)
- performFrontSignatureConceal(in vc: UIViewController)
- performBackOVIConceal(in vc: UIViewController)
- idDocConcealComplete(withDelay delay: TimeInterval)
3.2.1 Performing Front Crescent Touch Operation¶
To initiate the front touch operation, the performFrontCrescentConceal function is used. This operation is managed by the EnQualifyOCR API and is called as follows.
Delegate Mechanism
When the Front Crescent Touch operation is successfully completed, the frontCrescentConcealVerified delegate is triggered. In this delegate, other operations that need to be performed afterward can be handled.
3.2.2 Performing Front MLI (Ghost Image) Touch Operation¶
To initiate the front MLI touch operation, the performFrontMLIConceal function is used. This operation is managed by the EnQualifyOCR API and is called as follows.
Delegate Mechanism
When the Front MLI touch operation is successfully completed, the frontMLIConcealVerified delegate is triggered. In this delegate, other operations that need to be performed afterward can be handled.
3.2.3 Performing Front Signature Touch Operation¶
To initiate the front signature touch operation, the performFrontSignatureConceal function is used. This operation is managed by the EnQualifyOCR API and is called as follows.
Delegate Mechanism
When the front signature touch operation is successfully completed, the frontSignatureConcealVerified delegate is triggered. In this delegate, other operations that need to be performed afterward can be handled.
3.2.4 Performing Back Optical Variable Ink Touch Operation¶
To initiate the back optical variable ink touch operation, the performBackOVIConceal function is used. This operation is managed by the EnQualifyOCR API and is called as follows.
Delegate Mechanism
When the back optical variable ink touch operation is successfully completed, the backOVIConcealVerified delegate is triggered. In this delegate, other operations that need to be performed afterward can be handled.
3.2.5. Notifying Completion of Touch Test Flow¶
Once all touch test steps are completed, the idDocConcealComplete function is used to notify the SDK that the processes have ended. This function also stops the analyses performed by the camera, concludes the processing, and initiates the submission process of the read data to the backoffice.
When the data read from the backoffice submission is completed, the idDocConcealCompleted delegate is triggered.
Touch Test User Guide¶
The touch test is used to analyze whether the visual objects on the identity card are being covered or not by the user, using images captured through the rear camera from the EnQualifyOCR module. The touch test process is activated after the OCR step for the corresponding identity has been successfully completed. Below, the relevant functions and delegates are explained.
Delegates¶
OCR Callbacks
idDocConcealFailed()
- Triggered when an error occurs in the touch test processes or if it fails.
frontCrescentConcealVerified()
- Triggered when the front crescent item is successfully concealed following the invocation of the performFrontCrescentConceal function for touch testing purposes.
frontMLIConcealVerified()
- Triggered when the front MLI (Ghost Image) item is successfully concealed following the invocation of the performFrontMLIConceal function for touch testing purposes.
frontSignatureConcealVerified()
- Triggered when the front signature item is successfully concealed following the invocation of the performFrontSignatureConceal function for touch testing purposes.
backOVIConcealVerified()
- Triggered when the back optical variable ink item is successfully concealed following the invocation of the performBackOVIConceal function for touch testing purposes.
idDocConcealComplete(withDelay: 0.0)
- When the touch test steps are completed, the idDocConcealComplete function is used to notify the SDK that the processes have ended. This function also stops the analyses performed by the camera, concludes the processing, and initiates the submission process of the read data to the backoffice.
-
Parameter:
-
withDelay: Determines how long the camera session should be delayed before closing.
idDocConcealCompleted()
- Triggered after the touch test transaction is successfully completed and the read data is successfully submitted to the backoffice.