Jump to content

Real OCR in AU3 - in a few lines.


ptrex
 Share

Recommended Posts

It's work!!!

Even with jpg/bmp images!

Thanks a lot!

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

@ptrex

Have a nice weekend !!

Thanks! And you to!

Here i made from this great work of yours somthing like UDF:

#include <Array.au3>

Global Const $miLANG_CZECH = 5
Global Const $miLANG_DANISH = 6
Global Const $miLANG_DUTCH = 19
Global Const $miLANG_ENGLISH = 9
Global Const $miLANG_FINNISH = 11
Global Const $miLANG_FRENCH = 12
Global Const $miLANG_GERMAN = 7
Global Const $miLANG_GREEK = 8
Global Const $miLANG_HUNGARIAN = 14
Global Const $miLANG_ITALIAN = 16
Global Const $miLANG_JAPANESE = 17
Global Const $miLANG_KOREAN = 18
Global Const $miLANG_NORWEGIAN = 20
Global Const $miLANG_POLISH = 21
Global Const $miLANG_PORTUGUESE = 22
Global Const $miLANG_RUSSIAN = 25
Global Const $miLANG_SPANISH = 10
Global Const $miLANG_SWEDISH = 29
Global Const $miLANG_TURKISH = 31
Global Const $miLANG_CHINESE_SIMPLIFIED = 2052
Global Const $miLANG_CHINESE_TRADITIONAL = 1028

Global $oMyError = ObjEvent("AutoIt.Error","OCRErrFunc")

$sArray = OCRGet("C:\Temp\Numbers.tif", $miLANG_ENGLISH)
ConsoleWrite(@error)

_ArrayDisplay($sArray, "OCR Result")


Func OCRGet($Image, $Lang=9)
    Local $sArray[1], $oWord
    
    Local $miDoc = ObjCreate("MODI.Document")
    $miDoc.Create($Image)
    If @error Then Return SetError(1)
    
    $miDoc.Ocr($Lang, True, False)
    If @error Then Return SetError(2)
    
    For $oWord In $miDoc.Images(0).Layout.Words
        ReDim $sArray[UBound($sArray)+1]
        $sArray[UBound($sArray)-1] = $oWord.Text
    Next
    $sArray[0] = UBound($sArray)-1
    Return $sArray
EndFunc

;------------------------------ This is a COM Error handler --------------------------------
Func OCRErrFunc()
  $HexNumber = hex($oMyError.number, 8)
  Msgbox(0,"COM Error Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext)
  SetError(1)  ; to check for after this function returns
Endfunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • Moderators

Seems the size of the bmp/tif/whatever matters here... If your width and height of the pic isn't big enough, it throws errors... I haven't gotten the exact height needed yet specifically, but I know that 100 width and 12 height isn't working so well. Just an FYI for others, or if others haven't found that issue, maybe more of an eye opener for me :)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

@all

I went already a bit further and threw in a VIEWER in the game.

See updated First post.

Just playing around, gives a lot a possibilties.

Making this all in a UDF is to premature I think

Regards,

ptrex

Edited by ptrex
Link to comment
Share on other sites

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 1 month later...

I installed all components of Office XP and there isn't a folder C:\Program Files\Common Files\Microsoft Shared\MODI or the MODI component in registry.

Is there another possibility to install this component?

10x

Strength is irrelevant. Resistance is futile. We wish to improve ourselves. We will add your biological and technological distinctiveness to our own. Your culture will adapt to service ours.

Link to comment
Share on other sites

Hi!

I installed all components of Office XP and there isn't a folder C:\Program Files\Common Files\Microsoft Shared\MODI or the MODI component in registry.

+1

When I search, I find that Office installed the component "Office-Imaging", to make OCR. But, no trace of MODI.

I use Office-XP-professional-French.

Any idea?

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 2 weeks later...

Tested on Windows Vista with Office 2007. It works great!.

I'm only asking how to authorize the compiled exe in order to avoid these annoying warning security dialogs.

Thank you very much for sharing.

Roy.

Link to comment
Share on other sites

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...