# OCRParams Class

> Parameters for configuring the OCR (Optical Character Recognition) engine.

- Product: Adobe PDF Library 21
- Language: Modern C++
- Version: 21.4.0
- HTML page: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OCRParams
- Version index: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/llms.txt

```cpp
class OCRParams
```

**Namespace:** `datalogics_interface`

## Description

Parameters for configuring the OCR (Optical Character Recognition) engine.

Parameters for configuring the OCR engine.

OCRParams controls settings such as the engine to use, the resolution of the input images, the language(s) to recognize, performance tuning, page segmentation mode, candidate font names for placing text, and image preprocessing options.

**Referenced by:** [`OCREngine`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OCREngine.md)

**Uses types:** [`OCRLanguageSetting`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/OCRLanguageSetting.md), [`OCRPageSegmentationMode`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRPageSegmentationMode.md), [`OCRPerformance`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRPerformance.md)

## Constructors

### OCRParams

```cpp
datalogics_interface::OCRParams::OCRParams()
```

*constructor*

Create OCRParams with defaults.

### OCRParams

```cpp
datalogics_interface::OCRParams::OCRParams(const OCRParams &other)
```

*constructor*

**Parameters**

- `other` ([`const OCRParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OCRParams.md))

Copy constructor.

### OCRParams

```cpp
datalogics_interface::OCRParams::OCRParams(OCRParams &&) noexcept
```

*constructor*

**Parameters**

- (unnamed) ([`OCRParams &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OCRParams.md))

### ~OCRParams

```cpp
datalogics_interface::OCRParams::~OCRParams()
```

*destructor*

## Methods

### get_candidate_font_names

```cpp
std::vector< std::string > datalogics_interface::OCRParams::get_candidate_font_names() const
```

**Returns:** `std::vector< std::string >`

The names of candidate fonts for placing text under an image.

The default list should work well in most cases. If you're using text that isn't represented by Latin fonts, or by Chinese, Japanese, or Korean fonts, then retrieve this list, add the font that can represent that text, then set that new list on this object.

Enough font names must be supplied to cover the expected languages/scripts in use.

The code selects a font to represent each word. If a word code-switches between different scripts, for instance, if it contains non-Latin text and Arabic numerals, then make sure to supply the name of a font family that can handle both the text and the numerals.

The quality of the results depends on the font choice. The list is searched in order until a font works for a particular word. To make the text fit better, it's recommended to list proportional fonts before fixed-width fonts. Decorative fonts with flourishes, like Zapf Chancery, deliver poor results. Generally, supply a font that would be used in block text, such as in a newspaper or work of literature, such as Times Roman, or a font already in the list, like MinionPro.

If the PlaceTextUnder method in OCREngine can't identify a font that covers the whole text of a word, an exception will be thrown.

### get_enable_image_preprocessing

```cpp
bool datalogics_interface::OCRParams::get_enable_image_preprocessing() const
```

**Returns:** `bool`

Get the image preprocessing enable state. True if any image preprocessing is on.

### get_engine

```cpp
std::string datalogics_interface::OCRParams::get_engine() const
```

**Returns:** `std::string`

The name of the OCR engine to use.

Use the Tesseract4Engine constant to select the Tesseract v4 engine.

### get_languages

```cpp
std::vector< OCRLanguageSetting > datalogics_interface::OCRParams::get_languages() const
```

**Returns:** [`std::vector< OCRLanguageSetting >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/OCRLanguageSetting.md)

The list of languages the OCR engine should recognize.

### get_page_segmentation_mode

```cpp
OCRPageSegmentationMode datalogics_interface::OCRParams::get_page_segmentation_mode() const
```

**Returns:** [`OCRPageSegmentationMode`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRPageSegmentationMode.md)

The page segmentation mode, which controls how the OCR engine detects text regions on the page.

### get_performance

```cpp
OCRPerformance datalogics_interface::OCRParams::get_performance() const
```

**Returns:** [`OCRPerformance`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRPerformance.md)

The desired performance mode for the OCR engine, balancing speed versus accuracy.

### get_resolution

```cpp
double datalogics_interface::OCRParams::get_resolution() const
```

**Returns:** `double`

The resolution, in DPI, at which images are rendered for OCR processing.

### operator=

```cpp
OCRParams & datalogics_interface::OCRParams::operator=(const OCRParams &other)
```

**Parameters**

- `other` ([`const OCRParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OCRParams.md))

