Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OCR
#1
What about OCR...
#2
Not in near future.
#3
I was looking for...

I found this:

http://www.autoitscript.com/forum/index....ntry383144

How use this in QM?
#4
Code:
Copy      Help
str img="$desktop$\clipboard.tif" ;;this is an image containing text

typelib MODI {A5EDEDF4-2BBC-45F3-822B-E60C278A1A79} 11.0
MODI.Document doc._create

doc.Create(img.expandpath)
doc.OCR(MODI.miLANG_ENGLISH -1 0)

MODI.Image im=doc.Images.Item(0)
str s=im.Layout.Text

out s ;;and this is the text


MS Office must be installed. Don't know what is the minimal version. I have Office 2003.
#5
very nice! i can really use this thanks.
#6
Almost every other time I run the OCR, I get this error. If I back out and restart, it sometimes will work, sometimes not.

any ideas?
(running latest version of QM on Windows XP

Error (RT) in OCR-MLS-Trigger: 0xC6C81091,
OCR running error


Code:
Copy      Help
POINT+ OCRpos; xm(OCRpos)
CaptureRect5 OCRpos.x OCRpos.y-100 100 100

str img="$common documents$\My QM Share\clipboard.bmp" ;;this is an image containing text


typelib MODI {A5EDEDF4-2BBC-45F3-822B-E60C278A1A79} 11.0
MODI.Document doc._create

doc.Create(img.expandpath)
doc.OCR(MODI.miLANG_ENGLISH -1 0)

MODI.Image im=doc.Images.Item(0)
str s=im.Layout.Text
act win("Display" "#32770" "" 1);err
'1
out s ;;and this is the text
;str mls.format("There is a midline shift of %s" s)
#7
This is weird,

It works everytime by keyboard trigger but not by menu item call of the macro. Strange. Does that help anyone figure this out?

Thanks!!,
Stuart
#8
Maybe you'll find some information about it on the internet. Search for "OCR running error". Or in MODI (microsoft office document imaging) documentation, which should be somewhere in the MSDN library.
#9
That error is generated when the OCR engine fails to recognize text. It fails if there is no text, or only single character. In some places it fails with no obvious reason. For example, fails to recognize www button text in this web page, whereas recognizes text of other similar buttons.

To test, I used this macro.
Code:
Copy      Help
;This macro OCRs text by the mouse pointer.

out
str s

;1. Capture screen area by the mouse pointer and save to a temporary image file.

POINT p; xm p; p.x-4; p.y-8 ;;get mouse pointer position and make some correction
int wid(300) hei(30) ;;width and height of the screen area
str img="$desktop$\qm ocr temp.bmp" ;;temporary image file

CaptureRect p.x p.y wid hei img ;;capture and save

;2. Use MS Office Imaging to convert the image file to text.

typelib MODI {A5EDEDF4-2BBC-45F3-822B-E60C278A1A79} 11.0

MODI.Document doc._create
doc.Create(img.expandpath) ;;load the file

doc.OCR(MODI.miLANG_ENGLISH -1 0); err s="FAILED"; goto g1 ;;convert to text

MODI.Image im=doc.Images.Item(0) ;;first page
s=im.Layout.Text

;3. Show results.

;g1
RECT r; r.left=p.x; r.top=p.y; r.right=r.left+wid; r.bottom=r.top+hei
OnScreenRect 1 &r
OnScreenDisplay s 0 0 0 0 0 0xff 2
OnScreenRect 2 &r

CaptureRect is here

Quote:It works everytime by keyboard trigger but not by menu item call of the macro. Strange. Does that help anyone figure this out?

Maybe because the menu is still fading out at that time. Wait 0.5 s.
#10
Will try it out and let you know
Thanks a million....
Stuart
#11
Gindi, Stu, et al.

I have used Gindi's macro above for years and it's been great. I have now upgraded to Office 2010, but as you may be aware, MODI is gone Sad Per this link below, the OCR capability is now in OneNote.

If you or anyone else out there would like a QM puzzle Big Grin ....namely making a similar macro that runs off the OneNote typelib, this user would greatly appreciate it. Hopefully others too.

http://answers.microsoft.com/en-us/offi ... f9f3ac1323
#12
MODI can be installed without Office. Free.
http://support.microsoft.com/kb/982760
#13
I installed SharePoint Designer (only Microsoft Office Document Imaging) on Windows 8. It works. Type library version must be 12.

Macro MODI
Code:
Copy      Help
str fBmp="$temp$\qm_modi.bmp"
fBmp.expandpath

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

;convert to text
;typelib MODI {A5EDEDF4-2BBC-45F3-822B-E60C278A1A79} 11.0
typelib MODI {A5EDEDF4-2BBC-45F3-822B-E60C278A1A79} 12.0
MODI.Document doc._create

doc.Create(fBmp)
doc.OCR(MODI.miLANG_ENGLISH -1 0)

MODI.Image im=doc.Images.Item(0)
str s=im.Layout.Text

;show results
;out
out s

Tried to use MODI dlls without installing, but does not work. Creates object, but fails at doc.Create.
#14
Okay, thanks for the info. Does not work unless installed, eh??? Gee, it's like you've read my mind Big Grin ...like there's no end to your talents....at all :o ...because I need to do it with what's already on the machine (no machine modifications allowed). I will play with OneNote and report back to the forum, probably with failure...but you never know....miracles do happen.


Forum Jump:


Users browsing this thread: 1 Guest(s)