1 #ifndef ASPRISE_OCR_API_H
2 #define ASPRISE_OCR_API_H
19 #define EXPORT_API __declspec(dllexport)
20 #define CALL_CONVENTION __stdcall
24 #define CALL_CONVENTION
34 #define OCR_SPEED_FASTEST "fastest"
35 #define OCR_SPEED_FAST "fast"
36 #define OCR_SPEED_SLOW "slow"
38 #define OCR_RECOGNIZE_TYPE_TEXT "text"
39 #define OCR_RECOGNIZE_TYPE_BARCODE "barcode"
40 #define OCR_RECOGNIZE_TYPE_ALL "all"
42 #define OCR_OUTPUT_FORMAT_PLAINTEXT "text"
43 #define OCR_OUTPUT_FORMAT_XML "xml"
44 #define OCR_OUTPUT_FORMAT_PDF "pdf"
45 #define OCR_OUTPUT_FORMAT_RTF "rtf"
49 #define OCR_PROP_LIMIT_TO_CHARSET "PROP_LIMIT_TO_CHARSET"
51 #define OCR_PROP_PAGE_TYPE "PROP_PAGE_TYPE"
52 #define OCR_PROP_PAGE_TYPE_AUTO_DETECT "auto"
53 #define OCR_PROP_PAGE_TYPE_SINGLE_BLOCK "single_block"
54 #define OCR_PROP_PAGE_TYPE_SINGLE_COLUMN "single_column"
55 #define OCR_PROP_PAGE_TYPE_SINGLE_LINE "single_line"
56 #define OCR_PROP_PAGE_TYPE_SINGLE_WORD "single_word"
57 #define OCR_PROP_PAGE_TYPE_SINGLE_CHARACTOR "single_char"
58 #define OCR_PROP_PAGE_TYPE_SCATTERED "scattered"
60 #define OCR_PROP_OUTPUT_SEPARATE_WORDS "PROP_OUTPUT_SEPARATE_WORDS"
63 #define OCR_PROP_INPUT_PDF_DPI "PROP_INPUT_PDF_DPI"
67 #define OCR_START_PROP_DICT_SKIP_BUILT_IN_DEFAULT "START_PROP_DICT_SKIP_BUILT_IN_DEFAULT"
69 #define OCR_START_PROP_DICT_SKIP_BUILT_IN_ALL "START_PROP_DICT_SKIP_BUILT_IN_ALL"
71 #define OCR_START_PROP_DICT_CUSTOM_DICT_FILE "START_PROP_DICT_CUSTOM_DICT_FILE"
73 #define OCR_START_PROP_DICT_CUSTOM_TEMPLATES_FILE "START_PROP_DICT_CUSTOM_TEMPLATES_FILE"
76 #define OCR_PROP_DICT_DICT_IMPORTANCE "PROP_DICT_DICT_IMPORTANCE"
80 #define OCR_PROP_PDF_OUTPUT_FILE "PROP_PDF_OUTPUT_FILE"
81 #define OCR_PROP_PDF_OUTPUT_IMAGE_DPI "PROP_PDF_OUTPUT_IMAGE_DPI"
82 #define OCR_PROP_PDF_OUTPUT_FONT "PROP_PDF_OUTPUT_FONT"
83 #define OCR_PROP_PDF_OUTPUT_TEXT_VISIBLE "PROP_PDF_OUTPUT_TEXT_VISIBLE"
84 #define OCR_PROP_PDF_OUTPUT_IMAGE_FORCE_BW "PROP_PDF_OUTPUT_IMAGE_FORCE_BW"
86 #define OCR_PROP_PDF_OUTPUT_PDFA "PROP_PDF_OUTPUT_PDFA"
87 #define OCR_PROP_PDF_OUTPUT_PDFA_FONT_FILE "PROP_PDF_OUTPUT_PDFA_FONT_FILE"
90 #define OCR_PROP_PDF_OUTPUT_CONF_THRESHOLD "PROP_PDF_OUTPUT_CONF_THRESHOLD"
93 #define OCR_PROP_PDF_OUTPUT_RETURN_TEXT "PROP_PDF_OUTPUT_RETURN_TEXT"
97 #define OCR_PROP_RTF_OUTPUT_FILE "PROP_RTF_OUTPUT_FILE"
100 #define OCR_PROP_RTF_OUTPUT_RETURN_TEXT "PROP_RTF_OUTPUT_RETURN_TEXT"
103 #define OCR_PROP_RTF_PAPER_SIZE "PROP_RTF_PAPER_SIZE"
106 #define OCR_PROP_RTF_SHOW_TABLE_CELL_BORDER "PROP_RTF_SHOW_TABLE_CELL_BORDER"
111 #define OCR_PROP_IMG_PREPROCESS_TYPE "PROP_IMG_PREPROCESS_TYPE"
112 #define OCR_PROP_IMG_PREPROCESS_TYPE_DEFAULT "default"
113 #define OCR_PROP_IMG_PREPROCESS_TYPE_DEFAULT_WITH_ORIENTATION_DETECTION "default_with_orientation_detection"
114 #define OCR_PROP_IMG_PREPROCESS_TYPE_CUSTOM "custom"
117 #define OCR_PROP_IMG_PREPROCESS_CUSTOM_CMDS "PROP_IMG_PREPROCESS_CUSTOM_CMDS"
121 #define OCR_PROP_TABLE_SKIP_DETECTION "PROP_TABLE_SKIP_DETECTION"
124 #define OCR_PROP_TABLE_MIN_SIDE_LENGTH "PROP_TABLE_MIN_SIDE_LENGTH"
127 #define OCR_PROP_SAVE_INTERMEDIATE_IMAGES_TO_DIR "PROP_SAVE_INTERMEDIATE_IMAGES_TO_DIR"
130 #define OCR_PROP_INPUT_PDF_SINGLE_IMG_PER_PAGE "PROP_INPUT_PDF_SINGLE_IMG_PER_PAGE"
147 (
long long handle,
const char * imgFiles,
int pageIndex,
int startX,
int startY,
int width,
int height,
const char * recognizeType,
const char * outputFormat,
const char * propSpec,
const char * propSeparator,
const char * propKeyValueSpeparator);
168 #ifndef SKIP_AOCR_DYNAMIC
172 #define snprintf _snprintf
177 #if defined(_WIN32) && !defined(_WIN64)
178 #define FUNC_NAME_com_asprise_ocr_version "_com_asprise_ocr_version@0"
179 #define FUNC_NAME_com_asprise_ocr_setup "_com_asprise_ocr_setup@4"
180 #define FUNC_NAME_com_asprise_ocr_list_supported_langs "_com_asprise_ocr_list_supported_langs@0"
181 #define FUNC_NAME_com_asprise_ocr_start "_com_asprise_ocr_start@20"
182 #define FUNC_NAME_com_asprise_ocr_stop "_com_asprise_ocr_stop@8"
183 #define FUNC_NAME_com_asprise_ocr_recognize "_com_asprise_ocr_recognize@52"
184 #define FUNC_NAME_com_asprise_ocr_util_delete "_com_asprise_ocr_util_delete@12"
185 #define FUNC_NAME_com_asprise_ocr_input_license "_com_asprise_ocr_input_license@8"
187 #define FUNC_NAME_com_asprise_ocr_version "com_asprise_ocr_version"
188 #define FUNC_NAME_com_asprise_ocr_setup "com_asprise_ocr_setup"
189 #define FUNC_NAME_com_asprise_ocr_list_supported_langs "com_asprise_ocr_list_supported_langs"
190 #define FUNC_NAME_com_asprise_ocr_start "com_asprise_ocr_start"
191 #define FUNC_NAME_com_asprise_ocr_stop "com_asprise_ocr_stop"
192 #define FUNC_NAME_com_asprise_ocr_recognize "com_asprise_ocr_recognize"
193 #define FUNC_NAME_com_asprise_ocr_util_delete "com_asprise_ocr_util_delete"
194 #define FUNC_NAME_com_asprise_ocr_input_license "com_asprise_ocr_input_license"
200 typedef long long(
CALL_CONVENTION * func_type_com_asprise_ocr_start) (
const char *,
const char *,
const char *,
const char *,
const char *);
202 typedef char * (
CALL_CONVENTION *
func_type_com_asprise_ocr_recognize) (
long long,
const char *,
int,
int,
int,
int,
int,
const char *,
const char *,
const char *,
const char *,
const char *);
204 typedef void(
CALL_CONVENTION * func_type_com_asprise_ocr_input_license) (
const char *,
const char *);
219 printf(
"ERROR: Failed to look up function in the library: %s\n", funcName);
227 char libFilePath[256];
228 bool isWindows =
false;
231 const char * libName =
"aocr_x64.dll";
233 const char * libName =
"aocr.dll";
238 const char * libName =
"libaocr_x64.dylib";
240 #if defined(__LP64__) || defined(_LP64)
241 const char * libName =
"libaocr_x64.so";
243 const char * libName =
"libaocr.so";
249 const char * separator = strlen(pathToFolderContainingAocrLibrary) > 0 && (pathToFolderContainingAocrLibrary[strlen(pathToFolderContainingAocrLibrary) - 1] ==
'/' || pathToFolderContainingAocrLibrary[strlen(pathToFolderContainingAocrLibrary) - 1] ==
'\\')
251 snprintf(libFilePath, 256,
"%s%s%s", pathToFolderContainingAocrLibrary, separator, libName);
252 for (
size_t i = 0; i < strlen(libFilePath); i++) {
253 if (libFilePath[i] ==
'/' || libFilePath[i] ==
'\\') {
254 libFilePath[i] = isWindows ?
'\\' :
'/';
259 handle = LoadLibraryA(libFilePath);
261 printf(
"ERROR: GetLastError() returns: %lu\n", GetLastError());
273 handle = dlopen(libFilePath, RTLD_LAZY);
274 if (handle == NULL) {
275 printf(
"ERROR: dlerror(): %s\n", dlerror());
287 if (handle == NULL) {
288 printf(
"ERROR: failed to dynamically load the library: %s\nMake sure it exists. Contact support@asprise.com if you need any assistance.\n", libFilePath);
302 printf(
"ERROR: at lease one function is not found in the library.\n");
312 if (handle == NULL) {
316 return FreeLibrary(handle) != 0;
318 errorCode = dlclose(handle);
320 printf(
"dlclose() returns error code: %d\n", errorCode);
322 return errorCode == 0;
330 printf(
"Function is NULL. Please call dynamic_load_aocr_library first.\n");
360 long long c_com_asprise_ocr_start(
const char * lang,
const char * speed,
const char * propSpec,
const char * propSeparator,
const char * propKeyValueSpeparator) {
369 (
long long handle,
const char * imgFiles,
int pageIndex,
int startX,
int startY,
int width,
int height,
const char * recognizeType,
const char * outputFormat,
const char * propSpec,
const char * propSeparator,
const char * propKeyValueSpeparator) {
373 return func_com_asprise_ocr_recognize(handle, imgFiles, pageIndex, startX, startY, width, height, recognizeType, outputFormat, propSpec, propSeparator, propKeyValueSpeparator);
458 #endif // #ifndef SKIP_AOCR_DYNAMIC
460 #endif // ASPRISE_OCR_API_H
int CALL_CONVENTION c_com_asprise_ocr_setup(bool queryOnly)
Definition: asprise_ocr_api.h:344
void c_com_asprise_ocr_input_license(const char *licenseeName, const char *licenseCode)
Definition: asprise_ocr_api.h:385
EXPORT_API void CALL_CONVENTION com_asprise_ocr_util_delete(long long handle, bool isArray)
EXPORT_API int CALL_CONVENTION com_asprise_ocr_setup(bool queryOnly)
func_type_com_asprise_ocr_util_delete func_com_asprise_ocr_util_delete
Definition: asprise_ocr_api.h:212
EXPORT_API long long CALL_CONVENTION com_asprise_ocr_start(const char *lang, const char *speed, const char *propSpec, const char *propSeparator, const char *propKeyValueSpeparator)
#define FUNC_NAME_com_asprise_ocr_setup
Definition: asprise_ocr_api.h:188
func_type_com_asprise_ocr_start func_com_asprise_ocr_start
Definition: asprise_ocr_api.h:210
#define FUNC_NAME_com_asprise_ocr_start
Definition: asprise_ocr_api.h:190
func_type_com_asprise_ocr_stop func_com_asprise_ocr_stop
Definition: asprise_ocr_api.h:211
typedef int(CALL_CONVENTION *func_type_com_asprise_ocr_setup)(bool)
EXPORT_API char *CALL_CONVENTION com_asprise_ocr_list_supported_langs()
#define FUNC_NAME_com_asprise_ocr_util_delete
Definition: asprise_ocr_api.h:193
const char *func_type_com_asprise_ocr_input_license func_com_asprise_ocr_input_license
Definition: asprise_ocr_api.h:206
EXPORT_API char *CALL_CONVENTION com_asprise_ocr_recognize(long long handle, const char *imgFiles, int pageIndex, int startX, int startY, int width, int height, const char *recognizeType, const char *outputFormat, const char *propSpec, const char *propSeparator, const char *propKeyValueSpeparator)
long const char const char const char const char *typedef void(CALL_CONVENTION *func_type_com_asprise_ocr_stop)(long long)
Definition: asprise_ocr_api.h:201
func_type_com_asprise_ocr_version func_com_asprise_ocr_version
Definition: asprise_ocr_api.h:213
#define FUNC_NAME_com_asprise_ocr_version
Definition: asprise_ocr_api.h:187
void c_com_asprise_ocr_util_delete(long long handle, bool isArray)
Definition: asprise_ocr_api.h:393
#define FUNC_NAME_com_asprise_ocr_input_license
Definition: asprise_ocr_api.h:194
char *CALL_CONVENTION * func_type_com_asprise_ocr_list_supported_langs()
Definition: asprise_ocr_api.h:199
EXPORT_API void CALL_CONVENTION initaocr_x64(void)
EXPORT_API const char *CALL_CONVENTION com_asprise_ocr_version()
char *CALL_CONVENTION * func_type_com_asprise_ocr_recognize(long long, const char *, int, int, int, int, int, const char *, const char *, const char *, const char *, const char *)
Definition: asprise_ocr_api.h:202
EXPORT_API void CALL_CONVENTION com_asprise_ocr_stop(long long handle)
#define CALL_CONVENTION
Definition: asprise_ocr_api.h:24
char * c_com_asprise_ocr_list_supported_langs()
Definition: asprise_ocr_api.h:352
#define EXPORT_API
Definition: asprise_ocr_api.h:23
#define FUNC_NAME_com_asprise_ocr_list_supported_langs
Definition: asprise_ocr_api.h:189
void c_com_asprise_ocr_stop(long long handle)
Definition: asprise_ocr_api.h:377
const char *CALL_CONVENTION * func_type_com_asprise_ocr_version()
Definition: asprise_ocr_api.h:197
typedef bool
Definition: asprise_ocr_api.h:203
char * c_com_asprise_ocr_recognize(long long handle, const char *imgFiles, int pageIndex, int startX, int startY, int width, int height, const char *recognizeType, const char *outputFormat, const char *propSpec, const char *propSeparator, const char *propKeyValueSpeparator)
Definition: asprise_ocr_api.h:369
EXPORT_API void CALL_CONVENTION com_asprise_ocr_input_license(const char *licenseeName, const char *licenseCode)
func_type_com_asprise_ocr_setup func_com_asprise_ocr_setup
Definition: asprise_ocr_api.h:209
EXPORT_API void CALL_CONVENTION initaocr(void)
bool assertFuncExists(bool exists)
Definition: asprise_ocr_api.h:326
void * LIBRARY_HANDLE
Definition: asprise_ocr_api.h:174
const char * c_com_asprise_ocr_version()
Definition: asprise_ocr_api.h:336
void(* FUNC_TYPE)(void *)
Definition: asprise_ocr_api.h:169
bool dynamic_unload_aocr_library(LIBRARY_HANDLE handle)
Definition: asprise_ocr_api.h:310
func_type_com_asprise_ocr_recognize func_com_asprise_ocr_recognize
Definition: asprise_ocr_api.h:208
#define FUNC_NAME_com_asprise_ocr_stop
Definition: asprise_ocr_api.h:191
bool checkIfFuncFound(bool funcFound, const char *funcName)
Definition: asprise_ocr_api.h:215
LIBRARY_HANDLE dynamic_load_aocr_library(const char *pathToFolderContainingAocrLibrary)
Definition: asprise_ocr_api.h:225
long long(CALL_CONVENTION *func_type_com_asprise_ocr_start)(const char *
Definition: asprise_ocr_api.h:200
#define FUNC_NAME_com_asprise_ocr_recognize
Definition: asprise_ocr_api.h:192
long long c_com_asprise_ocr_start(const char *lang, const char *speed, const char *propSpec, const char *propSeparator, const char *propKeyValueSpeparator)
Definition: asprise_ocr_api.h:360
func_type_com_asprise_ocr_list_supported_langs func_com_asprise_ocr_list_supported_langs
Definition: asprise_ocr_api.h:207