Lines 1- 6 handle importing packages for this script. Open up a new file, name it ocr_template_match.py, and we’ll get to work: # import the necessary packages These additional screenshots will give you extra insight as to how we are able to chain together basic image processing techniques to build a solution to a computer vision project. Since there will be many image processing operations applied to help us detect and extract the credit card digits, I’ve included numerous intermediate screenshots of the input image as it passes through our image processing pipeline. These techniques have been used in other blog posts to detect barcodes in images and recognize machine-readable zones in passport images. In order to accomplish this, we’ll need to apply a number of image processing operations, including thresholding, computing gradient magnitude representations, morphological operations, and contour extraction. In this section we’ll implement our template matching algorithm with Python + OpenCV to automatically recognize credit card digits. To learn more about using template matching for OCR with OpenCV and Python, just keep reading.įigure 3: The MICR E-13B font commonly found on bank checks ( source).Įach of the above fonts have one thing in common - they are designed for easy OCR.įor this tutorial, we will make a template matching system for the OCR-A font, commonly found on the front of credit/debit cards. In today’s blog post I’ll be demonstrating how we can use template matching as a form of OCR to help us create a solution to automatically recognize credit cards and extract the associated credit card digits from images. Therefore, we need to devise our own custom solution to OCR credit cards. In these cases, the Tesseract library is unable to correctly identify the digits (this is likely due to Tesseract not being trained on credit card example fonts). Recognize the type of credit card (i.e., Visa, MasterCard, American Express, etc.).Apply OCR to recognize the sixteen digits on the credit card.Localize the four groupings of four digits, pertaining to the sixteen digits on the credit card.Detect the location of the credit card in the image.In some cases, it will work great - and in others, it will fail miserably.Ī great example of such a use case is credit card recognition, where given an input image, However, as I’ve mentioned multiple times in these previous posts, Tesseract should not be considered a general, off-the-shelf solution for Optical Character Recognition capable of obtaining high accuracy. We then learned how to cleanup images using basic image processing techniques to improve the output of Tesseract OCR. In a previous blog post, we learned how to install the Tesseract binary and use it for OCR.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |