Using Tesseract OCR library

As Tesseract OCR is already integrated with OpenCV 3.0, it still worth studying its API since it allows a finer-grained control over Tesseract parameters. The integration will be studied in the next chapter.

Creating a OCR function

We'll change the previous example to work with Tesseract. We will start with adding baseapi and fstream tesseracts to the list:

#include <opencv2/opencv.hpp>
#include <tesseract/baseapi.h>

#include <vector>
#include <fstream>

Then, we'll create a global TessBaseAPI object that represents our Tesseract OCR engine:

tesseract::TessBaseAPI ocr;

Tip

The ocr engine is completely self-contained. If you want to create multithreaded OCR software, just add a different TessBaseAPI object to each thread, and ...

Get OpenCV By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.