Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OCR-Image
#1
Is possible to obtain the number in an image knowing the numbers like ocr with 'scan' or another method?


Attached Files
.zip   NUMBERS.zip (Size: 2.93 KB / Downloads: 585)
#2
With scan it would be difficult. I tried to find an OCR dll, ActiveX or library. All are too expensive. The only free library, tesseract, reads only tif files.
#3
and isn't possible to convert BMP to TIF for to do the scan?
#4
I don't know how. Also, does not recognize some tif files. Worked well with the sample tif file, but did not work with tif files saved using MS Paint.
#5
Ok. Thanks.
#6
What do you think about http://www.about280.com/gocr/GOCRFrontend.zip ?
#7
I would prefer dll.
#8
Is possible using Tesseract + GflAx?
#9
Do you know how to create a tif file that can be used with tesseract? When I take some text snapshot with irfanview and save as tif file, tesseract produces empty file. Same with gflax. It works only with the eurotext.tif that is included with tesseract.
#10
In Autoit exist a function: CaptureToTIFF...

#11
The reason why it did not work - the text is too small. After resizing works well. I'll play with it more some day.
#12
Download these files from http://code.google.com/p/tesseract-ocr/downloads/list and unpack (eg with 7-Zip) somewhere:
1. tesseract-2.04.tar.gz. It contains tesseract.exe that we'll use.
2. tesseract-2.00.eng.tar.gz. It contains English language data. Place the tessdata folder in the folder where is tesseract exe.

Also need gflax:
Image manipulation

In the code, change the tesseract exe path (fTes).

Macro Macro1276
Code:
Copy      Help
str fTes="D:\Downloads\tesseract\tesseract.exe" ;;change this
int scale=2 ;;try to change this if recognition is poor. Tesseract is very sensitive to text size. Usually with 2 works best.

;---------------------

str fBmp="$temp$\qm_tesseract.bmp"
str fTif="$temp$\qm_tesseract.tif"
str fTxt="$temp$\qm_tesseract.txt"
fTes.expandpath
fBmp.expandpath
fTif.expandpath
fTxt.expandpath

;capture bitmap (optional)
if(!CaptureImageOrColor(0 0 _hwndqm fBmp)) ret

;bmp -> tif
typelib GflAx {059321F1-207A-47A7-93A1-29CDF876FDD3} 1.0
GflAx.GflAx g._create
g.LoadBitmap(fBmp)
g.Resize(g.width*scale g.height*scale)
g.SaveFormatName="tiff"
g.SaveBitmap(fTif)

;run fTif
;ret

;convert to text
if(fTxt.endi(".txt")) fTxt.fix(fTxt.len-4) ;;tesseract always adds ".txt"
str cl.format("%s ''%s'' ''%s''" fTes fTif fTxt) so
if(RunConsole2(cl so)) end so

;show results
fTxt+".txt"
_s.getfile(fTxt)
out
out _s
#13
Thanks, but I thought that worked with dll...
#14
With dll much work. The functions are low level...
#15
Tip:
To minimize error count when recognizing small font text, turn off Windows font smoothing or ClearType.
I also tried various gflax functions - sharpen, 0 saturation, monochrome. Sometimes it reduces error count, sometimes not.
#16
Thank you for all.

It could be a very useful function.
#17
IrfanView has a plug-in for OCR...

Haven't gotten a chance to play around with it,
Any examples to use with command line?

Thanks,
Jimmy Vig
#18
After several tests with default settings, I see that kadmos (irfanView plugin) produces much more errors than tesseract.
#19
Thanks for putting in the time. I was just thinking of sticking with IrfanView since I already use it in a couple places.

I use the other one you have an example for.

Thanks,
Jimmy Vig
#20
It is quite possible that I am going to make a switch from IrfanView to gflax.

I do like that IrfanView has a forum where I can get solutions. (EDIT...has forum!! http://newsgroup.xnview.com/viewtopic.p ... ilit=gflax)

Thanks bunches Big Grin
#21
Hi Gintaras and QMers,

The Tesseract OCR engine has a new API and new features. It would be a wonderful improvement for QM.

Please, Gintaras, is it possible to add this stuff to QM?

Thanks for your help.
Best regards.

APIExample on Github

Stackoverflow: How to implement Tesseract to run with project in Visual Studio 2010
#22
I tested the new tesseract command-line version now, but its OCR quality is so bad, I don't want to spend more time with its API.
#23
Oh, sorry to hear that. I read somewhere that Tesseract was one of the best engines.

Thanks anyway for your help. Best regards.
#24
Is possible to use https://github.com/DanysysTeam/UWPOCR in QM?
#25
No.

LibreAutomate uses the same Windows OCR API. You can create script in LibreAutomate and create .exe or call it from QM using command line or HTTP server.
#26
Can you show an example of script in LibreAutomate/create .exe of 'Find OCR text' and how call it from QM using command line or other method?
#27
HTTP server is a fast and powerful way to call LA functions.
https://www.libreautomate.com/forum/show...p?tid=7468
https://www.libreautomate.com/forum/show...5#pid36755

Or create .exe program from script. QM can execute it without LibreAutomate. Slower, but maybe simpler.

The example script will be an exe script.

Creating .exe program

In LibreAutomate create new script.
In Poperties select role exeProgram, fill outputPath, OK.
Later click the Compile button whenever you want to create or update .exe program.

Creating OCR code

Click toolbar button or menu item "Find OCR text".
Select the target window or control with hotkey F3. Test, OK.
More info in the OCR tool window.

Script example
 
Code:
Copy      Help
// script "OCR example.cs"
/*/ role exeProgram; outputPath C:\Test\OCR example; /*/

var w = wnd.find(1, "Test", "CabinetWClass");
var c = w.Child(1, id: 100); // SysTreeView32 "Navigation Pane"
var t = ocr.find(1, c, "Test");
t.MouseClick();

You can replace some strings etc with command line parameters args[0], args[1]...
The script can return a number to indicate errors.
 
Code:
Copy      Help
// script "OCR example.cs"
/*/ role exeProgram; outputPath C:\Test\OCR example; /*/

//if (script.testing) {
//    args = new[] { "Test", "CabinetWClass", "Test" }; //window name, class, and text to find
//}


try {
    var w = wnd.find(1, name: args[0], cn: args[1]);
    var t = ocr.find(1, w, text: args[2]);
    t.MouseClick();
    return 0;
}

catch (Exception e) { print.it(e); return 1; }

Calling from QM

Macro Macro3257
Code:
Copy      Help
str cl=
;"Test" "CabinetWClass" "Test"
int ec=run("C:\Test\OCR example\OCR example.exe" cl "" "" 0x30400)
out ec
#28
Thanks.


Forum Jump:


Users browsing this thread: 1 Guest(s)