dexter323: What are the exact contents of the variable called "Power"? You've probably got other characters in there, like a space or something. Use a StringReplace command or something similar to get rid of the non-numeric characters.

OCR.ahk - Library for recognizing text in images
Started by
camerb
, Jul 15 2011 11:13 PM
88 replies to this topic
#46
-
Posted 11 June 2012 - 05:34 PM

Aren't you glad that I didn't put an annoying gif here?
I have a problem recognizing numbers with OCR.ahk
FAIL1.jpg
DD:_:_:D7
FAIL2.jpg
nothing
is there a way to help recognition?
is structurise textract better than gocr?
FAIL1.jpg
DD:_:_:D7
FAIL2.jpg
nothing
is there a way to help recognition?
is structurise textract better than gocr?
#47
-
Posted 21 June 2012 - 08:21 PM

"Simplifying complexity is not simple"
stevep: are you running it in numeric mode?
#48
-
Posted 21 June 2012 - 08:31 PM

Aren't you glad that I didn't put an annoying gif here?
numeric is useless, it just changes the undetermined numbers to spaces, and I could convert D to 0 after OCR function
here's a bitmap, please try if you can
is there a way to use Tesseract OCR suggested by PhilHo in AHK?
<!-- m -->http://googlecode.bl... ... t-ocr.html<!-- m -->
<!-- m -->http://sourceforge.n...s/tesseract-ocr<!-- m -->
made by HP, taken over by Google which made it open source.
here's a bitmap, please try if you can
is there a way to use Tesseract OCR suggested by PhilHo in AHK?
<!-- m -->http://googlecode.bl... ... t-ocr.html<!-- m -->
<!-- m -->http://sourceforge.n...s/tesseract-ocr<!-- m -->
made by HP, taken over by Google which made it open source.
#49
-
Posted 21 June 2012 - 08:35 PM

"Simplifying complexity is not simple"
after saving the file as Monochrome in Paint and converting it to pcx, gocr.exe recognized all the numbers
A dos utility that will convert a bmp image to 2-bit Monochrome and save it as pcx/ is necessary for gocr.exe
also I have found there are many other ocr tools:
<!-- m -->http://en.wikipedia.... ... n_software<!-- m -->
but many are not command-line driven and not for Windows
This one recognized all the numbers from a jpeg without any conversions:
<!-- m -->http://www.verydoc.c...-ocr/index.html<!-- m -->
but it's 200$ !
A dos utility that will convert a bmp image to 2-bit Monochrome and save it as pcx/ is necessary for gocr.exe
also I have found there are many other ocr tools:
<!-- m -->http://en.wikipedia.... ... n_software<!-- m -->
but many are not command-line driven and not for Windows

This one recognized all the numbers from a jpeg without any conversions:
<!-- m -->http://www.verydoc.c...-ocr/index.html<!-- m -->
but it's 200$ !
#50
-
Posted 21 June 2012 - 09:47 PM

"Simplifying complexity is not simple"
SteveP: Good to hear that your conversion worked just fine for the expensive OCR software.
OCR does not guarantee a correct reading of what those numbers are, it merely makes a guess at what they could be. With text that small, I wouldn't get my hopes up for it recognizing many of the characters in there, because it is so pixelated. If the text is larger, it will be better, but again, nothing is guaranteed. Also, in the "FAIL1" image you gave me, a significant portion of the numbers is chopped off. That makes it nearly impossible for the computer to determine the actual text of the numbers.
Also, feel free to experiment with using TesseractOCR on your own (and start your own thread, too). I've messed around with Tesseract a little, but I am not planning on implementing any interaction with that software. Feel free to make your own lib for it.
OCR does not guarantee a correct reading of what those numbers are, it merely makes a guess at what they could be. With text that small, I wouldn't get my hopes up for it recognizing many of the characters in there, because it is so pixelated. If the text is larger, it will be better, but again, nothing is guaranteed. Also, in the "FAIL1" image you gave me, a significant portion of the numbers is chopped off. That makes it nearly impossible for the computer to determine the actual text of the numbers.
Also, feel free to experiment with using TesseractOCR on your own (and start your own thread, too). I've messed around with Tesseract a little, but I am not planning on implementing any interaction with that software. Feel free to make your own lib for it.
#51
-
Posted 21 June 2012 - 10:14 PM

Aren't you glad that I didn't put an annoying gif here?
goocr is fine, it determines all the numbers after the image is saved as Monochrome and converted to pcx/pnbThat makes it nearly impossible for the computer to determine the actual text of the numbers.
currently I am searching for a dos-utility command-line tool to accomplish this task.
Have you any on your mind?
#52
-
Posted 21 June 2012 - 10:21 PM

