Discussion:
Out of memory with MODI office 12
(too old to reply)
Ibrahim
2007-11-02 16:39:04 UTC
Permalink
Hi,
I need to use MODI to read a number of TIFF files check the compression of
the images in the files and then OCR a section of each image. Currently, i
have only implemented the code that reads the compression but Visual Studio
2005 gives me out of memory exception after it reads 477 files. Also this
number decreases each time i run the application. I have included the code i
have implemented below to see if anyone can come up with anything why this is
doing what it is doing. As you can see, i have not used the MODI object to be
part of my form, i just declared and instatiated it in code as you can see:

Private Function GetTifCompression(ByVal fileName As String, _
ByRef imageCompression As
MODI.MiCOMP_TYPE, _
ByRef imageNumber As Integer) As
Boolean

Dim result As Boolean = False

Dim imageIndex As Integer
Dim tiffDoc As MODI.Document = Nothing
Dim tiffImage As MODI.Image = Nothing
Dim tiffLayout As MODI.Layout = Nothing

Try

tiffDoc = New MODI.Document()
tiffDoc.Create(fileName)

tiffDoc.OCR(MiLANGUAGES.miLANG_ENGLISH)

Dim numImages As Integer = tiffDoc.Images.Count

If numImages > 1 Then
SendMessage(DISPLAY_ID.PROPGRESS, ".....There are more than
one image in this file.")
End If

If numImages <> 0 Then
For imageIndex = 0 To numImages - 1

' Each image in the TIFF file has its own compression
tiffImage = tiffDoc.Images(imageIndex)

tiffLayout = tiffImage.Layout()

imageCompression = tiffImage.Compression

imageNumber = imageIndex

result = True
Next
End If

Catch ex As Exception

SendMessage(DISPLAY_ID.FINAL_RESULT_ERROR, _
"Exception occured in reading the TIFF image : <" &
ex.Message & ">.")

Finally

tiffDoc.Close()
tiffLayout = Nothing
tiffImage = Nothing
tiffDoc = Nothing

End Try

Return result

End Function
--
Thank you,
Ibrahim
Ibrahim
2007-11-03 02:02:00 UTC
Permalink
Hi this is Ibrahim,
I found out that if i use the ToolBox and drop of an instance of the MODI
object onto my form and send messages from procesing thread to the ui thread,
i can process all the images i want with no exceptions as quickly as they can
be pumped.
Sometimes, we need to just do what these objects are designed for :-).
thanks, hope someone else out there can benefit from this.
Bye for now.
--
Thank you,
Ibrahim
Post by Ibrahim
Hi,
I need to use MODI to read a number of TIFF files check the compression of
the images in the files and then OCR a section of each image. Currently, i
have only implemented the code that reads the compression but Visual Studio
2005 gives me out of memory exception after it reads 477 files. Also this
number decreases each time i run the application. I have included the code i
have implemented below to see if anyone can come up with anything why this is
doing what it is doing. As you can see, i have not used the MODI object to be
Private Function GetTifCompression(ByVal fileName As String, _
ByRef imageCompression As
MODI.MiCOMP_TYPE, _
ByRef imageNumber As Integer) As
Boolean
Dim result As Boolean = False
Dim imageIndex As Integer
Dim tiffDoc As MODI.Document = Nothing
Dim tiffImage As MODI.Image = Nothing
Dim tiffLayout As MODI.Layout = Nothing
Try
tiffDoc = New MODI.Document()
tiffDoc.Create(fileName)
tiffDoc.OCR(MiLANGUAGES.miLANG_ENGLISH)
Dim numImages As Integer = tiffDoc.Images.Count
If numImages > 1 Then
SendMessage(DISPLAY_ID.PROPGRESS, ".....There are more than
one image in this file.")
End If
If numImages <> 0 Then
For imageIndex = 0 To numImages - 1
' Each image in the TIFF file has its own compression
tiffImage = tiffDoc.Images(imageIndex)
tiffLayout = tiffImage.Layout()
imageCompression = tiffImage.Compression
imageNumber = imageIndex
result = True
Next
End If
Catch ex As Exception
SendMessage(DISPLAY_ID.FINAL_RESULT_ERROR, _
"Exception occured in reading the TIFF image : <" &
ex.Message & ">.")
Finally
tiffDoc.Close()
tiffLayout = Nothing
tiffImage = Nothing
tiffDoc = Nothing
End Try
Return result
End Function
--
Thank you,
Ibrahim
benjamin chou
2011-08-05 00:38:49 UTC
Permalink
hi, Ibrahim,

From your last response:

"I found out that if i use the ToolBox and drop of an instance of the MODI object onto my form and send messages from procesing thread to the ui thread,
i can process all the images i want with no exceptions as quickly as they can be pumped."

Can you give us more specific instructions? Thanks very much.

Ben
Post by Ibrahim
Hi,
I need to use MODI to read a number of TIFF files check the compression of
the images in the files and then OCR a section of each image. Currently, i
have only implemented the code that reads the compression but Visual Studio
2005 gives me out of memory exception after it reads 477 files. Also this
number decreases each time i run the application. I have included the code i
have implemented below to see if anyone can come up with anything why this is
doing what it is doing. As you can see, i have not used the MODI object to be
Private Function GetTifCompression(ByVal fileName As String, _
ByRef imageCompression As
MODI.MiCOMP_TYPE, _
ByRef imageNumber As Integer) As
Boolean
Dim result As Boolean = False
Dim imageIndex As Integer
Dim tiffDoc As MODI.Document = Nothing
Dim tiffImage As MODI.Image = Nothing
Dim tiffLayout As MODI.Layout = Nothing
Try
tiffDoc = New MODI.Document()
tiffDoc.Create(fileName)
tiffDoc.OCR(MiLANGUAGES.miLANG_ENGLISH)
Dim numImages As Integer = tiffDoc.Images.Count
If numImages > 1 Then
SendMessage(DISPLAY_ID.PROPGRESS, ".....There are more than
one image in this file.")
End If
If numImages <> 0 Then
For imageIndex = 0 To numImages - 1
' Each image in the TIFF file has its own compression
tiffImage = tiffDoc.Images(imageIndex)
tiffLayout = tiffImage.Layout()
imageCompression = tiffImage.Compression
imageNumber = imageIndex
result = True
Next
End If
Catch ex As Exception
SendMessage(DISPLAY_ID.FINAL_RESULT_ERROR, _
"Exception occured in reading the TIFF image : <" &
ex.Message & ">.")
Finally
tiffDoc.Close()
tiffLayout = Nothing
tiffImage = Nothing
tiffDoc = Nothing
End Try
Return result
End Function
--
Thank you,
Ibrahim
Post by Ibrahim
Hi this is Ibrahim,
I found out that if i use the ToolBox and drop of an instance of the MODI
object onto my form and send messages from procesing thread to the ui thread,
i can process all the images i want with no exceptions as quickly as they can
be pumped.
Sometimes, we need to just do what these objects are designed for :-).
thanks, hope someone else out there can benefit from this.
Bye for now.
--
Thank you,
Ibrahim
Loading...