OCR Divide By Zero Exception

PDF-X OCR SDK is a New product from us and intended to compliment our existing PDF and Imaging Tools to provide the Developer with an expanding set of professional tools for Optical Character Recognition tasks

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan

Post Reply
TrackerUser99
User
Posts: 9
Joined: Fri Sep 21, 2012 12:42 pm

OCR Divide By Zero Exception

Post by TrackerUser99 » Sun Feb 24, 2013 5:50 pm

When I run the OcrDelphiExample sample project in Delphi 2007/Windows XP, I sometimes get an divide by zero exception raised for certain input PDF's. Other PDF input files OCR just fine. The Delphi EZeroDivide exception comes from ocrtool.dll when the OCR_MakeSearchable command is executed. Can you tell me why I sometimes get a divide by zero exception?

Thanks

Jerry Kashtan

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Re: OCR Divide By Zero Exception

Post by John - Tracker Supp » Sun Feb 24, 2013 6:06 pm

Very hard to say - can you supply an example PDF and advise if this always happens with this sample - please note all files must be zipped to be attached to a post.

thanks
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

TrackerUser99
User
Posts: 9
Joined: Fri Sep 21, 2012 12:42 pm

Re: OCR Divide By Zero Exception

Post by TrackerUser99 » Sun Feb 24, 2013 6:35 pm

Attached is a zip with three PDF files that cause the OcrDelphiExample application to fail by raising a Divide by Zero Error exception or an Invalid Floating Point Operation exception.

Thanks,

Jerry Kashtan

Files removed by system admin ......

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Re: OCR Divide By Zero Exception

Post by John - Tracker Supp » Sun Feb 24, 2013 6:49 pm

Thanks Jerry,

I will ask our OCR dev to investigate on Monday - thanks for your patience.

I have removed for the files from the forum for confidentiality
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Mon Feb 25, 2013 5:40 pm

Hi,

We are working on reproducing this to track down the source of the bug. I am not yet sure whether it is a problem with the core OCR library or the delphi wrapper portion, but will sort that out shortly.

Meanwhile, can you give a little more information please?

1. Do these documents always reproduce this behaviour, or is it sporadic?
2. What were the specific OCR settings you used? Language, DPI, auto-rotation (deskew), etc?
3. Can you provide the DLL version number (find ocrtools.dll in windows explorer, right click and select "Properties" and then the "Details" tab, and report the version information in "File Version". Should be in the format 1.0.x.x, for example 1.0.9.0 or 1.0.10.0).

Thanks!
-Walter

TrackerUser99
User
Posts: 9
Joined: Fri Sep 21, 2012 12:42 pm

Re: OCR Divide By Zero Exception

Post by TrackerUser99 » Mon Feb 25, 2013 6:26 pm

Hi Walter,

1. Do these documents always reproduce this behaviour, or is it sporadic?
[It is consistent in Delphi at runtime with the files I supplied.]

2. What were the specific OCR settings you used? Language, DPI, auto-rotation (deskew), etc?
[Language is English. I am using all the defaults in the Delphi example program. I did tweek the dpi and for a short
while it seemed to make a difference. When the dpi was higher 300 or more dpi, it sometimes worked without an exception being generated. Lower dpi's caused other PDF's to raise an exception.]


3. Can you provide the DLL version number (find ocrtools.dll in windows explorer, right click and select "Properties" and then the "Details" tab, and report the version information in "File Version". Should be in the format 1.0.x.x, for example 1.0.9.0 or 1.0.10.0).
[The dll version I have installed has the file version = 1.0.0010.0002 and is 7,482 KB in size. It was from a zipped distribution I got from Tracker back in September 2012.]

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Mon Feb 25, 2013 10:15 pm

I have been unable to reproduce this issue with C++ using the OCR library, so I have passed this on to our Delphi people and will have a response soon.

-Walter

TrackerUser99
User
Posts: 9
Joined: Fri Sep 21, 2012 12:42 pm

Re: OCR Divide By Zero Exception

Post by TrackerUser99 » Wed Mar 13, 2013 11:32 am

Hi Walter, any progress from your Delphi developer on resolving this issue? I need to get OCR working in my Delphi app so it can be released this month.

Thanks,

Jerry

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13559
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: OCR Divide By Zero Exception

Post by Tracker Supp-Stefan » Wed Mar 13, 2013 11:48 am

Hello Jerry,

I've passed the topic to Walter, and he should post back here a bit later today!

Cheers,
Stefan

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Wed Mar 13, 2013 5:30 pm

Do you have step by step instructions to reproduce this issue? Are you using your own code or testing with the example we provide?

Can you check your progress callback function, if applicable, to ensure you aren't inadvertently dividing by zero in there (e.g. by improperly setting the maximum-stage for a progress indicator or something)?

TrackerUser99
User
Posts: 9
Joined: Fri Sep 21, 2012 12:42 pm

