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.
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 the execution will be fairly thread-safe. You just need to guarantee that file writing is not done over the same file; otherwise, you'll need to guarantee safety for this operation.
Next, we will create a function called identify...