Ask Your Question

Rotation of word and cropping

asked 2016-11-01 06:14:44 -0500

rhardih gravatar image

updated 2016-11-01 06:15:33 -0500

I'm trying to build a simple price-tag scanner and I've gotten reasonably far with regards to binarisation and general de-noising.

However, feeding an image like this to Tesseract doesn't yield very good results. Tesseract seems very sensitive to the amount of artifacts present in the picture, aside from what is to be recognised, as well as even slight skews on the text. Here's an example, where a ROI around a price has been selected and binarised:

image description

Asking Tesseract to OCR this image, is rather useless: flflflflfl.

However, if I could manage to somehow consistently deskew and crop to just the numbers, it's a whole different thing:

image description

Now Tesseract provides a clean result: $33.25

In this case, because of the straight black line at the top, I could use a Hough transform and calculate the angle, in order to deskew the image, but there won't always be straight lines to use, so that won't work in general.

I could also use an ER filter to get just the text region, but then I'd get a rectangle without rotation and I'd still need to figure out how to crop/deskew again regardless.

So my question is, if there's some clever way to extract a relatively tight bounding box, a'la minAreaRect(), around just the number, in order to make presentable cutout to feed to Tesseract?

edit retag flag offensive close merge delete


I don't know anything about the size of the characters unfortunately. They will be in all kinds of sizes and font types.

rhardih gravatar imagerhardih ( 2016-11-04 04:23:07 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2016-11-03 05:11:43 -0500

Do you know what the size of the characters you are interested in? From my experience it seems to get the best results is to detect something that the text is next to that has strong features and then apply Tesseract to a known offset; does not mean this will work for you. Alternatively detecting the text might work better; it depends what type of artifacts you expect.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-11-01 06:14:44 -0500

Seen: 528 times

Last updated: Nov 01 '16