Skip to content

Perform Optical Character Recognition (OCR) using OpenCV and Tesseract

Notifications You must be signed in to change notification settings

nihargarg/optical-character-recognition-ocr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

How to perform Optical Character Recognition (OCR)

Steps to detect and OCR with OpenCV and Tesseract:

1. Take and save an image of the item (card/mailpiece/receipt) to be OCR'ed

  • This step is not included in this repository, but is as simple as clicking a picture using a camera and saving it to the local machine

    Original

2. Preprocessing the input image using OpenCV:

  • Apply edge detection to reveal the outline (detect the four corners) of the item in the image against the background

    • This step works well if there is sufficient contrast between the background and foreground

      Greyed
      Blurred

  • Detect contours in the edge map

    Edged
  • Loop over all contours and find the largest contour with four vertices (corners)

    Outline
  • Apply a perspective transform to obtain a top-down, bird’s-eye view of the item (required to improve OCR accuracy)

    Transformed
    Colored
    Enhanced

3. OCR the text on the top-down transform of the item using Tesseract

  • Extract data using Python regular expressions

  • Display the results on our terminal and save to a text file

    Nihar Garg, EIT, LEED Green Associate
    Project Engineer
    ngarg@princetonengineering Services
    609-216-7499
    101 Morgan Lane STE 205, Plc
    609-452-9700
    609-751-9545

A special thank you to pyimagesearch.

About

Perform Optical Character Recognition (OCR) using OpenCV and Tesseract

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages