• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**********************************************************************
2  * File:			ocrshell.h
3  * Description:	Code for the OCR side of the OCR API.
4  * Author:		Hewlett-Packard Co
5  *
6  * (C) Copyright 1996, Hewlett-Packard Co.
7  ** Licensed under the Apache License, Version 2.0 (the "License");
8  ** you may not use this file except in compliance with the License.
9  ** You may obtain a copy of the License at
10  ** http://www.apache.org/licenses/LICENSE-2.0
11  ** Unless required by applicable law or agreed to in writing, software
12  ** distributed under the License is distributed on an "AS IS" BASIS,
13  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  ** See the License for the specific language governing permissions and
15  ** limitations under the License.
16  *
17  **********************************************************************/
18 
19 #ifndef           OCRSHELL_H
20 #define           OCRSHELL_H
21 
22 /**********************************************************************
23  * This file contains code for the OCR side of the HP OCR interface.
24  * The code is designed to be used with either an ANSI C or C++ compiler.
25  * The structures are designed to allow them to be used with any
26  * structure alignment upto 8.
27  **********************************************************************/
28 
29 #include          "ocrclass.h"
30 
31 #define EUC_FORMAT_MASK   0xe0
32 
33 /**********************************************************************
34  * ocr_open_shm
35  *
36  * Attempt to connect to the shared memory segment and semaphores used
37  * in talking to the OCR engine. Called from OCR engine.
38  * The parameters are the command line arguments in order.
39  * The final parameter is a return value indicating the user-requested
40  * language.					The value will be LANGE_NONE if the user wishes to use
41  * the default.
42  **********************************************************************/
43 #ifdef __MAC__
44 inT16 ocr_open_shm(uinT16 *lang);
45 #else
46 inT16 ocr_open_shm(                       /*open the shm */
47                    const char *shm_h,     /*handle of shm */
48                    const char *shm_size,  /*size of shm segment */
49                    const char *mutex_h,   /*hp mutex */
50                    const char *ocr_h,     /*ocr semaphore */
51                    const char *hp_h,      /*hp semaphore */
52                    const char *lang_str,  /*language */
53                    uinT16 *lang           /*required language */
54                   );
55 #endif
56 
57 /**********************************************************************
58  * ocr_append_fontinfo
59  *
60  * Initialize one of the font descriptors.
61  **********************************************************************/
62 
63 inT16 ocr_append_fontinfo(                    /*put info into shm */
64                           uinT16 language,    /*default language */
65                           uinT8 font_family,  /*serif/not, fixed/not */
66                           uinT8 char_set,     /*character set standard */
67                           uinT8 pitch,        /*fixed or prop */
68                           const char *name    /*plain ascii name */
69                          );
70 
71 /**********************************************************************
72  * ocr_setup_startinfo
73  *
74  * Setup the info on the OCR engine. Uses 16 bit chars to name the
75  * engine.
76  **********************************************************************/
77 
78 inT16 ocr_setup_startinfo(                       /*put info into shm */
79                           uinT32 protocol,       /*interface version */
80                           uinT16 language,       /*default language */
81                           const uinT16 *name,    /*name of engine */
82                           const uinT16 *version  /*version of engine */
83                          );
84 
85 /**********************************************************************
86  * ocr_setup_startinfo_ansi
87  *
88  * Setup the info on the OCR engine. Uses 8 bit chars to name the
89  * engine.
90  **********************************************************************/
91 
92 inT16 ocr_setup_startinfo_ansi(                     /*put info into shm */
93                                uinT32 protocol,     /*interface version */
94                                uinT16 language,     /*default language */
95                                const char *name,    /*name of engine */
96                                const char *version  /*version of engine */
97                               );
98 
99 /**********************************************************************
100  * ocr_get_first_image_strip
101  *
102  * Wait for the master to send the first image strip and return a
103  * pointer to it. The result is NULL if it is time to exit.
104  **********************************************************************/
105 
106                                  /*get image strip */
107 ESTRIP_DESC *ocr_get_first_image_strip();
108 
109 /**********************************************************************
110  * ocr_get_next_image_strip
111  *
112  * Wait for the master to send the next image strip and return a
113  * pointer to it. The result is NULL if it is time to exit.
114  **********************************************************************/
115 
116                                  /*get image strip */
117 ESTRIP_DESC *ocr_get_next_image_strip();
118 
119 /**********************************************************************
120  * ocr_setup_monitor
121  *
122  * Setup the progress monitor. Call before starting the recognize task.
123  **********************************************************************/
124 
125 ETEXT_DESC *ocr_setup_monitor();  /*setup monitor */
126 
127 /**********************************************************************
128  * ocr_char_space
129  *
130  * Return the number of chars that can be fitted into the buffer.
131  **********************************************************************/
132 
133 inT32 ocr_char_space();  /*put char into shm */
134 
135 /**********************************************************************
136  * ocr_append_char
137  *
138  * Add a character to the output. Returns OKAY if successful, HPERR
139  * if there was insufficient room in the buffer.
140  **********************************************************************/
141 
142 inT16 ocr_append_char(                              /*put char into shm */
143                       uinT16 char_code,             /*character itself */
144                       inT16 left,                   /*of char (-1) */
145                       inT16 right,                  /*of char (-1) */
146                       inT16 top,                    /*of char (-1) */
147                       inT16 bottom,                 /*of char (-1) */
148                       inT16 font_index,             /*what font (-1) */
149                       uinT8 confidence,             /*0=perfect, 100=reject (0/100) */
150                       uinT8 point_size,             /*of char, 72=i inch, (10) */
151                       inT8 blanks,                  /*no of spaces before this char (1) */
152                       uinT8 enhancement,            /*char enhancement (0) */
153                       OCR_CHAR_DIRECTION text_dir,  /*rendering direction (OCR_CDIR_RIGHT_LEFT) */
154                       OCR_LINE_DIRECTION line_dir,  /*line rendering direction (OCR_LDIR_DOWN_RIGHT) */
155                       OCR_NEWLINE_TYPE nl_type      /*type of newline (if any) (OCR_NL_NONE) */
156                      );
157 
158 /**********************************************************************
159  * ocr_send_text
160  *
161  * Send the text to the host and wait for the ack.
162  * Use this function after a sequence of ocr_append_text calls to
163  * actually sent the text to the master process.
164  * Set more to come TRUE if there is more text in this page, FALSE
165  * if the OCR engine is now ready to receive another image.
166  **********************************************************************/
167 
168 inT16 ocr_send_text(                    /*send shm */
169                     BOOL8 more_to_come  /*any text left */
170                    );
171 
172 /**********************************************************************
173  * ocr_shutdown
174  *
175  * Closedown communications with the HP side and free up handles.
176  **********************************************************************/
177 
178 inT16 ocr_shutdown();  /*closedown */
179 
180 /**********************************************************************
181  * ocr_error
182  *
183  * Inform the HP side of an error.
184  * The OCR engine should do any cleanup of its own and exit aferwards.
185  * Uses the current state to determine how to send it and cleanup.
186  **********************************************************************/
187 
188 void ocr_error(                   /*send an error code */
189                OCR_ERR_CODE code  /*error code */
190               );
191 #endif
192