OCR with MODI

  • Thread starter David de Passos
  • Start date
D

David de Passos

Hi!

I'm using MODI activex from Microsoft Office 2003 and Microsoft VB.NET to
get the text from an OCR acquired image.

Why after OCR the image, the MODI component rotate the image?

Sometimes the MODI rotates the image 90 degrees and the OCR, obviously, can'
t do its job. Any ideia why this is happening?

There is my code:



Dim miDoc As MODI.Document

Dim miWord() As MODI.Word

Dim strWordInfo As String

Dim i, j As Long

Dim str As String

Dim Cont As Long

Dim IMG As Long

miDoc = New MODI.Document

miDoc.Create("C:\MultiPage.tif")

str = ""

Cont = 0

IMG = miDoc.Images.Count - 1



miDoc.OCR(MiLANGUAGES.miLANG_ENGLISH, True, True)

For j = 0 To IMG

miDoc.Images(j).rotate(0)

For i = 0 To miDoc.Images(j).Layout.Words.count - 1

ReDim Preserve miWord(Cont)

miWord(Cont) = miDoc.Images(j).Layout.Words(i)

Cont += 1

Next

Next

For i = 0 To miWord.Length - 1

str = str & " " & miWord(i).Text

Next

miDoc.Close(False)

miWord = Nothing


--


Cumprimentos,
David de Passos
--------------------------------------------------------------
RCSOFT, Lda.
E-Mail: (e-mail address removed)
Móvel: +351 966931639
Telefone: +351 239708708
Fax: +351 239708701
Tel. Directo: +351 239708705 ext. 401
 
K

Kashif Javed

Try using the following Function to get the text out of an image. Just
pass a file name with full path and it will return the text out of that
file. Its working fine for me without doing anything to the original
image file. I hope it will help.


Public Function fncOCR_Text(ByVal strImagePath As String) As String

'declaring required variables for OCR
Dim miDoc As MODI.Document
Dim miLayout As MODI.Layout
Dim strLayoutInfo As String
Dim strText As String

'Recognizing the Document
Set miDoc = New MODI.Document
miDoc.Create strImagePath
miDoc.Images(0).OCR

'Storing the value in a variable and returning it
Set miLayout = miDoc.Images(0).Layout
strText = Trim(miLayout.Text)
fncOCR_Text = strText

'Rleasing the Memory
Set miLayout = Nothing
Set miDoc = Nothing

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top