Skip to content
Advertisement

How can I read a full sequence of digits using tesseract instead of first digit only

I have the following clear binary image, and I want to read the digits using tesseract. Image

My problem is that tesseract is reading only the first digit (5)!

How can I make tesseract read the full sequence?

JavaScript

Output: 5 < o x o c >

Advertisement

Answer

You will have to do some amount of preprocessing before you push the image directly to pytesseract for extraction of text. One thing that comes to mind is using binary_fill_holes to fill the area inside edges. Here is an example of what you can do.

JavaScript

enter image description here

JavaScript

EDIT: No idea why pytesseract is predicting the last digit as 3 (weird!!)

You will have to find your own preprocessing pipeline that suits the other images. I would recommend looking at image segmentation and edge filling methods.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement