Text recognition on image file after capture() and processing

Asked by Nitr0UK

Am attempting to perform text recognition on a saved image (the image does not exist on screen only in a png file)

The image has been created through the capture() command, the image path returned is then passed into a java class that greyscales the image and increases the contrast, making the image black text on a white background to improve OCR effectiveness. However I am now stumped as to how to read this saved image back into Sikuli, considering text() can only be called on a region.

If I open this image in an image viewer and then set the region to this image text recognition now works perfectly, so this definitely isn't an issue. However automating it in this fashion is not practical due to the amount of images that are processed in this way and the time required to open each one.

Thanks for your help.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Nitr0UK
Solved:
Last query:
Last reply:
Revision history for this message
Nitr0UK (nitr0uk) said :
#1

Fixed, looked at the source and used TextRecognizer.recognize:

e.g.

from javax.imageio import ImageIO
from org.sikuli.script import TextRecognizer
from java.io import File

text = TextRecognizer.getInstance().recognize(ImageIO.read(File("imageLocation.png")))

Thanks.

Revision history for this message
Nitr0UK (nitr0uk) said :
#2

Fixed, looked at the source and used TextRecognizer.recognize:

e.g.

from javax.imageio import ImageIO
from org.sikuli.script import TextRecognizer
from java.io import File

text = TextRecognizer.getInstance().recognize(ImageIO.read(File("imageLocation.png")))

Thanks.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

Thanks for finding.

Should be added in the API: use an image file or buffered image directly for OCR.

I put it on my list.

Since I am trying to improve Sikuli:
--- the image path returned is then passed into a java class that greyscales the image and increases the contrast, making the image black text on a white background to improve OCR effectiveness.

Could you share the code with me (my mail at https://launchpad.net/~raimund-hocke)?

Revision history for this message
JonyGreen (jonygreen) said :
#4

You can try this free online ocr to convert image to text http://www.online-code.net/ocr.html.