> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getlimina.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Guide for OCR Modes Available with Limina DEID Container

> Explore the best OCR modes including Standard OCR, Azure Computer Vision OCR, Azure Document Intelligence, and Hybrid OCR compatible with Limina DEID container for efficient document processing and redaction.

<Info>
  If you are using the Limina container, the OCR system is configured through environment variables. For detailed instructions, refer to the sections on [Environment Variables](/configuration-and-operations/container-management/environment-variables) and the [Guide for Integrating Limina DEID container with Azure OCR](/configuration-and-operations/advanced-features/azure-ocr). You can configure more than one OCR systems.

  Once configured, the OCR system can be selected either via environment variables or directly in the [REST request](/latest/process-files-uri/).
</Info>

This guide outlines the different Optical Character Recognition (OCR) modes available for processing documents and images. Each mode has its unique application, depending on the document's nature and the specific requirements for text extraction.

<Columns cols={2}>
  <Card href="#standard-ocr" icon="list" horizontal>
    Standard OCR
  </Card>

  <Card href="#azure-computer-vision-ocr" icon="list" horizontal>
    Azure Computer Vision OCR
  </Card>

  <Card href="#azure-document-intelligence" icon="list" horizontal>
    Azure Document Intelligence
  </Card>

  <Card href="#hybrid-ocr" icon="list" horizontal>
    Hybrid OCR
  </Card>
</Columns>

## Standard OCR

| Attribute | Rating |
| --------- | ------ |
| Accuracy  | Medium |
| Speed     | High   |
| Cost      | Low    |

Standard OCR is built into the container and is the default OCR engine. It's designed for high-performance text recognition in images and digital documents, focusing on efficiency and accuracy for standard printed text.

The control flow for Standard OCR mode is depicted in the following flow chart:

<Frame>
  ```mermaid theme={"theme":"poimandres"}
  graph TD
      subgraph OCR [ OCR ]
          G[Standard / Azure OCR]
      end

      A[Process File] --> B{Document Type?}
      B -->|PDF| C[Convert to Image]:::test
      B -->|Office Docs| D[Extract Image]
      B --> |Image| G
      C --> G
      D --> G
      G --> H[Text DEID]
      H --> I[Create Redacted Image]
      I --> J[Create Redacted File]
  ```
</Frame>

### When to choose Standard OCR?

* Most cost efficient OCR solution is needed.

## Azure Computer Vision OCR

| Attribute | Rating |
| --------- | ------ |
| Accuracy  | High   |
| Speed     | High   |
| Cost      | Medium |

Azure Computer Vision OCR uses [Microsoft's Computer Vision API](https://azure.microsoft.com/en-us/products/ai-services/ai-vision) to analyze and extract text from a wide range of document types. It's particularly effective for complex documents, including those with handwriting, images, and various fonts, layouts, rotations, and Japanese characters.

To use this OCR mode, set `PAI_OCR_SYSTEM=azure_computer_vision` as an environment variable at container startup or specify it directly in the request parameters. Check out our [Guide for Integrating Limina DEID container with Azure OCR](/configuration-and-operations/advanced-features/azure-ocr) for setup information.

The control flow is similar to the Standard OCR mode.

### When to choose Azure Computer Vision OCR?

* Handwriting support is needed.
* Rotated document support is needed.
* Enhanced language support is needed.
* Wide range of supported languages, such as Japanese. See [Azure OCR Language support](https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/language-support) for more details.

## Azure Document Intelligence

| Attribute | Rating |
| --------- | ------ |
| Accuracy  | High   |
| Speed     | High   |
| Cost      | High   |

Azure Document Intelligence uses [Microsoft's Document Intelligence API](https://azure.microsoft.com/en-us/products/ai-services/ai-document-intelligence). On top of what Azure Computer Vision OCR already offers, Document Intelligence provide advanced features for complex layouts like tables and forms.

To use this OCR mode, set `PAI_OCR_SYSTEM=azure_doc_intelligence` as an environment variable at container startup or specify it directly in the request parameters. Check out our [Guide for Integrating Limina DEID container with Azure OCR](/configuration-and-operations/advanced-features/azure-ocr) for setup information.

The control flow is similar to the Standard OCR mode.

### When to choose Azure Document Intelligence?

* Need advanced features for complex layouts like tables and forms.
* Handwriting support is needed.
* Rotated document support is needed.
* Enhanced language support is needed.
* Wide range of supported languages. See [Azure OCR Language support](https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/language-support/ocr?view=doc-intel-4.0.0\&tabs=read-print%2Clayout-print%2Cgeneral#layout) for more details.

## Hybrid OCR

| Attribute | Rating |
| --------- | ------ |
| Accuracy  | Medium |
| Speed     | High   |
| Cost      | Medium |

The Hybrid OCR mode combines Azure Computer Vision OCR and Standard OCR to optimize text extraction and the cost for PDF documents. This mode uses Azure Computer Vision OCR for pages containing graphics and switches to Standard OCR for other pages. The choice between OCR modes is made on a page by page basis.

The setup of OCR in hybrid mode is the same as Azure Computer Vision OCR mode. Simply follow our [Guide for Integrating Limina DEID container with Azure OCR](/configuration-and-operations/advanced-features/azure-ocr) & use `PAI_OCR_SYSTEM=hybrid` either as an environment variable or specify it in the request parameters, instead of `PAI_OCR_SYSTEM=azure_computer_vision`.

The control flow for Hybrid OCR mode is depicted in the following flow chart:

<Frame>
  ```mermaid theme={"theme":"poimandres"}
  graph TD
      subgraph OCR [ OCR ]
          F[Standard OCR Flow]
          G[Azure Computer Vision OCR Flow]
      end

      A[Process File] --> B{File is a PDF}
      B --> |Yes| C[Render Pages]
      B -->|No| F
      C --> E{Image present in the page}
      E -->|Yes| G
      E -->|No| F
      G --> H[Text DEID]
      F --> H
      H --> I[Create Redacted Image]
      I --> J[Create Redacted File]
  ```
</Frame>

### When to choose Hybrid OCR?

* Need a mix of performance and cost effectiveness.
* Need to process mainly PDFs. For other document types the Hybrid OCR will work just like the Standard OCR.

## Amazon Textract

| Attribute | Rating |
| --------- | ------ |
| Accuracy  | High   |
| Speed     | High   |
| Cost      | High   |

[Amazon textract](https://aws.amazon.com/textract/) integration is offered for those customers that prefer the AWS ecosystem.

To use this OCR mode, set `PAI_OCR_SYSTEM=aws_textract` as an environment variable at container startup or specify it directly in the request parameters.

Additionally ensure that following environment variables are set:

```shell theme={"theme":"poimandres"}
PAI_AWS_ACCESS_KEY_ID=<YOUR-AWS_ACCESS_KEY_ID>
PAI_AWS_SECRET_ACCESS_KEY=<YOUR-AWS_SECRET_ACCESS_KEY>
PAI_AWS_DEFAULT_REGION=<YOUR-AWS-REGION eg. "us-east-1">
```

The control flow is similar to the Standard OCR mode.
