Initialization Parameters
Parameters passed when launching the OCR Lite SDK. The identity number is required; all other parameters are optional and have sensible defaults.
Parameters
| Parameter | Android (OcrCommunication.ParamKey) | iOS (OcrViewController) | Type | Required | Default |
|---|---|---|---|---|---|
| Identity number | IDENTITY_NUMBER | cnicNumber | String | Yes | — |
| Image width | IMAGE_WIDTH | imageWidth | Int | No | 1000 |
| Scan mode | SCAN_MODE | scanMode | String | No | "frontAndBack" |
| Blur threshold | BLUR_THRESHOLD | blurThreshold | Double (Android) / Float (iOS) | No | 100 |
| Motion threshold | MOTION_THRESHOLD | — | Double | No | 0.5 |
| Show branding | SHOW_BRANDING | showBranding | Boolean | No | false |
| Font | FONT | — | Resource ID | No | SDK default |
| Primary color | PRIMARY_COLOR | — | String (hex) | No | SDK default |
| Skip processing | — | skipProcessing | Boolean | No | false |
Parameter Descriptions
| Parameter | Description |
|---|---|
| Identity number | The CNIC number already known to your app. The SDK reads the number from the back-card barcode and compares it against this value (see distance). Android: a missing value causes a LAUNCH_FAILURE event. iOS: the value defaults to an empty string and no error is raised, so the comparison never matches. |
| Image width | Target width in pixels for captured card images. Both front and back images are saved at this width; the height keeps the card's aspect ratio. Higher values preserve more detail but use more storage; lower values reduce file size. |
| Scan mode | Which sides of the card the user is asked to capture. One of "frontAndBack" (capture front, then back), "frontOnly" (capture front only), or "backOnly" (capture back only). An unknown value falls back to "frontAndBack". The scan mode changes which events are posted and which result fields are present — see Scan mode and results. On Android, the accepted values are also available as OcrCommunication.ScanMode.*.value. |
| Blur threshold | Minimum sharpness score a frame needs to be accepted. A frame whose score falls below this value is rejected as blurred, so higher values are stricter and lower values are more lenient. Recommended range: 50–400. Android: pass a Double (e.g. 100.0); an Int or Float extra is ignored and the default is used. |
| Motion threshold | Android only. Maximum camera movement allowed across recent frames, from 0.0 (still) to 1.0. A frame with more movement than this value is rejected as shaky, so lower values are stricter. Pass a Double. |
| Show branding | Shows the provider logo on the scan screen when true. |
| Font | Android only. Resource identifier (R.font.*) for the heading, subtitle and helper text shown in the OCR interface. Omit to use the SDK default typography. |
| Primary color | Android only. Hex color string (e.g. "#007083") used as the accent color (loading indicator) in the OCR interface. Omit to use the SDK default theme. |
| Skip processing | iOS only. When true, the SDK skips classification and OCR on the first capture and immediately calls handleResponse with the cnicNumber you passed, empty images, documentType .old, distance 0 and an empty extractedData. Use it only to test your integration without a physical card. |
Screen Orientation
The SDK ships a portrait and a landscape scan screen. Both take the same parameters and post the same events.
| Orientation | Android activity | iOS controller |
|---|---|---|
| Portrait | com.fetchsky.ocrlitesdk.OcrActivity | OcrViewController |
| Landscape | com.fetchsky.ocrlitesdk.OcrLandscapeActivity | OcrLandscapeViewController |
The landscape screen runs full screen: the camera fills the display and the area outside the card holder is dimmed. Only the card holder region is classified and saved. For launch steps, see Android: Launch Landscape UI and iOS: Launch Landscape UI.
Present OcrLandscapeViewController modally — do not embed it as a child view controller. It locks the interface to landscape, which works only for a presented controller. Your app must list landscape orientations in its supported interface orientations.
Android
Pass parameters as Intent extras when launching OcrActivity (or OcrLandscapeActivity):
val intent = Intent(this, com.fetchsky.ocrlitesdk.OcrActivity::class.java)
intent.putExtra(OcrCommunication.ParamKey.IDENTITY_NUMBER.value, cnicNumber)
intent.putExtra(OcrCommunication.ParamKey.IMAGE_WIDTH.value, 1000)
intent.putExtra(OcrCommunication.ParamKey.SCAN_MODE.value, OcrCommunication.ScanMode.FRONT_AND_BACK.value) // Optional: "frontAndBack", "frontOnly", "backOnly"
intent.putExtra(OcrCommunication.ParamKey.BLUR_THRESHOLD.value, 100.0) // Optional, must be a Double
intent.putExtra(OcrCommunication.ParamKey.MOTION_THRESHOLD.value, 0.5) // Optional, must be a Double
intent.putExtra(OcrCommunication.ParamKey.SHOW_BRANDING.value, true) // Optional
intent.putExtra(OcrCommunication.ParamKey.FONT.value, R.font.poppins) // Optional
intent.putExtra(OcrCommunication.ParamKey.PRIMARY_COLOR.value, "#007083") // Optional
startActivity(intent)
iOS
Pass parameters to the OcrViewController (or OcrLandscapeViewController) initializer:
let ocrController = OcrViewController(
cnicNumber: "your_cnic_number",
skipProcessing: false,
blurThreshold: 100,
imageWidth: 1000,
showBranding: false,
scanMode: "frontAndBack" // "frontAndBack", "frontOnly", "backOnly"
)