Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi / Tesseract OCR: Can somebody help me get this new DLL working in Delphi? [closed]

There is this great open-source OCR component that Google has been developing: http://code.google.com/p/tesseract-ocr/

They have a new version out (version 3) at the beginning of October 2010.

But this new version no longer has a working C wrapper, and it's up to somebody in the Delphi community to get it to work from inside Delphi -- I'm trying to do it because I badly need it and nobody else is in a hurry to do it but I have no idea what I'm doing when it comes to DLLs and converting C to Delphi. That's where I could use your help.

The clues I have picked up are that I need Dependency Walker to somehow prevent 'name-mangling' (no idea what that means). The actual DLL API methods are in the C files - and presumably the DLL function-names you see in Dependency-Walker will match the functions in the API file.

Here's everything you'll need to help: You will need a folder with the tessdll.dll in it and also leptonlib.dll just needs to be there. You'll need a subfolder called 'tessdata', and inside the folder will be your 'language data files' - [check the downloads page on the site]

Here's the Windows installer just so you can see the DLL in action: [check the downloads page on the site]

To get this working for Delphi, you'll have your executable in the same folder as the DLL. You'll then need to know what to call in the DLL, and for that you can look in the C Source files: [check the source files on the downloads page on the site]

Thanks for any assistance.

like image 482
Richard Woolf Avatar asked Oct 19 '25 09:10

Richard Woolf


1 Answers

Actually after taking a closer look at the documentation there might be a subset of function that are still C API and thus accessible directly from Delphi:

BOOL APIENTRY  DllMain (HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) 
TESSDLL_API void __cdecl  TessDllRelease () 
TESSDLL_API void *__cdecl  TessDllInit (const char *lang) 
TESSDLL_API int __cdecl  TessDllBeginPageBPP (uinT32 xsize, uinT32 ysize, unsigned char *buf, uinT8 bpp) 
TESSDLL_API int __cdecl  TessDllBeginPageLangBPP (uinT32 xsize, uinT32 ysize, unsigned char *buf, const char *lang, uinT8 bpp) 
TESSDLL_API int __cdecl  TessDllBeginPageUprightBPP (uinT32 xsize, uinT32 ysize, unsigned char *buf, const char *lang, uinT8 bpp) 
TESSDLL_API int __cdecl  TessDllBeginPage (uinT32 xsize, uinT32 ysize, unsigned char *buf) 
TESSDLL_API int __cdecl  TessDllBeginPageLang (uinT32 xsize, uinT32 ysize, unsigned char *buf, const char *lang) 
TESSDLL_API int __cdecl  TessDllBeginPageUpright (uinT32 xsize, uinT32 ysize, unsigned char *buf, const char *lang) 
TESSDLL_API void __cdecl  TessDllEndPage (void) 
TESSDLL_API ETEXT_DESC *__cdecl  TessDllRecognize_a_Block (uinT32 left, uinT32 right, uinT32 top, uinT32 bottom) 
TESSDLL_API ETEXT_DESC *__cdecl  TessDllRecognize_all_Words (void) 
TESSDLL_API void __cdecl  ReleaseRecognize () 
TESSDLL_API void *__cdecl  InitRecognize () 
TESSDLL_API int __cdecl  CreateRecognize (uinT32 xsize, uinT32 ysize, unsigned char *buf) 
TESSDLL_API ETEXT_DESC *__cdecl  reconize_a_word (uinT32 left, uinT32 right, uinT32 top, uinT32 bottom) 

I don't know if these functions are enough, but they are directly accessible.

like image 57
Jens Mühlenhoff Avatar answered Oct 22 '25 00:10

Jens Mühlenhoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!