Testing MODI Ocr

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
pantik
Junior Coder
Posts: 45
Joined: Sun Dec 13, 2009 5:52 pm

Testing MODI Ocr

Post by pantik » Tue Jan 12, 2010 3:41 pm

I have created this script to test MODI Ocr but this ocr doesnt work too well. When the captured bitmap contains only one line the ocr gets nothing i.e. MODI Ocr needs two line to recognize the text (you can easyly test it with my script) Also it is not very accurate and it fails in carriage returns and spaces.

Do you know a better ocr or do i need changue my VB function?
THANKS BY ADVANCE

Code: Select all

VBStart
Function DoOCR(bitmapfile)
  Dim miDoc
  Dim miLayout
  Dim stringOut

  set miDoc=CreateObject("MODI.Document")
  miDoc.Create (bitmapfile)
  ' Perform OCR.
  'You can change the mousepointer here to an hourglass or something.
  miDoc.Images(0).OCR
  'Change the mouse back to normal default.
  set miLayout = miDoc.Images(0).Layout
  stringOut=miLayout.Text
  'MsgBox(stringOut)
  DoOCR = stringOut
  Set miLayout = Nothing
  Set miDoc = Nothing
End Function
VBEND

Dialog>Dialog
   Caption=OCR
   Width=649
   Height=338
   Top=128
   Left=267
   Button=Capture,231,265,75,25,1
   Button=Exit,335,265,75,25,2
   Memo=msMemo1,344,17,282,224,
   Image=,21,17,282,224,msImage1,0
EndDialog>Dialog

srt>ocr
  WaitKeyDown>vk17
  GetCursorPos>X1,Y1
  LibFunc>kernel32,Beep,r,300,50
  Wait>0.5
  WaitKeyDown>vk17
  GetCursorPos>X2,Y2
  LibFunc>kernel32,Beep,r,300,50
  ScreenCapture>X1,Y1,X2,Y2,%SCRIPT_DIR%\capture.bmp
  VBeval>Doocr("%SCRIPT_DIR%\capture.bmp"),text
END>ocr

label>start

show>dialog
label>dialogloop
GetDialogAction>dialog,r
  if>r=1
  CloseDialog>dialog
  gosub>ocr
  Let>flag=1
  goto>start
  endif
  if>r=2,exit
  if>flag=1
  Let>dialog.msImage1=%SCRIPT_DIR%\capture.bmp
  Let>dialog.msMemo1=text
  Let>flag=0
  ResetDialogAction>dialog
  endif
Wait>0.1
goto>dialogloop
label>exit
exit
P.S. The script use control key to indicate topleft and buttonright coordinates of the area that you want capture.

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

MODI OCR issues

Post by gdyvig » Tue Jan 12, 2010 4:44 pm

Hi pantik,

I have not looked over your script yet, but if you search the forums (and the site) for "MODI" you will find several discussions about MODI issues.

No OCR is 100% accurate.
MODI needs some space bordering the expected text, about half a font height worth or it will fail to find the text or will misinterpret it.

It can also be fooled by graphics near the text, expecially if the graphic is the same color as the font and resembles text.

It may also have better luck with some fonts than others. If you have control over the font you may want to experiment with that.

MODI seems to do quite well for a general purpose OCR. It also has the advanatage returning the coordinates of the found text (Do a search on MODI click on text).


Gale

pantik
Junior Coder
Posts: 45
Joined: Sun Dec 13, 2009 5:52 pm

Post by pantik » Tue Jan 12, 2010 5:59 pm

Yes, i have read the posts about MODI and I know what you say. By the way, i already saw your script to click on text by modi and it is a good job. Thank you.

Anyway i still have not the enough knowledge to use VB function and edit the ocr functioning, i only copy and paste yours code in my scripts :). But i am sure that there is better ocr or the code may be improved. it does not make sense for me ocr fails in situation as these:

Image
There is short space bordering the text but i get 100% accurate.

Image
There is enough space however I get nothing (null)

