GlobeEngine
asprise_ocr_api.h File Reference
#include <stdio.h>
#include <string.h>
#include <dlfcn.h>

Go to the source code of this file.

Macros

#define EXPORT_API
 
#define CALL_CONVENTION
 
#define OCR_SPEED_FASTEST   "fastest"
 
#define OCR_SPEED_FAST   "fast"
 
#define OCR_SPEED_SLOW   "slow"
 
#define OCR_RECOGNIZE_TYPE_TEXT   "text"
 
#define OCR_RECOGNIZE_TYPE_BARCODE   "barcode"
 
#define OCR_RECOGNIZE_TYPE_ALL   "all"
 
#define OCR_OUTPUT_FORMAT_PLAINTEXT   "text"
 
#define OCR_OUTPUT_FORMAT_XML   "xml"
 
#define OCR_OUTPUT_FORMAT_PDF   "pdf"
 
#define OCR_OUTPUT_FORMAT_RTF   "rtf"
 
#define OCR_PROP_LIMIT_TO_CHARSET   "PROP_LIMIT_TO_CHARSET"
 
#define OCR_PROP_PAGE_TYPE   "PROP_PAGE_TYPE"
 
#define OCR_PROP_PAGE_TYPE_AUTO_DETECT   "auto"
 
#define OCR_PROP_PAGE_TYPE_SINGLE_BLOCK   "single_block"
 
#define OCR_PROP_PAGE_TYPE_SINGLE_COLUMN   "single_column"
 
#define OCR_PROP_PAGE_TYPE_SINGLE_LINE   "single_line"
 
#define OCR_PROP_PAGE_TYPE_SINGLE_WORD   "single_word"
 
#define OCR_PROP_PAGE_TYPE_SINGLE_CHARACTOR   "single_char"
 
#define OCR_PROP_PAGE_TYPE_SCATTERED   "scattered"
 
#define OCR_PROP_OUTPUT_SEPARATE_WORDS   "PROP_OUTPUT_SEPARATE_WORDS"
 
#define OCR_PROP_INPUT_PDF_DPI   "PROP_INPUT_PDF_DPI"
 
#define OCR_START_PROP_DICT_SKIP_BUILT_IN_DEFAULT   "START_PROP_DICT_SKIP_BUILT_IN_DEFAULT"
 
#define OCR_START_PROP_DICT_SKIP_BUILT_IN_ALL   "START_PROP_DICT_SKIP_BUILT_IN_ALL"
 
#define OCR_START_PROP_DICT_CUSTOM_DICT_FILE   "START_PROP_DICT_CUSTOM_DICT_FILE"
 
#define OCR_START_PROP_DICT_CUSTOM_TEMPLATES_FILE   "START_PROP_DICT_CUSTOM_TEMPLATES_FILE"
 
#define OCR_PROP_DICT_DICT_IMPORTANCE   "PROP_DICT_DICT_IMPORTANCE"
 
#define OCR_PROP_PDF_OUTPUT_FILE   "PROP_PDF_OUTPUT_FILE"
 
#define OCR_PROP_PDF_OUTPUT_IMAGE_DPI   "PROP_PDF_OUTPUT_IMAGE_DPI"
 
#define OCR_PROP_PDF_OUTPUT_FONT   "PROP_PDF_OUTPUT_FONT"
 
#define OCR_PROP_PDF_OUTPUT_TEXT_VISIBLE   "PROP_PDF_OUTPUT_TEXT_VISIBLE"
 
#define OCR_PROP_PDF_OUTPUT_IMAGE_FORCE_BW   "PROP_PDF_OUTPUT_IMAGE_FORCE_BW"
 
#define OCR_PROP_PDF_OUTPUT_PDFA   "PROP_PDF_OUTPUT_PDFA"
 
#define OCR_PROP_PDF_OUTPUT_PDFA_FONT_FILE   "PROP_PDF_OUTPUT_PDFA_FONT_FILE"
 
#define OCR_PROP_PDF_OUTPUT_CONF_THRESHOLD   "PROP_PDF_OUTPUT_CONF_THRESHOLD"
 
#define OCR_PROP_PDF_OUTPUT_RETURN_TEXT   "PROP_PDF_OUTPUT_RETURN_TEXT"
 
#define OCR_PROP_RTF_OUTPUT_FILE   "PROP_RTF_OUTPUT_FILE"
 
#define OCR_PROP_RTF_OUTPUT_RETURN_TEXT   "PROP_RTF_OUTPUT_RETURN_TEXT"
 
