1

I am attempting (and failing at) locating area's containing text from a larger image. Specifically I am looking to recognize titles of Magic cards. At the moment I have managed to cut the images down to blocks containing the title, such as

input image.

Despite this and even with training the ocr library to work with only with this font accuracy is still low. As far as I can tell the best thing I can do is crop the image to only the text. After research I still have been unable to do so. I attempted to implement the solutions presented in Extracting text OpenCV however the text is too close to the border for this to work. attempt image. If possible help in the form of java would be greatly appreciated. (sorry for the image links, I don't have the reputation to embed images)

Community
  • 1
  • 1
  • Sorry, can't help. But I was wondering how you integrated Tesseract with opencv? Are you using Opencv 3.0 with the tesseract contrib module? If so what did you have to do to get that working? – medloh Oct 30 '15 at 16:26
  • I am using the opencv 3.0 java wrapper and the latest version of tess4j. I am simply converting the mat's from opencv to java buffered images and passing them to tess4j. – Justin Gerhardt Oct 30 '15 at 17:33
  • Nice, I was just curious about the new OCR support in opencv 3.0, and what it takes to get it working through the java bindings. As for your issue, have you tried enlarging the image, applying filters like eroision, dilation, blurring, sharpening, etc to get a better bounding on the text contours? – medloh Oct 30 '15 at 17:42
  • I have not used ocr thought opencv, I didn't even know it was possible. as for the image the distance between the border and the text is smaller than the spaces in the text making the filters useless at distinguishing the two. – Justin Gerhardt Oct 30 '15 at 18:25
  • I have also implement this http://stackoverflow.com/a/25105964/1874116 in java. However passing this image: [input image 2](http://i.imgur.com/zOd1qck.png) only managed to produce [output image](http://i.imgur.com/v1oPrkt.png) (i would edit the original question but I don't have the rep need to add the links) – Justin Gerhardt Oct 30 '15 at 18:26
  • If all the text is going to have a nice clean border like that you may have better luck precisely identifying the location of the border (hough lines), and assuming the position of the text relative to those borders. – medloh Oct 30 '15 at 20:56
  • Thanks, searching for border in the stroke width transform images worked and while a bit unreliable certainly helped. feel free to post your suggestions as an anwser – Justin Gerhardt Nov 02 '15 at 02:47

1 Answers1

0

Posting answer as suggested.

This answer relies on the text always being close to the same distance/offset away from the border.

Find the boundings of the border using Canny/Hough etc, and with whatever filtering techniques works best with your images (erosion, dilution, sharpen, grayscale, binary thresholding, etc).

Then take a smaller interior submat() of this border bounding Rect to get an approximation of where the text should be and run the ocr on this submat.

medloh
  • 941
  • 12
  • 33