**Returns:** [`OCRParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OCRParams.md)

Copy assignment.

### operator=

```cpp
OCRParams & datalogics_interface::OCRParams::operator=(OCRParams &&) noexcept
```

**Parameters**

- (unnamed) ([`OCRParams &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OCRParams.md))

**Returns:** [`OCRParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OCRParams.md)

### set_candidate_font_names

```cpp
void datalogics_interface::OCRParams::set_candidate_font_names(const std::vector< std::string > &font_names)
```

**Parameters**

- `font_names` (`const std::vector< std::string > &`): the names of candidate fonts for placing text under an image

**Returns:** `void`

The names of candidate fonts for placing text under an image.

The default list should work well in most cases. If you're using text that isn't represented by Latin fonts, or by Chinese, Japanese, or Korean fonts, then retrieve this list, add the font that can represent that text, then set that new list on this object.

Enough font names must be supplied to cover the expected languages/scripts in use.

The code selects a font to represent each word. If a word code-switches between different scripts, for instance, if it contains non-Latin text and Arabic numerals, then make sure to supply the name of a font family that can handle both the text and the numerals.

The quality of the results depends on the font choice. The list is searched in order until a font works for a particular word. To make the text fit better, it's recommended to list proportional fonts before fixed-width fonts. Decorative fonts with flourishes, like Zapf Chancery, deliver poor results. Generally, supply a font that would be used in block text, such as in a newspaper or work of literature, such as Times Roman, or a font already in the list, like MinionPro.

If the PlaceTextUnder method in OCREngine can't identify a font that covers the whole text of a word, an exception will be thrown.

### set_enable_image_preprocessing

```cpp
void datalogics_interface::OCRParams::set_enable_image_preprocessing(bool enable)
```

**Parameters**

- `enable` (`bool`): true to enable all image preprocessing, false to disable it. Once the OCREngine is initialized, this setting is permanent.

**Returns:** `void`

Enable all image preprocessing, default enabled. Note that once the OCREngine is initialized, this setting is permanent.

### set_engine

```cpp
void datalogics_interface::OCRParams::set_engine(const std::string &value)
```

**Parameters**

- `value` (`const std::string &`): the name of the OCR engine to use

**Returns:** `void`

The name of the OCR engine to use.

Use the Tesseract4Engine constant to select the Tesseract v4 engine.

### set_languages

```cpp
void datalogics_interface::OCRParams::set_languages(const std::vector< OCRLanguageSetting > &languages)
```

**Parameters**

- `languages` ([`const std::vector< OCRLanguageSetting > &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/OCRLanguageSetting.md)): the list of languages the OCR engine should recognize

**Returns:** `void`

The list of languages the OCR engine should recognize.

### set_page_segmentation_mode

```cpp
void datalogics_interface::OCRParams::set_page_segmentation_mode(OCRPageSegmentationMode mode)
```

**Parameters**

- `mode` ([`OCRPageSegmentationMode`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRPageSegmentationMode.md)): the page segmentation mode, which controls how the OCR engine detects text regions on the page

**Returns:** `void`

The page segmentation mode, which controls how the OCR engine detects text regions on the page.

### set_performance

```cpp
void datalogics_interface::OCRParams::set_performance(OCRPerformance perf)
```

**Parameters**

- `perf` ([`OCRPerformance`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRPerformance.md)): the desired performance mode for the OCR engine, balancing speed versus accuracy

**Returns:** `void`

The desired performance mode for the OCR engine, balancing speed versus accuracy.

### set_resolution

```cpp
void datalogics_interface::OCRParams::set_resolution(double value)
```

**Parameters**

- `value` (`double`): the resolution, in DPI, at which images are rendered for OCR processing

**Returns:** `void`

The resolution, in DPI, at which images are rendered for OCR processing.