#define OCR_PROP_RTF_PAPER_SIZE   "PROP_RTF_PAPER_SIZE"
 
#define OCR_PROP_RTF_SHOW_TABLE_CELL_BORDER   "PROP_RTF_SHOW_TABLE_CELL_BORDER"
 
#define OCR_PROP_IMG_PREPROCESS_TYPE   "PROP_IMG_PREPROCESS_TYPE"
 
#define OCR_PROP_IMG_PREPROCESS_TYPE_DEFAULT   "default"
 
#define OCR_PROP_IMG_PREPROCESS_TYPE_DEFAULT_WITH_ORIENTATION_DETECTION   "default_with_orientation_detection"
 
#define OCR_PROP_IMG_PREPROCESS_TYPE_CUSTOM   "custom"
 
#define OCR_PROP_IMG_PREPROCESS_CUSTOM_CMDS   "PROP_IMG_PREPROCESS_CUSTOM_CMDS"
 
#define OCR_PROP_TABLE_SKIP_DETECTION   "PROP_TABLE_SKIP_DETECTION"
 
#define OCR_PROP_TABLE_MIN_SIDE_LENGTH   "PROP_TABLE_MIN_SIDE_LENGTH"
 
#define OCR_PROP_SAVE_INTERMEDIATE_IMAGES_TO_DIR   "PROP_SAVE_INTERMEDIATE_IMAGES_TO_DIR"
 
#define OCR_PROP_INPUT_PDF_SINGLE_IMG_PER_PAGE   "PROP_INPUT_PDF_SINGLE_IMG_PER_PAGE"
 
#define FUNC_NAME_com_asprise_ocr_version   "com_asprise_ocr_version"
 
#define FUNC_NAME_com_asprise_ocr_setup   "com_asprise_ocr_setup"
 
#define FUNC_NAME_com_asprise_ocr_list_supported_langs   "com_asprise_ocr_list_supported_langs"
 
#define FUNC_NAME_com_asprise_ocr_start   "com_asprise_ocr_start"
 
#define FUNC_NAME_com_asprise_ocr_stop   "com_asprise_ocr_stop"
 
#define FUNC_NAME_com_asprise_ocr_recognize   "com_asprise_ocr_recognize"
 
#define FUNC_NAME_com_asprise_ocr_util_delete   "com_asprise_ocr_util_delete"
 
#define FUNC_NAME_com_asprise_ocr_input_license   "com_asprise_ocr_input_license"
 

Typedefs

typedef void(* FUNC_TYPE) (void *)
 
typedef voidLIBRARY_HANDLE
 
typedef const char *CALL_CONVENTIONfunc_type_com_asprise_ocr_version()
 
typedef char *CALL_CONVENTIONfunc_type_com_asprise_ocr_list_supported_langs()
 
typedef long long(CALL_CONVENTION *func_type_com_asprise_ocr_start) (const char *
 
typedef long const char const char const char const char *typedef void(CALL_CONVENTION *func_type_com_asprise_ocr_stop) (long long)
 
typedef char *CALL_CONVENTIONfunc_type_com_asprise_ocr_recognize(long long, const char *, int, int, int, int, int, const char *, const char *, const char *, const char *, const char *)
 
typedef const char *func_type_com_asprise_ocr_input_license func_com_asprise_ocr_input_license = NULL
 

Functions

EXPORT_API const char *CALL_CONVENTION com_asprise_ocr_version ()
 
EXPORT_API int CALL_CONVENTION com_asprise_ocr_setup (bool queryOnly)
 
EXPORT_API char *CALL_CONVENTION com_asprise_ocr_list_supported_langs ()
 
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)
 
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)
 
EXPORT_API void CALL_CONVENTION com_asprise_ocr_stop (long long handle)
 
EXPORT_API void CALL_CONVENTION com_asprise_ocr_input_license (const char *licenseeName, const char *licenseCode)
 
EXPORT_API void CALL_CONVENTION com_asprise_ocr_util_delete (long long handle, bool isArray)
 
EXPORT_API void CALL_CONVENTION initaocr (void)
 
EXPORT_API void CALL_CONVENTION initaocr_x64 (void)
 
typedef int (CALL_CONVENTION *func_type_com_asprise_ocr_setup)(bool)
 
