00001 /********************************************************************** 00002 * File: ocrshell.h 00003 * Description: Code for the OCR side of the OCR API. 00004 * Author: Hewlett-Packard Co 00005 * 00006 * (C) Copyright 1996, Hewlett-Packard Co. 00007 ** Licensed under the Apache License, Version 2.0 (the "License"); 00008 ** you may not use this file except in compliance with the License. 00009 ** You may obtain a copy of the License at 00010 ** http://www.apache.org/licenses/LICENSE-2.0 00011 ** Unless required by applicable law or agreed to in writing, software 00012 ** distributed under the License is distributed on an "AS IS" BASIS, 00013 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 ** See the License for the specific language governing permissions and 00015 ** limitations under the License. 00016 * 00017 **********************************************************************/ 00018 00019 #ifndef OCRSHELL_H 00020 #define OCRSHELL_H 00021 00022 /********************************************************************** 00023 * This file contains code for the OCR side of the HP OCR interface. 00024 * The code is designed to be used with either an ANSI C or C++ compiler. 00025 * The structures are designed to allow them to be used with any 00026 * structure alignment upto 8. 00027 **********************************************************************/ 00028 00029 #include "ocrclass.h" 00030 00031 #define EUC_FORMAT_MASK 0xe0 00032 00033 /********************************************************************** 00034 * ocr_open_shm 00035 * 00036 * Attempt to connect to the shared memory segment and semaphores used 00037 * in talking to the OCR engine. Called from OCR engine. 00038 * The parameters are the command line arguments in order. 00039 * The final parameter is a return value indicating the user-requested 00040 * language. The value will be LANGE_NONE if the user wishes to use 00041 * the default. 00042 **********************************************************************/ 00043 #ifdef __MAC__ 00044 inT16 ocr_open_shm(uinT16 *lang); 00045 #else 00046 inT16 ocr_open_shm( /*open the shm */ 00047 const char *shm_h, /*handle of shm */ 00048 const char *shm_size, /*size of shm segment */ 00049 const char *mutex_h, /*hp mutex */ 00050 const char *ocr_h, /*ocr semaphore */ 00051 const char *hp_h, /*hp semaphore */ 00052 const char *lang_str, /*language */ 00053 uinT16 *lang /*required language */ 00054 ); 00055 #endif 00056 00057 /********************************************************************** 00058 * ocr_append_fontinfo 00059 * 00060 * Initialize one of the font descriptors. 00061 **********************************************************************/ 00062 00063 inT16 ocr_append_fontinfo( /*put info into shm */ 00064 uinT16 language, /*default language */ 00065 uinT8 font_family, /*serif/not, fixed/not */ 00066 uinT8 char_set, /*character set standard */ 00067 uinT8 pitch, /*fixed or prop */ 00068 const char *name /*plain ascii name */ 00069 ); 00070 00071 /********************************************************************** 00072 * ocr_setup_startinfo 00073 * 00074 * Setup the info on the OCR engine. Uses 16 bit chars to name the 00075 * engine. 00076 **********************************************************************/ 00077 00078 inT16 ocr_setup_startinfo( /*put info into shm */ 00079 uinT32 protocol, /*interface version */ 00080 uinT16 language, /*default language */ 00081 const uinT16 *name, /*name of engine */ 00082 const uinT16 *version /*version of engine */ 00083 ); 00084 00085 /********************************************************************** 00086 * ocr_setup_startinfo_ansi 00087 * 00088 * Setup the info on the OCR engine. Uses 8 bit chars to name the 00089 * engine. 00090 **********************************************************************/ 00091 00092 inT16 ocr_setup_startinfo_ansi( /*put info into shm */ 00093 uinT32 protocol, /*interface version */ 00094 uinT16 language, /*default language */ 00095 const char *name, /*name of engine */ 00096 const char *version /*version of engine */ 00097 ); 00098 00099 /********************************************************************** 00100 * ocr_get_first_image_strip 00101 * 00102 * Wait for the master to send the first image strip and return a 00103 * pointer to it. The result is NULL if it is time to exit. 00104 **********************************************************************/ 00105 00106 /*get image strip */ 00107 ESTRIP_DESC *ocr_get_first_image_strip(); 00108 00109 /********************************************************************** 00110 * ocr_get_next_image_strip 00111 * 00112 * Wait for the master to send the next image strip and return a 00113 * pointer to it. The result is NULL if it is time to exit. 00114 **********************************************************************/ 00115 00116 /*get image strip */ 00117 ESTRIP_DESC *ocr_get_next_image_strip(); 00118 00119 /********************************************************************** 00120 * ocr_setup_monitor 00121 * 00122 * Setup the progress monitor. Call before starting the recognize task. 00123 **********************************************************************/ 00124 00125 ETEXT_DESC *ocr_setup_monitor(); /*setup monitor */ 00126 00127 /********************************************************************** 00128 * ocr_char_space 00129 * 00130 * Return the number of chars that can be fitted into the buffer. 00131 **********************************************************************/ 00132 00133 inT32 ocr_char_space(); /*put char into shm */ 00134 00135 /********************************************************************** 00136 * ocr_append_char 00137 * 00138 * Add a character to the output. Returns OKAY if successful, HPERR 00139 * if there was insufficient room in the buffer. 00140 **********************************************************************/ 00141 00142 inT16 ocr_append_char( /*put char into shm */ 00143 uinT16 char_code, /*character itself */ 00144 inT16 left, /*of char (-1) */ 00145 inT16 right, /*of char (-1) */ 00146 inT16 top, /*of char (-1) */ 00147 inT16 bottom, /*of char (-1) */ 00148 inT16 font_index, /*what font (-1) */ 00149 uinT8 confidence, /*0=perfect, 100=reject (0/100) */ 00150 uinT8 point_size, /*of char, 72=i inch, (10) */ 00151 inT8 blanks, /*no of spaces before this char (1) */ 00152 uinT8 enhancement, /*char enhancement (0) */ 00153 OCR_CHAR_DIRECTION text_dir, /*rendering direction (OCR_CDIR_RIGHT_LEFT) */ 00154 OCR_LINE_DIRECTION line_dir, /*line rendering direction (OCR_LDIR_DOWN_RIGHT) */ 00155 OCR_NEWLINE_TYPE nl_type /*type of newline (if any) (OCR_NL_NONE) */ 00156 ); 00157 00158 /********************************************************************** 00159 * ocr_send_text 00160 * 00161 * Send the text to the host and wait for the ack. 00162 * Use this function after a sequence of ocr_append_text calls to 00163 * actually sent the text to the master process. 00164 * Set more to come TRUE if there is more text in this page, FALSE 00165 * if the OCR engine is now ready to receive another image. 00166 **********************************************************************/ 00167 00168 inT16 ocr_send_text( /*send shm */ 00169 BOOL8 more_to_come /*any text left */ 00170 ); 00171 00172 /********************************************************************** 00173 * ocr_shutdown 00174 * 00175 * Closedown communications with the HP side and free up handles. 00176 **********************************************************************/ 00177 00178 inT16 ocr_shutdown(); /*closedown */ 00179 00180 /********************************************************************** 00181 * ocr_error 00182 * 00183 * Inform the HP side of an error. 00184 * The OCR engine should do any cleanup of its own and exit aferwards. 00185 * Uses the current state to determine how to send it and cleanup. 00186 **********************************************************************/ 00187 00188 void ocr_error( /*send an error code */ 00189 OCR_ERR_CODE code /*error code */ 00190 ); 00191 #endif