Memory Leak
-
- Posts: 6
- Joined: Mon Mar 02, 2009 11:56 am
Memory Leak
The OCR is working fine but after 4 hours of use it falls over with the following error:
-1705 MEM_ALLOC's used
Error: Memfree of NULL pointer!
Fatal error: No error trap defined!
Signal_termination_handler called with signal 0
and this kills my application with no chance for me to catch the exception. Any ideas of how to resolve this or at least stop it from killing the entire application.
-1705 MEM_ALLOC's used
Error: Memfree of NULL pointer!
Fatal error: No error trap defined!
Signal_termination_handler called with signal 0
and this kills my application with no chance for me to catch the exception. Any ideas of how to resolve this or at least stop it from killing the entire application.
Re: Memory Leak
Hi,
I need some help to help you
- Are you using the OCR in GdPicture ActiveX or .NET ?
- Are you sure the error message came form the OCR engine ?
- Could you give more information about the way you apply OCR process ? (kind of image ?, ocr on area ?, are you using the same object ?, an idea of the number of OCR process...)
Best regards,
Loïc
I need some help to help you
- Are you using the OCR in GdPicture ActiveX or .NET ?
- Are you sure the error message came form the OCR engine ?
- Could you give more information about the way you apply OCR process ? (kind of image ?, ocr on area ?, are you using the same object ?, an idea of the number of OCR process...)
Best regards,
Loïc
-
- Posts: 6
- Joined: Mon Mar 02, 2009 11:56 am
Re: Memory Leak
I am using the ocr in .net
Near 100% sure the error came from the OCR engine as it was in the tesseract.log file created the app does not even throw an error it just dies.
The image is of four numbers and I am using a new object for each OCR attempt. Its anoying as the OCR works every time but it does not release the memory so eventually the app just crashes. As for number it varies from 10 to 30.
Near 100% sure the error came from the OCR engine as it was in the tesseract.log file created the app does not even throw an error it just dies.
The image is of four numbers and I am using a new object for each OCR attempt. Its anoying as the OCR works every time but it does not release the memory so eventually the app just crashes. As for number it varies from 10 to 30.
Re: Memory Leak
Hi,
Could you give me a code snippet of your OCR process ?
Maybe you don't release all image handles ?
Also, if you can send me the image on which the OCR crash it can be a great help for me.
Best regards,
Loïc
Could you give me a code snippet of your OCR process ?
Maybe you don't release all image handles ?
Also, if you can send me the image on which the OCR crash it can be a great help for me.
Best regards,
Loïc
-
- Posts: 6
- Joined: Mon Mar 02, 2009 11:56 am
Re: Memory Leak
My code is as follows and I will email the images now.
Code: Select all
public String ConvertImageToString(String Filename)
{
String rtnValue;
int iImageID;
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
int iImageWidth;
int iImageHeight;
// initialise GDPicture
oGdPictureImaging.SetLicenseNumber("???????????????????????????????????????????????????"); // This is the commercial license key.
oGdPictureImaging.SetLicenseNumberOCRTesseract("???????????????????????????????????????????????????"); // This is the commercial license key.
// grab the image
iImageID = oGdPictureImaging.CreateGdPictureImageFromFile(Filename);
// get the dimensions
iImageWidth = oGdPictureImaging.GetWidth(iImageID);
iImageHeight = oGdPictureImaging.GetHeight(iImageID);
// crop any borders off
oGdPictureImaging.Crop(iImageID, 1, 1, iImageWidth - 2, iImageHeight - 2);
// resize the image
oGdPictureImaging.Resize(iImageID, iImageWidth + 200, iImageHeight + 200, GdPicture.InterpolationMode.InterpolationModeDefault);
// reduce to 1bpp
oGdPictureImaging.ConvertTo1Bpp(iImageID);
oGdPictureImaging.FxBitonalDilate4(iImageID);
// do the OCR
oGdPictureImaging.OCRTesseractClear();
rtnValue = oGdPictureImaging.OCRTesseractDoOCR(iImageID, TesseractDictionary.TesseractDictionaryEnglish, "C:\\Program Files\\GdPicture.NET\\Redist\\OCR\\", "12343576890");
// release the image
oGdPictureImaging.OCRTesseractClear();
oGdPictureImaging.ReleaseGdPictureImage(iImageID);
return rtnValue;
}
Re: Memory Leak
Ok I probably found your problem.
Try to replace:
by:
Hope this solve your issue.
With best regards,
Loïc
Try to replace:
Code: Select all
// do the OCR
oGdPictureImaging.OCRTesseractClear();
rtnValue = oGdPictureImaging.OCRTesseractDoOCR(iImageID, TesseractDictionary.TesseractDictionaryEnglish, "C:\\Program Files\\GdPicture.NET\\Redist\\OCR\\", "12343576890");
// release the image
oGdPictureImaging.OCRTesseractClear();
Code: Select all
// do the OCR
rtnValue = oGdPictureImaging.OCRTesseractDoOCR(iImageID, TesseractDictionary.TesseractDictionaryEnglish, "C:\\Program Files\\GdPicture.NET\\Redist\\OCR\\", "12343576890");
// release the image
oGdPictureImaging.OCRTesseractReinit();
Hope this solve your issue.
With best regards,
Loïc
-
- Posts: 6
- Joined: Mon Mar 02, 2009 11:56 am
Re: Memory Leak
Sorry but this still has not solved the issue. Memory is still not being released and after a number of OCR's it pulls the entire app with no catchable error message.
Re: Memory Leak
Hi,
Please download the last edition from here: https://www.gdpicture.com/download/downl ... urenet.php
I made tests with success on the images you sent me. See the code below (169000 ocr process without 1 kb of memory leak).
Best regards,
Loïc
Please download the last edition from here: https://www.gdpicture.com/download/downl ... urenet.php
I made tests with success on the images you sent me. See the code below (169000 ocr process without 1 kb of memory leak).
Code: Select all
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim storefile As Directory
Dim files As String()
Dim File As String
files = storefile.GetFiles("C:\Debug\", "*")
For i As Integer = 1 To 100
For Each File In files
Debug.Print(ConvertImageToString(File))
Next
Label1.Text = Str(i)
Application.DoEvents()
Next i
MsgBox("end!")
End Sub
Public Function ConvertImageToString(ByVal Filename As String) As String
Dim rtnValue As String
Dim iImageID As Integer
Dim oGdPictureImaging As New GdPicture.GdPictureImaging
Dim iImageWidth As Integer
Dim iImageHeight As Integer
' initialise GDPicture
oGdPictureImaging.SetLicenseNumber("XXX") ' This is the commercial license key.
oGdPictureImaging.SetLicenseNumberOCRTesseract("XXX") 'This is the commercial license key.
' grab the image
iImageID = oGdPictureImaging.CreateGdPictureImageFromFile(Filename)
'get the dimensions
iImageWidth = oGdPictureImaging.GetWidth(iImageID)
iImageHeight = oGdPictureImaging.GetHeight(iImageID)
' crop any borders off
oGdPictureImaging.Crop(iImageID, 1, 1, iImageWidth - 2, iImageHeight - 2)
' resize the image
oGdPictureImaging.Resize(iImageID, iImageWidth + 200, iImageHeight + 200, GdPicture.InterpolationMode.InterpolationModeDefault)
' reduce to 1bpp
oGdPictureImaging.ConvertTo1Bpp(iImageID)
oGdPictureImaging.FxBitonalDilate4(iImageID)
' do the OCR
'oGdPictureImaging.OCRTesseractReinit()
'oGdPictureImaging.OCRTesseractClear()
rtnValue = oGdPictureImaging.OCRTesseractDoOCR(iImageID, GdPicture.TesseractDictionary.TesseractDictionaryEnglish, "C:\Program Files\GdPicture.NET\Redist\\OCR\", "12343576890")
Label2.Text = rtnValue
'release the image
'oGdPictureImaging.OCRTesseractClear()
oGdPictureImaging.ReleaseGdPictureImage(iImageID)
'oGdPictureImaging = Nothing
Return rtnValue
End Function
Best regards,
Loïc
-
- Posts: 6
- Joined: Mon Mar 02, 2009 11:56 am
Re: Memory Leak
Well you have fixed the memory leak but caused the OCR success rate to drop from 90% to 50%. Please let me know how to get this back up.
Re: Memory Leak
Hi,
For me on 100 images 75 are OK... => 75% (which can be improved -> see below).
The problem come from your image processing which is not adapted at all to your images.
With this processing I got around 95% of accuracy and better time performances with the image you sent me:
The accuracy can also be improved if you keep the same imaging object to make ocr process. instead creating 1 object per OCR process, try to create one object for 100 process.
Best regards,
Loïc
Well you have fixed the memory leak but caused the OCR success rate to drop from 90% to 50%
For me on 100 images 75 are OK... => 75% (which can be improved -> see below).
The problem come from your image processing which is not adapted at all to your images.
With this processing I got around 95% of accuracy and better time performances with the image you sent me:
Code: Select all
oGdPictureImaging.Crop(m_ImageID, 1, 1, oGdPictureImaging.GetWidth(m_ImageID) - 2, oGdPictureImaging.GetHeight(m_ImageID) - 2)
oGdPictureImaging.Scale(m_ImageID, 300, InterpolationMode.InterpolationModeHighQualityBicubic)
oGdPictureImaging.ConvertTo1Bpp(m_ImageID)
oGdPictureImaging.FxBitonalErode4(m_ImageID)
Best regards,
Loïc
-
- Posts: 6
- Joined: Mon Mar 02, 2009 11:56 am
Re: Memory Leak
Thanks, this worked a treat. We now have a system that is working at nearly 100% sucess rate.
Re: Memory Leak
Good new !
Thank you for your feedback.
With the image you have you can get near than 99% of accuracy with a bit of research...
The idea is to make 2 OCR process with 2 different image processing & comparing the result in order to keep the process having the best relevance. However this take twice processing time but maybe it's not a problem.
Best regards,
Loïc
Thank you for your feedback.
With the image you have you can get near than 99% of accuracy with a bit of research...
The idea is to make 2 OCR process with 2 different image processing & comparing the result in order to keep the process having the best relevance. However this take twice processing time but maybe it's not a problem.
Best regards,
Loïc
Who is online
Users browsing this forum: No registered users and 2 guests