Hello,
i need help!
I get this problem after serveral used the tesseract lib. (Around 450 - 600 runs with tesseract) I will evaluate the results in different cases. (Testsuit)
I get the error messages: (After 450-600 iteration)
Error: Not enough memory! "Fatal error encountered!" == NULL:Error:Assert failed:in file ..\..\ccutil\globaloc.cpp, line 75
In jvisualvm look it good. No Memory leak is show up!
This is the code, that i will use very often: (currently work it only 450-600 times)
String dataPath = dictonaryLanguage.getAbsolutePath(); TessAPI1.TessBaseAPI handle = TessAPI1.TessBaseAPICreate(); ByteBuffer buf = ImageIOHelper.convertImageData( image ); int bpp = image.getColorModel().getPixelSize(); int bytespp = bpp / 8; int bytespl = (int)Math.ceil( image.getWidth() * bpp / 8.0 ); TessAPI1.TessBaseAPIInit3( handle, dataPath, language ); TessAPI1.TessBaseAPISetPageSegMode( handle, TessAPI1.TessPageSegMode.PSM_AUTO ); TessAPI1.TessBaseAPISetImage( handle, buf, image.getWidth(), image.getHeight(), bytespp, bytespl ); TessAPI1.TessBaseAPIRecognize( handle, null ); TessAPI1.TessResultIterator ri = TessAPI1.TessBaseAPIGetIterator( handle ); TessAPI1.TessPageIterator pi = TessAPI1.TessResultIteratorGetPageIterator( ri ); TessAPI1.TessPageIteratorBegin( pi ); do { Pointer ptr = TessAPI1.TessResultIteratorGetUTF8Text( ri, TessAPI1.TessPageIteratorLevel.RIL_WORD); if(ptr == null){ break; } String wordText = ptr.getString(0); TessAPI1.TessDeleteText(ptr); float confidence = TessAPI1.TessResultIteratorConfidence(ri, TessAPI1.TessPageIteratorLevel.RIL_WORD); IntBuffer leftB = IntBuffer.allocate( 1); IntBuffer topB = IntBuffer.allocate(1); IntBuffer rightB = IntBuffer.allocate(1); IntBuffer bottomB = IntBuffer.allocate(1); TessAPI1.TessPageIteratorBoundingBox(pi, TessAPI1.TessPageIteratorLevel.RIL_WORD, leftB, topB, rightB, bottomB); int left = leftB.get(); int top = topB.get(); int right = rightB.get(); int bottom = bottomB.get(); IntBuffer boldB = IntBuffer.allocate( 1); IntBuffer italicB = IntBuffer.allocate(1); IntBuffer underlinedB = IntBuffer.allocate(1); IntBuffer monospaceB = IntBuffer.allocate(1); IntBuffer serifB = IntBuffer.allocate(1); IntBuffer smallcapsB = IntBuffer.allocate(1); IntBuffer pointSizeB = IntBuffer.allocate(1); IntBuffer fontIdB = IntBuffer.allocate(1); String fontName = TessAPI1.TessResultIteratorWordFontAttributes(ri, boldB, italicB, underlinedB,monospaceB, serifB, smallcapsB, pointSizeB, fontIdB); Rectangle area = new Rectangle( left, top, right-left, bottom-top ); //and so on ... } while (TessAPI1.TessPageIteratorNext(pi, TessAPI1.TessPageIteratorLevel.RIL_WORD) == TessAPI1.TRUE); //I tried this //System.gc(); //but it doesn't work
Did you try end/delete and create/init a new TessBaseAPI after a number of iterations?
end/delete
create/init
TessBaseAPI
Thanks, for the fast answer, that was the solution.
Log in to post a comment.
Hello,
i need help!
I get this problem after serveral used the tesseract lib. (Around 450 - 600 runs with tesseract)
I will evaluate the results in different cases. (Testsuit)
I get the error messages: (After 450-600 iteration)
In jvisualvm look it good. No Memory leak is show up!
This is the code, that i will use very often: (currently work it only 450-600 times)
Did you try
end/delete
andcreate/init
a newTessBaseAPI
after a number of iterations?Thanks, for the fast answer, that was the solution.