typedef void (CALL_CONVENTION *func_type_com_asprise_ocr_util_delete)(long long
 
bool checkIfFuncFound (bool funcFound, const char *funcName)
 
LIBRARY_HANDLE dynamic_load_aocr_library (const char *pathToFolderContainingAocrLibrary)
 
bool dynamic_unload_aocr_library (LIBRARY_HANDLE handle)
 
bool assertFuncExists (bool exists)
 
const char * c_com_asprise_ocr_version ()
 
int CALL_CONVENTION c_com_asprise_ocr_setup (bool queryOnly)
 
char * c_com_asprise_ocr_list_supported_langs ()
 
long long c_com_asprise_ocr_start (const char *lang, const char *speed, const char *propSpec, const char *propSeparator, const char *propKeyValueSpeparator)
 
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)
 
void c_com_asprise_ocr_stop (long long handle)
 
void c_com_asprise_ocr_input_license (const char *licenseeName, const char *licenseCode)
 
void c_com_asprise_ocr_util_delete (long long handle, bool isArray)
 

Variables

typedef bool
 
func_type_com_asprise_ocr_list_supported_langs func_com_asprise_ocr_list_supported_langs = NULL
 
func_type_com_asprise_ocr_recognize func_com_asprise_ocr_recognize = NULL
 
func_type_com_asprise_ocr_setup func_com_asprise_ocr_setup = NULL
 
func_type_com_asprise_ocr_start func_com_asprise_ocr_start = NULL
 
func_type_com_asprise_ocr_stop func_com_asprise_ocr_stop = NULL
 
func_type_com_asprise_ocr_util_delete func_com_asprise_ocr_util_delete = NULL
 
func_type_com_asprise_ocr_version func_com_asprise_ocr_version = NULL
 

Macro Definition Documentation

#define CALL_CONVENTION
#define EXPORT_API

Asprise OCR API for C/C++: ALL RIGHTS RESERVED (c) Asprise.com

Read developer's guide to C/C++ OCR SDK API.

For evaluation only: 1) Using this file with or without modification in any application is strictly prohibited unless you have obtained a license from Asprise.

2) Distributing this file in any way is prohibited.

Visit Asprise OCR SDK C/C++ API

#define FUNC_NAME_com_asprise_ocr_input_license   "com_asprise_ocr_input_license"
#define FUNC_NAME_com_asprise_ocr_list_supported_langs   "com_asprise_ocr_list_supported_langs"
#define FUNC_NAME_com_asprise_ocr_recognize   "com_asprise_ocr_recognize"
#define FUNC_NAME_com_asprise_ocr_setup   "com_asprise_ocr_setup"
#define FUNC_NAME_com_asprise_ocr_start   "com_asprise_ocr_start"
#define FUNC_NAME_com_asprise_ocr_stop   "com_asprise_ocr_stop"
#define FUNC_NAME_com_asprise_ocr_util_delete   "com_asprise_ocr_util_delete"
#define FUNC_NAME_com_asprise_ocr_version   "com_asprise_ocr_version"
#define OCR_OUTPUT_FORMAT_PDF   "pdf"
#define OCR_OUTPUT_FORMAT_PLAINTEXT   "text"
#define OCR_OUTPUT_FORMAT_RTF   "rtf"
#define OCR_OUTPUT_FORMAT_XML   "xml"
#define OCR_PROP_DICT_DICT_IMPORTANCE   "PROP_DICT_DICT_IMPORTANCE"

Percentage measuring the importance of the dictionary (0: not at all; 100: extremely important; default: 10)

#define OCR_PROP_IMG_PREPROCESS_CUSTOM_CMDS   "PROP_IMG_PREPROCESS_CUSTOM_CMDS"

Image pre-processing command

#define OCR_PROP_IMG_PREPROCESS_TYPE   "PROP_IMG_PREPROCESS_TYPE"

Image pre-processing type

#define OCR_PROP_IMG_PREPROCESS_TYPE_CUSTOM   "custom"
#define OCR_PROP_IMG_PREPROCESS_TYPE_DEFAULT   "default"
#define OCR_PROP_IMG_PREPROCESS_TYPE_DEFAULT_WITH_ORIENTATION_DETECTION   "default_with_orientation_detection"
#define OCR_PROP_INPUT_PDF_DPI   "PROP_INPUT_PDF_DPI"

The DPI to be used to render the PDF file; default is 300 if not specified

#define OCR_PROP_INPUT_PDF_SINGLE_IMG_PER_PAGE   "PROP_INPUT_PDF_SINGLE_IMG_PER_PAGE"

Set to true if there is only one image per page on the input PDF file; potentially speed up of the process

