<a id="easyocr"></a>

# EasyOCR - Reading Texts

![EasyOCR](assets/images/easyocr1/character_isolation.webp)

<a id="easyocr-purpose"></a>

## Purpose

The **EasyOCR** optical character recognition library reads short texts (such as serial numbers, part numbers and dates).

* It uses font files (pre-defined OCR-A, OCR-B and Semi-standard fonts, or other learned fonts).
* Its template matching algorithm recognizes even badly printed, broken or connected characters of any size.
* Characters can be filtered by class to improve reliability and speed.

#### NOTE
**EasyOCR** is superseded by [**EasyOCR2**](../easyocr2/index.html.md) and [**EasyDeepOCR**](../easydeepocr/index.html.md). See the [comparison of OCR methods](../comparison_of_ocr_methods.html.md).

<a id="easyocr-quickstart"></a>

## Recognizing Characters

* Create an [`EOCR`](../../../doxygen_cpp/classeVision_1_1EOCR.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR.html) object and load a font with [`EOCR::Load`](../../../doxygen_cpp/classeVision_1_1EOCR.html#a82e426d0bff454ebe86abfa14dd8f74f) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR.html#abc09dbb2aeee60ed2e16c71710077b3a) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR.html#a55bb4431b3e5cba105d0526063afaacd).
* Call [`EOCR::Recognize`](../../../doxygen_cpp/classeVision_1_1EOCR.html#a75fa619140de2614ec0847df09023138) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR.html#af1994c767a2c892ad17bb4ad72acdeac) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR.html#aecb017230592da5bf934c0541a4cd227) to read the text in an image.

### C++

```cpp
#include <eVision/EasyOcr/EasyOCR/EOCR.h>
```

```cpp
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// EOCR constructor
EOCR ocr;
// Load the font file
ocr.Load("myFont.ocr");
// ...
// Recognize the characters
std::string text = ocr.Recognize(&srcImage, 10, EOCRClass_AllClasses);
// Alternatively
// Define the character filter (2 letters and 3 digits)
std::vector<uint32_t> charFilter;
charFilter.push_back(EOCRClass_UpperCase);
charFilter.push_back(EOCRClass_UpperCase);
charFilter.push_back(EOCRClass_Digit);
charFilter.push_back(EOCRClass_Digit);
charFilter.push_back(EOCRClass_Digit);
// Recognize the characters with class filtering
text = ocr.Recognize(&srcImage, 10, charFilter);
```

### C#

```cs
using eVision;
```

```cs
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// EOCR constructor
EOCR ocr = new EOCR();
// Load the font file
ocr.Load("myFont.ocr");
// ...
// Recognize the characters
string text = ocr.Recognize(srcImage, 10, (int)EOCRClass.AllClasses);
// Alternatively
// Define the character filter (2 letters and 3 digits)
uint[] charFilter = new uint[5];
charFilter[0] = (uint)EOCRClass.UpperCase;
charFilter[1] = (uint)EOCRClass.UpperCase;
charFilter[2] = (uint)EOCRClass.Digit;
charFilter[3] = (uint)EOCRClass.Digit;
charFilter[4] = (uint)EOCRClass.Digit;
// Recognize the characters with class filtering
text = ocr.Recognize(srcImage, 10, charFilter);
```

### Python

```py
import eVision
# Image constructor
src_image = eVision.EImageBW8()
# EOCR constructor
ocr = eVision.EOCR()
# Load the font file
ocr.Load("myFont.ocr")
# ...
# Recognize the characters
text = ocr.Recognize(src_image, 10, eVision.EOCRClass.AllClasses)
# Alternatively
# Define the character filter (2 letters and 3 digits)
char_filters = []
char_filters.append(eVision.EOCRClass.UpperCase)
char_filters.append(eVision.EOCRClass.UpperCase)
char_filters.append(eVision.EOCRClass.Digit)
char_filters.append(eVision.EOCRClass.Digit)
char_filters.append(eVision.EOCRClass.Digit)
# Recognize the characters with class filtering
text = ocr.Recognize(src_image, 10, char_filters)
```

<a id="easyocr-contents"></a>

## Contents

Font learning, segmentation, recognition, and parameter tuning.

<a id="easyocr-quick-links"></a>

## Quick Links

List of all Classes, Structs and Enumerations of the **EasyOCR** library.

Code snippets for the **EasyOCR** library.

#### SEE ALSO
The `EasyOcrRead` sample program reads text in an image ROI using an OCR font file: [EasyOcrRead](../../../resources/sample_programs/text_and_code_reading/easyocrread.html.md).
