[code]
module tessdll;
import
tango.stdc.time,
tango.sys.Sharedlib,
tango.stdc.stringz;
alias ubyte uinT8;
alias byte inT8;
alias ushort uinT16;
alias short inT16;
alias uint uinT32;
alias int inT32;
alias ubyte unsigned_char;
alias short c_int;
//bool (*CANCEL_FUNC)(void* cancel_this, int words);
alias bool function(void*,c_int) CANCEL_FUNC;
struct EANYCODE_CHAR { /*single character */
// It should be noted that the format for char_code for version 2.0
and beyond is UTF8
// which means that ASCII characters will come out as one structure
but other characters
// will be returned in two or more instances of this structure with a
single byte of the
// UTF8 code in each, but each will have the same bounding box.
// Programs which want to handle languagues with different characters
sets will need to
// handle extended characters appropriately, but *all* code needs to
be prepared to
// receive UTF8 coded characters for characters such as bullet and
fancy quotes.
uinT16 char_code; /*character itself */
inT16 left; /*of char (-1) */
inT16 right; /*of char (-1) */
inT16 top; /*of char (-1) */
inT16 bottom; /*of char (-1) */
inT16 font_index; /*what font (0) */
uinT8 confidence; /*0=perfect, 100=reject (0/100) */
uinT8 point_size; /*of char, 72=i inch, (10) */
inT8 blanks; /*no of spaces before this char (1) */
}
struct ETEXT_DESC{ //ETEXT_STRUCT output header
inT16 count; /*chars in this buffer(0) */
inT16 progress; /*percent complete increasing (0-100)
*/
inT8 more_to_come; /*true if not last */
inT8 ocr_alive; /*ocr sets to 1, HP 0 */
inT8 err_code; /*for errcode use */
CANCEL_FUNC cancel; /*returns true to cancel */
void* cancel_this; /*this or other data for cancel*/
clock_t end_time; /*time to stop if not 0*/
EANYCODE_CHAR text[1]; /*character data */
}
extern(C){
//TESSDLL_API int __cdecl TessDllBeginPage(uinT32 xsize,uinT32
ysize, unsigned char *buf);
c_int function(uinT32, uinT32, ubyte*) TessDllBeginPage;
//TESSDLL_API int __cdecl TessDllBeginPageLang(uinT32 xsize,uinT32
ysize, unsigned char *buf, const char* lang);
c_int function(uinT32, uinT32, ubyte*, char*) TessDllBeginPageLang;
//TESSDLL_API int __cdecl TessDllBeginPageUpright(uinT32 xsize,uinT32
ysize, unsigned char *buf, const char* lang);
c_int function(uinT32, uinT32, ubyte*, char*)
TessDllBeginPageUpright;
//Added in version 2.0 to allow users to specify bytes per pixel to
do
//1 for binary biptmap
//8 for gray
//24 bit for color RGB
//TESSDLL_API int __cdecl TessDllBeginPageBPP(uinT32 xsize, uinT32
ysize, unsigned char *buf, uinT8 bpp);
c_int function(uinT32, uinT32, ubyte*, uinT8) TessDllBeginPageBPP;
//TESSDLL_API int __cdecl TessDllBeginPageLangBPP(uinT32 xsize,uinT32
ysize, unsigned char *buf, const char* lang,uinT8 bpp);
c_int function(uinT32, uinT32, ubyte*, char*, uinT8)
TessDllBeginPageLangBPP;
//TESSDLL_API int __cdecl TessDllBeginPageUprightBPP(uinT32
xsize,uinT32 ysize, unsigned char *buf, const char* lang,uinT8 bpp);
c_int function(uinT32, uinT32, ubyte*, char*, uinT8)
TessDllBeginPageUprightBPP;
// TESSDLL_API void __cdecl TessDllEndPage(void);
void function(ubyte) TessDllEndPage;
//This allows you to extract one word or section from the bitmap or
//the whole page
//To extract the whole page just enter zeros for left, right, top,
bottom
//Note: getting one word at time is not yet optimized for speed.
//limit of 32000 character can be returned
//see ocrclass.h for a decription of the ETEXT_DESC file
//TESSDLL_API ETEXT_DESC * __cdecl TessDllRecognize_a_Block(uinT32
left, uinT32 right, uinT32 top, uinT32 bottom);
ETEXT_DESC* function(uinT32, uinT32, uinT32, uinT32)
TessDllRecognize_a_Block;
//TESSDLL_API ETEXT_DESC * __cdecl TessDllRecognize_all_Words();
ETEXT_DESC* function() TessDllRecognize_all_Words;
//This will release any memory associated with the recognize class
object
//TESSDLL_API void __cdecl TessDllRelease();
void function() TessDllRelease;
}
void bind(alias T)(SharedLib lib){
//pragma(msg, T.stringof);
T = cast( typeof(T) ) lib.getSymbol(toStringz(T.stringof));
assert(T !is null);
}
static this(){
auto lib = SharedLib.load(`tessdll.dll`);
if( lib is null){
throw new Exception(`load tessdll.dll error`);
}else{
bind!(TessDllBeginPage)(lib);
bind!(TessDllBeginPageLang)(lib);
bind!(TessDllBeginPageBPP)(lib);
bind!(TessDllBeginPageBPP)(lib);
bind!(TessDllBeginPageLangBPP)(lib);
bind!(TessDllBeginPageUprightBPP)(lib);
bind!(TessDllEndPage)(lib);
bind!(TessDllRecognize_a_Block)(lib);
bind!(TessDllRecognize_all_Words)(lib);
bind!(TessDllRelease)(lib);
}
}
[/code]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tesseract-ocr" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tesseract-ocr?hl=en
-~----------~----~----~----~------~----~------~--~---