#define OCR_PROP_LIMIT_TO_CHARSET   "PROP_LIMIT_TO_CHARSET"
#define OCR_PROP_OUTPUT_SEPARATE_WORDS   "PROP_OUTPUT_SEPARATE_WORDS"
#define OCR_PROP_PAGE_TYPE   "PROP_PAGE_TYPE"
#define OCR_PROP_PAGE_TYPE_AUTO_DETECT   "auto"
#define OCR_PROP_PAGE_TYPE_SCATTERED   "scattered"
#define OCR_PROP_PAGE_TYPE_SINGLE_BLOCK   "single_block"
#define OCR_PROP_PAGE_TYPE_SINGLE_CHARACTOR   "single_char"
#define OCR_PROP_PAGE_TYPE_SINGLE_COLUMN   "single_column"
#define OCR_PROP_PAGE_TYPE_SINGLE_LINE   "single_line"
#define OCR_PROP_PAGE_TYPE_SINGLE_WORD   "single_word"
#define OCR_PROP_PDF_OUTPUT_CONF_THRESHOLD   "PROP_PDF_OUTPUT_CONF_THRESHOLD"

Text recognized below or above confidence will be highlighted in different colors.

#define OCR_PROP_PDF_OUTPUT_FILE   "PROP_PDF_OUTPUT_FILE"
#define OCR_PROP_PDF_OUTPUT_FONT   "PROP_PDF_OUTPUT_FONT"
#define OCR_PROP_PDF_OUTPUT_IMAGE_DPI   "PROP_PDF_OUTPUT_IMAGE_DPI"
#define OCR_PROP_PDF_OUTPUT_IMAGE_FORCE_BW   "PROP_PDF_OUTPUT_IMAGE_FORCE_BW"
#define OCR_PROP_PDF_OUTPUT_PDFA   "PROP_PDF_OUTPUT_PDFA"
#define OCR_PROP_PDF_OUTPUT_PDFA_FONT_FILE   "PROP_PDF_OUTPUT_PDFA_FONT_FILE"
#define OCR_PROP_PDF_OUTPUT_RETURN_TEXT   "PROP_PDF_OUTPUT_RETURN_TEXT"

Return text in 'text' or 'xml' format

#define OCR_PROP_PDF_OUTPUT_TEXT_VISIBLE   "PROP_PDF_OUTPUT_TEXT_VISIBLE"
#define OCR_PROP_RTF_OUTPUT_FILE   "PROP_RTF_OUTPUT_FILE"
#define OCR_PROP_RTF_OUTPUT_RETURN_TEXT   "PROP_RTF_OUTPUT_RETURN_TEXT"

Return text in 'text' or 'xml' format

#define OCR_PROP_RTF_PAPER_SIZE   "PROP_RTF_PAPER_SIZE"

default is LETTER, may set to A4.

#define OCR_PROP_RTF_SHOW_TABLE_CELL_BORDER   "PROP_RTF_SHOW_TABLE_CELL_BORDER"

set to false to disable rendering table cells borders into black. Default is true.

#define OCR_PROP_SAVE_INTERMEDIATE_IMAGES_TO_DIR   "PROP_SAVE_INTERMEDIATE_IMAGES_TO_DIR"

Save intermediate images generated for debug purpose - don't specify or empty string to skip saving

#define OCR_PROP_TABLE_MIN_SIDE_LENGTH   "PROP_TABLE_MIN_SIDE_LENGTH"

default is 32 if not specified

#define OCR_PROP_TABLE_SKIP_DETECTION   "PROP_TABLE_SKIP_DETECTION"

table will be detected by default; set this property to true to skip detection.

#define OCR_RECOGNIZE_TYPE_ALL   "all"
#define OCR_RECOGNIZE_TYPE_BARCODE   "barcode"
#define OCR_RECOGNIZE_TYPE_TEXT   "text"
#define OCR_SPEED_FAST   "fast"
#define OCR_SPEED_FASTEST   "fastest"
#define OCR_SPEED_SLOW   "slow"
#define OCR_START_PROP_DICT_CUSTOM_DICT_FILE   "START_PROP_DICT_CUSTOM_DICT_FILE"

Path to your custom dictionary (words are separated using line breaks). Default value: null

#define OCR_START_PROP_DICT_CUSTOM_TEMPLATES_FILE   "START_PROP_DICT_CUSTOM_TEMPLATES_FILE"

Path to your custom templates (templates are separated using line breaks). Default value: null