This capture is done with notepad and arial font:
Image
I get the carriage retunr but it fail:
asdfasdf 123
asdfasdf 123
asdfasdtl23

Image
I dont get carriage return, ... and so on.

will not i be able to find nothing better than this ?

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Alternative OCR

Post by gdyvig » Tue Jan 12, 2010 6:42 pm

Hi Pantik,

Here is another OCR mentioned in this artical. I tried it an it was better than MODI for some fonts. At the time I tested it it had trouble with underlined letters with tails (gjpq) and it does not return the location of the text.

http://www.mjtnet.com/blog/2006/06/06/s ... ical-text/


I also tried the OCR built into some other testing tools. They had similar problems if you are seeking 100% accuracy.

When testing whether the captured text represents what you are looking for you may have to do some "fuzzy" matches. Try removing spaces from both the expected and actual results. Try comparing individual words and syllables. Capture an image to compare with nonsensical text.

Another alternative is to use ImageRecognition instead of OCR. This can be doable if you have a manageable number of possible words in the application.


Gale

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

MODI

Post by kpassaur » Mon Jan 18, 2010 9:49 pm

Understanding MODI and other OCR engines.

MODI is an OCR engine owned by Nunance formly ScanSoft the makers of Omni Page. It is not their newest or best engine, but it is included for free in some versions of Microsoft Office. No, it is not in all versions of Office and I have never been able to find a list that states which ones have it and which do not. On some vesions such as 2003 it will be installed on the first run. On 2007 you need to find it on your CD. If you have an old version and upgrade the old version is not removed first and you will have issues.

If that is the case uninstall both versions then search for MSPview.exe, delete the folders it was stored in (if it remains), run a registry cleaner and then reinstall. This may sound excessive, but trust me it will save on difficulties later.


As for the quality of MODI OCR a client had me compare numerous OCR engines including, MODI, OmniPage, TypeReader (Expervision), Abby etc. and the results from all major engines including MODI were very similar. One engine may have done better on one document but not another (see the comment about fonts above). So at the end of the day the results were very similar on all major OCR engines with some better on one document and others better on a different document. Notice how I said on all major engines, the free and cheap ones are really not worth it.

As noted above no OCR engine is 100 percent accurate. When they claim they are 99.0 percent accurate it is per character not per document.

So do the math, if you are collecting 10 digit invoice numbers and capture 100 files you will have 1000 digits captured. With 99.0 percent accuracy that means there are 10 incorrect ones, if these fall on 10 different documents it means only 90 are correct on your 100 invoices which is 10 percent failure for your documents.

There are many ways to increase this accuracy rate. One is a weighted average. Two or more OCR engines are used and the results compared.

Another is Fuzzy logic as mentioned above. When you view OCR you will see a zero "0" come back as a lower case "o" or upper case one "O". This is common and if you know you can only have numbers it is an easy replacement. Since all fonts are different the results will be so when building Fuzzy logic look to see what is returned. For instance another common one is a "B" being read when it is supposed to be an "8". Now start looking at "R"s and "6"s.

The next thing you can to is verification. When you are OCRing a file and a database relates to it, OCR more than one item and use the tools in MS to verify it with what exists in a database.

MODI text cannot be extracted in a formatted manner. That is the major difficulty with it. So you need to spend time parsing the data in a manner that works when it is not always in the same place. Now I said it could not be extracted in a manner that is formated, which some will say is not true because it can be exported to Word with some of the formating in tact. However it does not seem to allow it to be done by directly accessing MODI.

If you do everything possible you can get one out of a thousand failure rate on OCR (I have done it) and if you did everything right you can trap it for manual review.

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

MODI

Post by kpassaur » Mon Jan 18, 2010 9:59 pm

One more comment, it fails with spaces and carriage returns on purpose. It is built into the formatting for MODI. To prove this OCR a file in MODI, search the contents and they will be aligned. Now copy and paste it into Notepad and you may have spaces and carriage returns. I am sure when Nuance licensed it to Microsoft they built this in on purpose.

Hint: If your image comes back with no OCR because it is small place a border around it, do not increase the area captured and you will get better results.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts