Python HOW: Image processing for OCR using OpenCV

Prepare your images for Optical Character Recognition APIs

Gabriel Harris Ph.D.
5 min readSep 10, 2020
source: author

If your image has random noise, uneven illumination, holes in front objects, etc. There are few things that you can do before posting your image to a computer vision API. In this article, we go through few processing techniques to boost OCR results using OpenCV

TL;DR: full code

Install OpenCV

Install OpenCV using your preferred package manager

Read the image

I will use the cover of the 1st edition of one of my favorite books as an example. Let’s first read the image, specifying the colour type of the image to coloured. This will read the image in the default colour format in OpenCV which is BGR (Blue-Green-Red). We will then convert the colour space to the more common RGB order (and for…

--

--

Gabriel Harris Ph.D.

I’m an End-to-End Lead Data Scientist and Data Science Manager. My articles are love letters to my future self