ronriel Posted October 21, 2008 Posted October 21, 2008 Hello, I would like to share this. You need to have MS Office 2003 or 2007 Document Imaging installed for this to work. Returns: [0][0] - number of recognized words in a containing image [1][1] - Returns the distance in pixels of the left edge of the specified rectangle from the left edge of the containing image. [1][2] - Returns the distance in pixels of the top edge of the specified rectangle from the top edge of the containing image. [1][3] - Returns the width of the specified rectangle. [1][4] - Returns the height of the specified rectangle. expandcollapse popup; #FUNCTION# ==================================================================================================== ================ ; Name.......: OCR_GetWordsCoordinates ; Description: Performs optical character recognition (OCR) on a specified image file, and then reports the coordinates ; and size of the bounding rectangle surrounding each word in the recognized text. ; Author ....: ronriel ; ==================================================================================================== =========================== Func OCR_GetWordsCoordinates($Image) Local $error = ObjEvent("AutoIt.Error","Error"),$items[1][5] $miDoc = ObjCreate("MODI.Document") $miDoc.Create($Image) If @error Then Return SetError(1,0,-1) $miDoc.Ocr(9, True, True) If @error Then Return SetError(2,0,-1) EndIf $items[0][0] = $miDoc.Images(0).Layout.Numwords;number of recognized words in a containing image For $y = 1 to $items[0][0] ReDim $items[$y+1][5] $items[$y][0] = $miDoc.Images(0).Layout.Words($y-1).text;the recognized word For $miRect In $miDoc.Images(0).Layout.Words($y-1).Rects $items[$y][1] = $miRect.Left;Returns the distance in pixels of the left edge of the specified rectangle from the left edge of the containing image. $items[$y][2] = $miRect.Top ;Returns the distance in pixels of the top edge of the specified rectangle from the top edge of the containing image. $items[$y][3] = $miRect.Right - $miRect.Left;width of the specified rectangle $items[$y][4] = $miRect.Bottom - $miRect.Top ;height of the specified rectangle Next Next Return $items EndFunc Func Error() Endfunc ;EXAMPLE #include<array.au3> $a = FileOpenDialog("Choose an Image File",@DesktopDir&"\","Images (*.jpg;*.bmp;*.gif;*.png;*.tif)") If @error then Return $b = OCR_GetWordsCoordinates($a) _ArrayDisplay($b) I hope this is useful. [font="Comic Sans MS"]-ronriel[/font][topic="48542"]r4r media player[/topic][topic="80836"]OCR & Paste[/topic]
Michel Claveau Posted October 21, 2008 Posted October 21, 2008 Hi! Very interesting. With that, I can locate a form filled with the hand, and digitized.
hornet Posted June 20, 2010 Posted June 20, 2010 Will this script work if I use Tesseract to capture an image and then search for specific text in the image then have the mouse click at that location? -hornet
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now