# ID OCR

The ID OCR module extracts text from a captured identity document using [Optical Character Recognition (OCR)](https://developer.incode.com/docs/glossary#ocr)​. It then shows that text to the user to confirm it's correct before the session continues. When enabled, users can correct missing or misread fields.

The [Process ID](https://developer.incode.com/docs/module-process-id) module (`addIdProcess`) runs the server-side processing; ID OCR (`addOcr`) presents the optionally editable review screen to the user. When ID Capture uses `scanStep: .both`, processing runs automatically and a separate `addIdProcess` call is not required.

For an overview of this module and how it works, see [Review OCR Data](https://developer.incode.com/docs/review-ocr-data).

How you use this module depends on your integration pattern. When the app defines the steps in code, you add the module to an `IncdOnboardingFlowConfiguration` as shown below; when the flow is defined in Dashboard, you reference it and let the back end drive the steps. See [Integration Approaches](https://developer.incode.com/docs/ios-flow-configuration).

**Availability:** All variants.

## Add ID OCR

1. Add an [ID Capture](https://developer.incode.com/docs/module-id-scan) module before ID OCR. It runs against a document that has already been captured.
2. Add a [Process ID](https://developer.incode.com/docs/module-process-id) module after ID Capture and before ID OCR.
3. Add the ID OCR module's editable review screen with `addOcr()`:
   ```swift
   // Editable OCR review
   flowConfig.addOcr(isEditable: true, idRank: .firstID)
   ```

ID OCR ships both a v1 and a v2 UI. v2 omits the ID summary screen.

## Configuration Options

Configure the module with `addOcr()`.

| Option       | Type      | Description                             |
| ------------ | --------- | --------------------------------------- |
| `isEditable` | `Bool`    | Lets the user correct extracted values. |
| `idRank`     | `IDRank?` | `.firstID` (default) or `.secondID`.    |

## Result

Register the delegate callbacks to receive results:

```swift
func onOcrCompleted()
```

`OcrResult` (editable review) exposes:

- `photo: UIImage?`, `documentNumber: String?`, `expiryDate: Date?`, and `dateOfBirth: Date?`: `nil` when unavailable.
- `error: IncdError?`: Set when the step fails; otherwise, `nil`.

You can also fetch OCR data headlessly via `IncdOnboardingManager.shared.getUserOCRData(_:completion:)`, which returns an `OmniGetOCRDataResult`.

<br />
