Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
OpenCV By Example

You're reading from   OpenCV By Example Enhance your understanding of Computer Vision and image processing by developing real-world projects in OpenCV 3

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher Packt
ISBN-13 9781785280948
Length 296 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Vinícius G. Mendonça Vinícius G. Mendonça
Author Profile Icon Vinícius G. Mendonça
Vinícius G. Mendonça
David Millán Escrivá David Millán Escrivá
Author Profile Icon David Millán Escrivá
David Millán Escrivá
Prateek Joshi Prateek Joshi
Author Profile Icon Prateek Joshi
Prateek Joshi
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with OpenCV FREE CHAPTER 2. An Introduction to the Basics of OpenCV 3. Learning the Graphical User Interface and Basic Filtering 4. Delving into Histograms and Filters 5. Automated Optical Inspection, Object Segmentation, and Detection 6. Learning Object Classification 7. Detecting Face Parts and Overlaying Masks 8. Video Surveillance, Background Modeling, and Morphological Operations 9. Learning Object Tracking 10. Developing Segmentation Algorithms for Text Recognition 11. Text Recognition with Tesseract Index

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 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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime