1 /////////////////////////////////////////////////////////////////////// 2 // File: tessdll.h 3 // Description: Windows dll interface for Tesseract. 4 // Author: Glen Wernersbach 5 // Created: Tue May 15 10:30:01 PDT 2007 6 // 7 // (C) Copyright 2007, Jetsoftdev. 8 // Licensed under the Apache License, Version 2.0 (the "License"); 9 // you may not use this file except in compliance with the License. 10 // You may obtain a copy of the License at 11 // http://www.apache.org/licenses/LICENSE-2.0 12 // Unless required by applicable law or agreed to in writing, software 13 // distributed under the License is distributed on an "AS IS" BASIS, 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 // See the License for the specific language governing permissions and 16 // limitations under the License. 17 // 18 /////////////////////////////////////////////////////////////////////// 19 20 21 #ifndef __cplusplus 22 typedef BOOL bool; 23 #endif /* __cplusplus */ 24 25 #include "ocrclass.h" 26 27 28 #ifdef __cplusplus 29 30 #include "baseapi.h" 31 32 33 //This is an exposed C++ 34 class TESSDLL_API TessDllAPI : public tesseract::TessBaseAPI 35 { 36 public: 37 //lang is the code of the language for which the data will be loaded. 38 //(Codes follow ISO 639-3.) If it is NULL, english (eng) will be loaded. 39 TessDllAPI(const char* lang = NULL) ; 40 ~TessDllAPI (); 41 42 //xsize should be the width of line in bytes times 8 43 //ysize is the height 44 //pass through a buffer of bytes for a 1 bit per pixel bitmap 45 //BeginPage assumes the first memory address is the bottom of the image 46 //BeginPageUpright assumes the first memory address is the top of the image 47 int BeginPage(uinT32 xsize,uinT32 ysize,unsigned char *buf); 48 int BeginPageUpright(uinT32 xsize,uinT32 ysize,unsigned char *buf); 49 50 // This could probably be combined with about in a one function bpp=1 51 int BeginPage(uinT32 xsize,uinT32 ysize,unsigned char *buf,uinT8 bpp); 52 int BeginPageUpright(uinT32 xsize,uinT32 ysize,unsigned char *buf, uinT8 bpp); 53 void EndPage(); 54 55 //This allows you to extract one word or section from the bitmap or 56 //the whole page 57 //To extract the whole page just enter zeros for left, right, top, bottom 58 //Note: getting one word at time is not yet optimized for speed. 59 //limit of 32000 character can be returned 60 //see ocrclass.h for a decription of the ETEXT_DESC file 61 ETEXT_DESC *Recognize_a_Block(uinT32 left,uinT32 right, 62 uinT32 top,uinT32 bottom); 63 ETEXT_DESC *Recognize_all_Words(void); 64 65 private: 66 int ProcessPagePass1(); 67 68 unsigned char *membuf; 69 }; 70 71 #endif 72 73 #ifdef __cplusplus 74 extern "C" 75 { 76 #endif 77 78 #ifndef TESSDLL_API 79 #ifdef TESSDLL_EXPORTS 80 #define TESSDLL_API __declspec(dllexport) 81 #elif defined(TESSDLL_IMPORTS) 82 #define TESSDLL_API __declspec(dllimport) 83 #else 84 #define TESSDLL_API 85 #endif 86 #endif 87 88 89 //The functions below provide a c wrapper to a global recognize class object 90 91 //xsize should be the width of line in bytes times 8 92 //ysize is the height 93 //pass through a buffer of bytes for a 1 bit per pixel bitmap 94 //BeginPage assumes the first memory address is the bottom of the image (MS DIB format) 95 //BeginPageUpright assumes the first memory address is the top of the image (TIFF format) 96 //lang is the code of the language for which the data will be loaded. 97 //(Codes follow ISO 639-3.) If it is NULL, english (eng) will be loaded. 98 TESSDLL_API int __cdecl TessDllBeginPage(uinT32 xsize,uinT32 ysize, 99 unsigned char *buf); 100 101 TESSDLL_API int __cdecl TessDllBeginPageLang(uinT32 xsize,uinT32 ysize, 102 unsigned char *buf, 103 const char* lang); 104 TESSDLL_API int __cdecl TessDllBeginPageUpright(uinT32 xsize,uinT32 ysize, 105 unsigned char *buf, 106 const char* lang); 107 //Added in version 2.0 to allow users to specify bytes per pixel to do 108 //1 for binary biptmap 109 //8 for gray 110 //24 bit for color RGB 111 TESSDLL_API int __cdecl TessDllBeginPageBPP(uinT32 xsize,uinT32 ysize, 112 unsigned char *buf,uinT8 bpp); 113 114 TESSDLL_API int __cdecl TessDllBeginPageLangBPP(uinT32 xsize,uinT32 ysize, 115 unsigned char *buf, 116 const char* lang,uinT8 bpp); 117 TESSDLL_API int __cdecl TessDllBeginPageUprightBPP(uinT32 xsize,uinT32 ysize, 118 unsigned char *buf, 119 const char* lang,uinT8 bpp); 120 121 TESSDLL_API void __cdecl TessDllEndPage(void); 122 123 //This allows you to extract one word or section from the bitmap or 124 //the whole page 125 //To extract the whole page just enter zeros for left, right, top, bottom 126 //Note: getting one word at time is not yet optimized for speed. 127 //limit of 32000 character can be returned 128 //see ocrclass.h for a decription of the ETEXT_DESC file 129 TESSDLL_API ETEXT_DESC * __cdecl TessDllRecognize_a_Block(uinT32 left, 130 uinT32 right, 131 uinT32 top, 132 uinT32 bottom); 133 TESSDLL_API ETEXT_DESC * __cdecl TessDllRecognize_all_Words(); 134 135 //This will release any memory associated with the recognize class object 136 TESSDLL_API void __cdecl TessDllRelease(); 137 138 #ifdef __cplusplus 139 } 140 #endif 141