#define OCR_START_PROP_DICT_SKIP_BUILT_IN_ALL   "START_PROP_DICT_SKIP_BUILT_IN_ALL"

set to 'true' to skip using all built-in dicts. Default value: 'false'

#define OCR_START_PROP_DICT_SKIP_BUILT_IN_DEFAULT   "START_PROP_DICT_SKIP_BUILT_IN_DEFAULT"

set to 'true' to skip using the default built in dict. Default value: 'false'

Typedef Documentation

typedef const char* func_type_com_asprise_ocr_input_license func_com_asprise_ocr_input_license = NULL
typedef void(* FUNC_TYPE) (void *)
typedef char* CALL_CONVENTION* func_type_com_asprise_ocr_list_supported_langs()
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 *)
typedef const char* CALL_CONVENTION* func_type_com_asprise_ocr_version()
typedef void* LIBRARY_HANDLE
typedef long long(CALL_CONVENTION *func_type_com_asprise_ocr_start)(const char *
typedef void

Function Documentation

bool assertFuncExists ( bool  exists)
void c_com_asprise_ocr_input_license ( const char *  licenseeName,
const char *  licenseCode 
)

Inputs the license information

char* c_com_asprise_ocr_list_supported_langs ( )

Call after setup; list all supported langs separated by comma; please delete returned char[] after use.

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 
)

returns the recognized text or error message in format like '<error: ...'

int CALL_CONVENTION c_com_asprise_ocr_setup ( bool  queryOnly)

Returns 0 if setup required; 1 if setup has been done; or negative error code.

long long c_com_asprise_ocr_start ( const char *  lang,
const char *  speed,
const char *  propSpec,
const char *  propSeparator,
const char *  propKeyValueSpeparator 
)

returns the ocr engine handle or negative error code.

void c_com_asprise_ocr_stop ( long long  handle)

Destroys the OCR engine.

void c_com_asprise_ocr_util_delete ( long long  handle,
bool  isArray 
)

Util function that perform C delete/delete[]

const char* c_com_asprise_ocr_version ( )

Returns the version of the library.

bool checkIfFuncFound ( bool  funcFound,
const char *  funcName 
)
EXPORT_API void CALL_CONVENTION com_asprise_ocr_input_license ( const char *  licenseeName,
const char *  licenseCode 
)

Inputs the license information

EXPORT_API char* CALL_CONVENTION com_asprise_ocr_list_supported_langs ( )

Call after setup; list all supported langs separated by comma; please delete returned char[] after use.

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 
)

returns the recognized text or error message in format like '<error: ...'

EXPORT_API int CALL_CONVENTION com_asprise_ocr_setup ( bool  queryOnly)

Returns 0 if setup required; 1 if setup has been done; or negative error code.

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 
)

returns the ocr engine handle or negative error code.

EXPORT_API void CALL_CONVENTION com_asprise_ocr_stop ( long long  handle)

Destroies the OCR engine.

EXPORT_API void CALL_CONVENTION com_asprise_ocr_util_delete ( long long  handle,
bool  isArray 
)

Util function that perform C delete/delete[]

EXPORT_API const char* CALL_CONVENTION com_asprise_ocr_version ( )

Returns the version of the library.

LIBRARY_HANDLE dynamic_load_aocr_library ( const char *  pathToFolderContainingAocrLibrary)

Dynamically load aocr library; return the loaded library handle or NULL if failed.

bool dynamic_unload_aocr_library ( LIBRARY_HANDLE  handle)

unload aocr library; return true if successful or false if failed.

call setup

EXPORT_API void CALL_CONVENTION initaocr_x64 ( void  )
typedef int ( CALL_CONVENTION func_type_com_asprise_ocr_setup)
typedef void ( CALL_CONVENTION func_type_com_asprise_ocr_util_delete)

Variable Documentation

typedef bool
func_type_com_asprise_ocr_list_supported_langs func_com_asprise_ocr_list_supported_langs = NULL
func_type_com_asprise_ocr_recognize func_com_asprise_ocr_recognize = NULL
func_type_com_asprise_ocr_setup func_com_asprise_ocr_setup = NULL
func_type_com_asprise_ocr_start func_com_asprise_ocr_start = NULL
func_type_com_asprise_ocr_stop func_com_asprise_ocr_stop = NULL
func_type_com_asprise_ocr_util_delete func_com_asprise_ocr_util_delete = NULL
func_type_com_asprise_ocr_version func_com_asprise_ocr_version = NULL