Using the text API
Enough theory. It's time to see how the text module works in practice. Let's study how we can use it to perform text detection, extraction, and identification.
Text detection
Let's start by creating a simple program so that we can perform text segmentation using ERFilters. In this program, we will use the trained classifiers from text API samples. You may download this from the OpenCV repository, but they are also available in this book's companion code.
First, we start by including all of the necessary libs
and usings
:
#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 the Extremal region filtering section that the ERFilter
works separately in each image channel. Therefore, we must provide a way to separate each desired channel in a different single channel, cv::Mat
. This is done by the separateChannels...