invalid floating point operation when calling TessBaseAPIAnalyseLayout

141 views
Skip to first unread message

Matthias Schneider

unread,
Jun 10, 2016, 6:00:19 AM6/10/16
to tesseract-ocr
Hi,

I'm trying to use the C-API to detect text regions on checks.
During my first tests, I ran into an 'invalid floating point operation' happening on just one of my sample images (testcheck.png).

This is my (simplified) test application:

  
   
TessBaseAPI* hTesseract = TessBaseAPICreate();
   
   
TessBaseAPIInit2(hTesseract, "", "eng", OEM_DEFAULT);
  

   
PIX *img = pixRead("testcheck.png");
   
TessBaseAPISetImage2(hTesseract, img);
   
TessBaseAPISetPageSegMode(hTesseract, PSM_AUTO);
   
TessBaseAPIAnalyseLayout(hTesseract);    // here I get the 'invalid floating point operation'

Is this a bug or am I doing something wrong?
As I already said, this happens only one some of my sample images while it works fine on others.

Matthias
testcheck.png

Tom Morris

unread,
Jun 11, 2016, 1:37:31 PM6/11/16
to tesseract-ocr
What version of Tesseract? Source or binary? If source, compiled with what compiler & compilation options? What operating system? What processor architecture? What's the stack trace for the crash?

Matthias Schneider

unread,
Jun 13, 2016, 10:22:32 AM6/13/16
to tesseract-ocr
I'm using latest dev version 3.05.00dev and I used peirick/leptonica (https://github.com/peirick/leptonica) to build libtesseract.dll and liblept.dll with Visual Studio 2015.
However, the resulting DLLs I'm using in Embarcadero C++ Builder 10.1 after I created the import libs with implib. And after doing some more debugging it looks like I found the reason: in baselinedetect.cpp there is this code:
  for (int i = 0; i < positions.size(); ++i)
     offsets
.push_back(fmod(positions[i], *m_out));

In some cases *m_out can be 0.0 causing fmod to return 'nan' on Visual Studio projects but causing an 'floating point invalid operation' on C++Builder projects.

Tom Morris

unread,
Jun 13, 2016, 4:09:19 PM6/13/16
to tesseract-ocr
On Monday, June 13, 2016 at 10:22:32 AM UTC-4, Matthias Schneider wrote:
I'm using latest dev version 3.05.00dev and I used peirick/leptonica (https://github.com/peirick/leptonica) to build libtesseract.dll and liblept.dll with Visual Studio 2015.
However, the resulting DLLs I'm using in Embarcadero C++ Builder 10.1 after I created the import libs with implib. And after doing some more debugging it looks like I found the reason: in baselinedetect.cpp there is this code:
  for (int i = 0; i < positions.size(); ++i)
     offsets
.push_back(fmod(positions[i], *m_out));

 
In some cases *m_out can be 0.0 causing fmod to return 'nan' on Visual Studio projects but causing an 'floating point invalid operation' on C++Builder projects.

Have you tried switching the floating point processing to be compatible in your target compiler?

ie the {$FINITEFLOAT OFF} directive

Tom 
Reply all
Reply to author
Forward
0 new messages