r1me / TTesseractOCR4

Object Pascal binding for tesseract-ocr - an optical character recognition engine
MIT License
145 stars 46 forks source link

Can't run example #1

Closed DmLam closed 7 years ago

DmLam commented 7 years ago

I try to run delphi_console_simple example and get AV in TTesseractOCR4.Initialize on the TessBaseAPIInit2 call.

lstmrecognizer->DeSerialize(&fp):Error:Assert failed:in file C:\Users\rime.cppan\storage\src\38\cb\0305\ccmain\tessedit.cpp, line 193 Exception EAccessViolation in module pvt.cppan.demo.google.tesseract.libtesseract-master.dll at 000839A9. Access violation at address 583439A9 in module 'pvt.cppan.demo.google.tesseract.libtesseract-master.dll'. Read of address 00000000.

I use Tokyo 10.2.1, tesseract binaries is downloaded from r1me.pl, eng.traineddata is in tessdata folder

r1me commented 7 years ago

It looks like Tesseract internally fails to load trained data. Please make sure that you are using latest LSTM model (https://github.com/tesseract-ocr/tessdata/blob/master/eng.traineddata) and the file is not corrupted. If it doesn't help try changing Tesseract initialization line to this:

uses
  System.SysUtils,
  tesseractocr in '..\..\tesseractocr.pas';

(...)

    if Tesseract.Initialize(ExtractFilePath(ParamStr(0)) + 'tessdata\', 'eng') then

or

    if Tesseract.Initialize(ExtractFilePath(ParamStr(0)) + 'tessdata\', 'eng', oemTesseractOnly) then
DmLam commented 7 years ago

Yes, the problem was in corrupted eng.traineddata. Redownloaded it and now everything works fine. Thank you!