Using the text API

Enough of theory. It's time to see how the text module works in practice. Let's study how to use it to perform text detection, extraction, and identification.

Text detection

Let's start with creating a simple program to perform text segmentation using ERFilters. In this program, we will use the trained classifiers from text API samples. You can download them from the OpenCV repository, but they are also available in the book's companion code.

First, we start with including all the necessary libs and using:

#include  "opencv2/highgui.hpp"
#include  "opencv2/imgproc.hpp"
#include  "opencv2/text.hpp"

#include  <vector>
#include  <iostream>

using namespace std;
using namespace cv;
using namespace cv::text;

Recall from our previous section ...

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.