Re: OCR Divide By Zero Exception

Post by TrackerUser99 » Wed Mar 13, 2013 5:42 pm

I commented out the SetCallback method and still get the divide by zero unhandled exception while in OCR_MakeSearchable. The option list that is passed into OCR_MakeSearchable is as follows:

lang=0
RegionMode=1
whitelist=''
blacklist=''
DataPath=<valid path to the PDF>
ImageFlags=1
raster_dpi=200
accMode=0

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Wed Mar 13, 2013 6:19 pm

Are you using your own code or testing with the example we provide?

TrackerUser99
User
Posts: 9
Joined: Fri Sep 21, 2012 12:42 pm

Re: OCR Divide By Zero Exception

Post by TrackerUser99 » Wed Mar 13, 2013 6:23 pm

I am using the Tracker Delphi OCR example code. No modifications other than I recently commented out the callback method.

Jerry

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Wed Mar 13, 2013 6:52 pm

Thanks. No luck in C++ (using the same DLL as provided with the delphi package) so we are actively trying to reproduce this with the help of the delphi guys, since it seems to be an issue with the example or wrapper.

-Walter

TrackerUser99
User
Posts: 9
Joined: Fri Sep 21, 2012 12:42 pm

Re: OCR Divide By Zero Exception

Post by TrackerUser99 » Wed Mar 13, 2013 6:56 pm

Refer to my earlier email where I provided a few PDF's that were causing the mischief.

Jerry

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Wed Mar 13, 2013 6:56 pm

TrackerUser99 wrote:Refer to my earlier email where I provided a few PDF's that were causing the mischief.

Jerry
Yup, that's what we are using. No luck reproducing it with the C++ code (using the same ocrtools DLL), so it seems to be some interoperability thing with delphi that we will have to sort out.

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Mon Mar 18, 2013 9:34 pm

I guess in the delphi example there is a place in the callback function where a divide by zero error can occur.

I was told that the fix is:

if frmMainOCR.FMaxLevel > 0 then
prc := dwLevel / frmMainOCR.FMaxLevel;

TrackerUser99
User
Posts: 9
Joined: Fri Sep 21, 2012 12:42 pm

Re: OCR Divide By Zero Exception

Post by TrackerUser99 » Tue Mar 19, 2013 12:18 pm

Hi Walter, I am not using the callback when processing but still get the divide by zero exception raised in the Delphi example code Tracker provided. This exception happens when opening many but not all PDF files in my set of test PDF's using the English language and dpi set to 300. It is a consistent error that prevents me from using this product. Can your Delphi developer send me a Delphi sample program that he/she feels works consistently with the PDF's I sent you? This is really important that I get a working OCR PDF app running by the end of this month.

Does Tracker have an updated OCR product at this time that I can download and test with?

Thanks,

Jerry

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Tue Mar 19, 2013 5:12 pm

Please email support@tracker-software.com, attn: walter, and I will provide you with a new build of the ocr DLLs.

As mentioned I was unable to reproduce the problem with the ocr libraries myself, so I suspect it is a delphi specific problem, and the guys who handle this are very busy preparing the release of our end user editor this week. However I have incorporated some fixes to return an error code on certain types of malformed input that could result in a /0 exception, and there are some other miscellaneous minor bug fixes in the core OCR code. Once you get the new build this may help identify the problem.

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Wed Mar 27, 2013 5:42 pm

We have uncovered the bug responsible for this exception and will update the distribution on our website. It was caused by an obscure case triggered by the input document "image0001.pdf".

I will also email you directly with the fixed build.

-Walter

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Wed Mar 27, 2013 7:55 pm

Just a quick update; the downloadable live OCR package is now updated with the fix.

Fixed DLL version numbers are:

1.0.12.x

We will update the trial version installer soon.

Walter-Tracker Supp
User
Posts: 383
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR Divide By Zero Exception

Post by Walter-Tracker Supp » Wed Apr 03, 2013 6:48 pm

I would like to update this post with report of a new fix which better resolves this problem.

A little background: in some algorithms, for example some of the fundamental OCR algorithms we use, it is preferable (for performance, and sometimes mathematical reasons) to ignore some floating point exceptions (e.g. divide by zero) when the "bad" results of these operations do not negatively impact the algorithm. Default behaviour in MSVC++ is to ignore these hardware exceptions thrown by the FPU, but Delphi applications do not suppress them.

The newest DLLs explicitly disable the relevant FP exceptions during algorithms for which throwing these exceptions is not desirable, and then sets the previous exception handling state after execution (so that exceptions in your own Delphi code will be handled as normal).

This change has been made in version 1.0.13.x of the ocrtools DLLs available on our website shortly (likely within an hour or so after this post). The live DLLs will be updated first, and demo versions in the demo installer will be updated as soon as our installer gurus can get this done.

We apologize to any users (Delphi users, in particular) who have been inconvenienced by this behaviour.

-Walter

Post Reply