"Simplifying complexity is not simple"
You'll notice that the lib already converts the files to pnm. However, it does not have a monochrome conversion mode. It does have a greyscale conversion mode, but that is not the same thing, since it allows for many shades of grey. I have not looked into monochrome conversions via the command-line, if you find something promising, let me know. It might be nice to add that in.
#53
-
Posted 21 June 2012 - 10:27 PM

Aren't you glad that I didn't put an annoying gif here?
GDI+ doesn't have ColorDepth functions, ImageMagick does the job
<!-- m -->http://www.imagemagi... ... hp#windows<!-- m -->
currently reading the help files
<!-- m -->http://www.imagemagi... ... essing.php<!-- m -->
here it is:
-monochrome
transform the image to black and white.
<!-- m -->http://www.imagemagi... ... hp#windows<!-- m -->
currently reading the help files
<!-- m -->http://www.imagemagi... ... essing.php<!-- m -->
here it is:
-monochrome
transform the image to black and white.
#54
-
Posted 21 June 2012 - 10:33 PM

"Simplifying complexity is not simple"
Still have a problem with conversion to Monochrome, ImageMagick have a lot of color reduction and dithering options, I have tried most, but with no luck. I had to create a topic in ImageMagick forum to solve the problem:
http://www.imagemagi...php?f=1&t=21264
It looks like Gocr project is abandoned, last version is dated 2010-09
http://www.imagemagi...php?f=1&t=21264
It looks like Gocr project is abandoned, last version is dated 2010-09
#55
-
Posted 22 June 2012 - 12:27 AM

"Simplifying complexity is not simple"
camerb, you should read the gocr help file, the image is already converted to grayscale by gocr itself:
<!-- m -->http://aist1.pisem.net/gocr.html<!-- m -->
no need for the grayscale option in
I don't get it, it recognizes text on following images, even handwritten text, is it a problem with the Windows version?
Examples are downloaded from the Linux version
<!-- m -->http://www-e.uni-mag... ... .49.tar.gz<!-- m -->
<!-- m -->http://aist1.pisem.net/gocr.html<!-- m -->
no need for the grayscale option in
convertCmd=djpeg.exe -pnm -grayscale %filenameJpg% %filenamePnm%
I don't get it, it recognizes text on following images, even handwritten text, is it a problem with the Windows version?
Examples are downloaded from the Linux version
<!-- m -->http://www-e.uni-mag... ... .49.tar.gz<!-- m -->
#56
-
Posted 22 June 2012 - 12:45 AM

"Simplifying complexity is not simple"
so, here are the changes that saved my day:
and definitely the convert.exe should be used, as jpeg even at 100% quality IS compressed, and with ImageMagick convert GetOCR() could prepare an uncompressed pgm for gocr.exe
and use pgm (Portable Graymap) instead of pnm
this file is also uncompressed
Changes in OCR.ahk 93 filenamePnm := "in.pnm" > filenamePnm := "in.pgm" 95 djpegPath=djpeg.exe > djpegPath=c:\Program Files\ImageMagick-6.7.7-Q16\convert.exe 117 convertCmd=djpeg.exe -pgm -grayscale %filenameJpg% %filenamePnm% > convertCmd=%djpegPath% %filenameJpg% -colorspace gray -auto-level -threshold 64`% -background black -extent 95x18 %filenamePnm%it's not universal, but the threshold value can be added as additional option to GetOCR()
and definitely the convert.exe should be used, as jpeg even at 100% quality IS compressed, and with ImageMagick convert GetOCR() could prepare an uncompressed pgm for gocr.exe
and use pgm (Portable Graymap) instead of pnm
this file is also uncompressed
#58
-
Posted 22 June 2012 - 02:31 AM

"Simplifying complexity is not simple"
Where am I suppose to see the result?
When I run OCR-preview.ahk I just see a pink rectangle, nothing more.
When I run OCR-preview.ahk I just see a pink rectangle, nothing more.
#59
-
Posted 04 July 2012 - 12:59 PM

MartinCarlsson: What version of AHK are you running? Also, what OS are you using? Also, did you unzip the zip file before running the AHK? Also, can you tell where the AHK stopped by opening up the "Lines most recently executed" debug panel in AHK?
You should see a pink rectangle, plus a ToolTip that shows what the text said.
You should see a pink rectangle, plus a ToolTip that shows what the text said.
#60
-
Posted 05 July 2012 - 01:09 PM

Aren't you glad that I didn't put an annoying gif here?