williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@4
|
5 |
* under the terms of "Eclipse Public License v1.0""
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description: APIs of the OCR(Optical Character Recognition), current engine
|
williamr@2
|
15 |
* can recognize 24 bit colored image and 8 bit gray scale image
|
williamr@2
|
16 |
* in BMP format.
|
williamr@2
|
17 |
*
|
williamr@2
|
18 |
*
|
williamr@2
|
19 |
*/
|
williamr@2
|
20 |
|
williamr@2
|
21 |
|
williamr@2
|
22 |
#ifndef OCRCOMMON_H
|
williamr@2
|
23 |
#define OCRCOMMON_H
|
williamr@2
|
24 |
|
williamr@2
|
25 |
// INCLUDE FILES
|
williamr@2
|
26 |
#include <e32std.h>
|
williamr@2
|
27 |
#include <e32def.h>
|
williamr@2
|
28 |
#include <e32base.h>
|
williamr@2
|
29 |
|
williamr@2
|
30 |
/**
|
williamr@2
|
31 |
* Bad image or unsupported format
|
williamr@2
|
32 |
*/
|
williamr@2
|
33 |
const TInt KErrOcrBadImage (-1001);
|
williamr@2
|
34 |
|
williamr@2
|
35 |
/**
|
williamr@2
|
36 |
* Unsupported language
|
williamr@2
|
37 |
*/
|
williamr@2
|
38 |
const TInt KErrOcrBadLanguage (-1002);
|
williamr@2
|
39 |
|
williamr@2
|
40 |
/**
|
williamr@2
|
41 |
* Bad layout region
|
williamr@2
|
42 |
*/
|
williamr@2
|
43 |
const TInt KErrOcrBadRegion (-1003);
|
williamr@2
|
44 |
|
williamr@2
|
45 |
/**
|
williamr@2
|
46 |
* Not set any language
|
williamr@2
|
47 |
*/
|
williamr@2
|
48 |
const TInt KErrOcrNotSetLanguage (-1004);
|
williamr@2
|
49 |
|
williamr@2
|
50 |
/**
|
williamr@2
|
51 |
* Not set any language packages
|
williamr@2
|
52 |
*/
|
williamr@2
|
53 |
const TInt KErrOcrBadDictFile (-1005);
|
williamr@2
|
54 |
|
williamr@2
|
55 |
/** Type of the text layouts
|
williamr@2
|
56 |
*/
|
williamr@2
|
57 |
enum TOcrLayoutType
|
williamr@2
|
58 |
{
|
williamr@2
|
59 |
/** Texts in the block is horizontal
|
williamr@2
|
60 |
*/
|
williamr@2
|
61 |
EOcrLayoutTypeH,
|
williamr@2
|
62 |
|
williamr@2
|
63 |
/** Texts in the block is vertical
|
williamr@2
|
64 |
*/
|
williamr@2
|
65 |
EOcrLayoutTypeV
|
williamr@2
|
66 |
};
|
williamr@2
|
67 |
|
williamr@2
|
68 |
/** Type of the text
|
williamr@2
|
69 |
*/
|
williamr@2
|
70 |
enum TOcrTextType
|
williamr@2
|
71 |
{
|
williamr@2
|
72 |
/** when the image or recognition area has multi-line format
|
williamr@2
|
73 |
*/
|
williamr@2
|
74 |
EOcrTextMultiLine,
|
williamr@2
|
75 |
|
williamr@2
|
76 |
/** when the image or recognition area has single-line format
|
williamr@2
|
77 |
*/
|
williamr@2
|
78 |
EOcrTextSingleLine
|
williamr@2
|
79 |
};
|
williamr@2
|
80 |
|
williamr@2
|
81 |
/** Type of the text background
|
williamr@2
|
82 |
*/
|
williamr@2
|
83 |
enum TOcrBackgroundType
|
williamr@2
|
84 |
{
|
williamr@2
|
85 |
/** light character with light background
|
williamr@2
|
86 |
*/
|
williamr@2
|
87 |
EOcrBackgroundLight,
|
williamr@2
|
88 |
|
williamr@2
|
89 |
/** dark character with dark background
|
williamr@2
|
90 |
*/
|
williamr@2
|
91 |
EOcrBackgroundDark,
|
williamr@2
|
92 |
|
williamr@2
|
93 |
/** un-suspected background
|
williamr@2
|
94 |
*/
|
williamr@2
|
95 |
EOcrBackgroundUnknown
|
williamr@2
|
96 |
};
|
williamr@2
|
97 |
|
williamr@2
|
98 |
/**
|
williamr@2
|
99 |
* OCR (Optical Character Recognition) Text Line Information
|
williamr@2
|
100 |
*
|
williamr@2
|
101 |
* This class holds the information from the OCR engine after the recognition
|
williamr@2
|
102 |
* Note that all memory ownership belongs to the OCR engine, so do not need to
|
williamr@2
|
103 |
* either allocate memory for it or push it to the CleanupStack. Engine will
|
williamr@2
|
104 |
* release the memory whenever necessary
|
williamr@2
|
105 |
*
|
williamr@2
|
106 |
* @lib ocrsrv.lib
|
williamr@2
|
107 |
* @since S60 3.1
|
williamr@2
|
108 |
*/
|
williamr@2
|
109 |
class TOCRTextLineInfo
|
williamr@2
|
110 |
{
|
williamr@2
|
111 |
public:
|
williamr@2
|
112 |
|
williamr@2
|
113 |
/**
|
williamr@2
|
114 |
* Text buffer for the line. Note that after layout analysis, this is NULL
|
williamr@2
|
115 |
* and the buffer will be filled after recognition (Not Own)
|
williamr@2
|
116 |
*/
|
williamr@2
|
117 |
HBufC16* iText;
|
williamr@2
|
118 |
|
williamr@2
|
119 |
/**
|
williamr@2
|
120 |
* Region coordinate to be processed
|
williamr@2
|
121 |
*/
|
williamr@2
|
122 |
TRect iRect;
|
williamr@2
|
123 |
|
williamr@2
|
124 |
/**
|
williamr@2
|
125 |
* Array of the character rects. (Not Own)
|
williamr@2
|
126 |
*/
|
williamr@2
|
127 |
TRect* iCharRect;
|
williamr@2
|
128 |
|
williamr@2
|
129 |
/**
|
williamr@2
|
130 |
* Number of characters
|
williamr@2
|
131 |
*/
|
williamr@2
|
132 |
TInt iCharCount;
|
williamr@2
|
133 |
};
|
williamr@2
|
134 |
|
williamr@2
|
135 |
/**
|
williamr@2
|
136 |
* OCR (Optical Character Recognition) Text Line Information
|
williamr@2
|
137 |
*
|
williamr@2
|
138 |
* This class holds the information from the layout analysis, the engine
|
williamr@2
|
139 |
* will allocate the memory of TOCRBlockInfo array, and pass the ownership
|
williamr@2
|
140 |
* to you while you can remove it by delete[]
|
williamr@2
|
141 |
*
|
williamr@2
|
142 |
* @lib ocrsrv.lib
|
williamr@2
|
143 |
* @since S60 3.1
|
williamr@2
|
144 |
*/
|
williamr@2
|
145 |
class TOCRBlockInfo
|
williamr@2
|
146 |
{
|
williamr@2
|
147 |
public:
|
williamr@2
|
148 |
|
williamr@2
|
149 |
/**
|
williamr@2
|
150 |
* Region coordinate to be processed
|
williamr@2
|
151 |
*/
|
williamr@2
|
152 |
TRect iRect;
|
williamr@2
|
153 |
|
williamr@2
|
154 |
/**
|
williamr@2
|
155 |
* Layout Type (Horizontal or Vertical)
|
williamr@2
|
156 |
*/
|
williamr@2
|
157 |
TOcrLayoutType iType;
|
williamr@2
|
158 |
|
williamr@2
|
159 |
/**
|
williamr@2
|
160 |
* Id of the block
|
williamr@2
|
161 |
*/
|
williamr@2
|
162 |
TInt iBlockId;
|
williamr@2
|
163 |
};
|
williamr@2
|
164 |
|
williamr@2
|
165 |
/**
|
williamr@2
|
166 |
* OCR (Optical Character Recognition) Text Block Information
|
williamr@2
|
167 |
*
|
williamr@2
|
168 |
* This class holds the information from the OCR engine after the recognition
|
williamr@2
|
169 |
* Note that all memory ownership belongs to the OCR engine, so do not need to
|
williamr@2
|
170 |
* either allocate memory for it or push it to the CleanupStack. Engine will
|
williamr@2
|
171 |
* release the memory whenever necessary
|
williamr@2
|
172 |
*
|
williamr@2
|
173 |
* @lib ocrsrv.lib
|
williamr@2
|
174 |
* @since S60 3.1
|
williamr@2
|
175 |
*/
|
williamr@2
|
176 |
class TOCRTextRgnInfo
|
williamr@2
|
177 |
{
|
williamr@2
|
178 |
public:
|
williamr@2
|
179 |
|
williamr@2
|
180 |
/**
|
williamr@2
|
181 |
* Region coordinate to be processed
|
williamr@2
|
182 |
*/
|
williamr@2
|
183 |
TRect iRect;
|
williamr@2
|
184 |
|
williamr@2
|
185 |
/**
|
williamr@2
|
186 |
* Layout Type (Horizontal or Vertical)
|
williamr@2
|
187 |
*/
|
williamr@2
|
188 |
TOcrLayoutType iType;
|
williamr@2
|
189 |
|
williamr@2
|
190 |
/**
|
williamr@2
|
191 |
* Id of the block
|
williamr@2
|
192 |
*/
|
williamr@2
|
193 |
TInt iBlockId;
|
williamr@2
|
194 |
|
williamr@2
|
195 |
/**
|
williamr@2
|
196 |
* Text line Information (Not Own)
|
williamr@2
|
197 |
*/
|
williamr@2
|
198 |
TOCRTextLineInfo* iLines;
|
williamr@2
|
199 |
|
williamr@2
|
200 |
/**
|
williamr@2
|
201 |
* Number of Lines
|
williamr@2
|
202 |
*/
|
williamr@2
|
203 |
TInt iLineCount;
|
williamr@2
|
204 |
};
|
williamr@2
|
205 |
|
williamr@2
|
206 |
/**
|
williamr@2
|
207 |
* OCR (Optical Character Recognition) Setting for Layout Analysis
|
williamr@2
|
208 |
*
|
williamr@2
|
209 |
* The setting for layout analysis
|
williamr@2
|
210 |
*
|
williamr@2
|
211 |
* @lib ocrsrv.lib
|
williamr@2
|
212 |
* @since S60 3.1
|
williamr@2
|
213 |
*/
|
williamr@2
|
214 |
class TOCRLayoutSetting
|
williamr@2
|
215 |
{
|
williamr@2
|
216 |
public:
|
williamr@2
|
217 |
|
williamr@2
|
218 |
/**
|
williamr@2
|
219 |
* Image brightness
|
williamr@2
|
220 |
*/
|
williamr@2
|
221 |
enum TOcrBrightness
|
williamr@2
|
222 |
{
|
williamr@2
|
223 |
ENormal, ///< brightness is normal
|
williamr@2
|
224 |
ELight, ///< brightness is light
|
williamr@2
|
225 |
EDark ///< brightness is dark
|
williamr@2
|
226 |
};
|
williamr@2
|
227 |
|
williamr@2
|
228 |
/**
|
williamr@2
|
229 |
* Whether skew adjustment enabled, in most cases
|
williamr@2
|
230 |
* this flag shall be always on; But if images are in
|
williamr@2
|
231 |
* very good contition, this flag can be off to increase
|
williamr@2
|
232 |
* the recognition speed
|
williamr@2
|
233 |
*/
|
williamr@2
|
234 |
TBool iSkew;
|
williamr@2
|
235 |
|
williamr@2
|
236 |
/**
|
williamr@2
|
237 |
* Brightness for text background
|
williamr@2
|
238 |
*/
|
williamr@2
|
239 |
TOcrBrightness iBrightness;
|
williamr@2
|
240 |
};
|
williamr@2
|
241 |
|
williamr@2
|
242 |
/**
|
williamr@2
|
243 |
* OCR (Optical Character Recognition) Setting for Recognize (Reserved)
|
williamr@2
|
244 |
*
|
williamr@2
|
245 |
* The setting for recognition
|
williamr@2
|
246 |
*
|
williamr@2
|
247 |
* @lib ocrsrv.lib
|
williamr@2
|
248 |
* @since S60 3.1
|
williamr@2
|
249 |
*/
|
williamr@2
|
250 |
class TOCRRecognizeSetting
|
williamr@2
|
251 |
{
|
williamr@2
|
252 |
public:
|
williamr@2
|
253 |
|
williamr@2
|
254 |
/**
|
williamr@2
|
255 |
* Reserved for future use
|
williamr@2
|
256 |
*/
|
williamr@2
|
257 |
TAny* iAny;
|
williamr@2
|
258 |
};
|
williamr@2
|
259 |
|
williamr@2
|
260 |
/**
|
williamr@2
|
261 |
* OCR (Optical Character Recognition) Block Information for Recognizing Blocks
|
williamr@2
|
262 |
*
|
williamr@2
|
263 |
* This class is for recognizing blocks. @see MOCREngineRecognizeBlock::RecognizeBlockL
|
williamr@2
|
264 |
*
|
williamr@2
|
265 |
* @lib ocrsrv.lib
|
williamr@2
|
266 |
* @since S60 3.1
|
williamr@2
|
267 |
*/
|
williamr@2
|
268 |
class TOCRLayoutBlockInfo
|
williamr@2
|
269 |
{
|
williamr@2
|
270 |
public:
|
williamr@2
|
271 |
|
williamr@2
|
272 |
/**
|
williamr@2
|
273 |
* Region coordinate to be processed
|
williamr@2
|
274 |
*/
|
williamr@2
|
275 |
TRect iRect;
|
williamr@2
|
276 |
|
williamr@2
|
277 |
/**
|
williamr@2
|
278 |
* Layout Type (Horizontal or Vertical)
|
williamr@2
|
279 |
*/
|
williamr@2
|
280 |
TOcrLayoutType iLayout;
|
williamr@2
|
281 |
|
williamr@2
|
282 |
/**
|
williamr@2
|
283 |
* Text Type (Multi or Single line)
|
williamr@2
|
284 |
*/
|
williamr@2
|
285 |
TOcrTextType iText;
|
williamr@2
|
286 |
|
williamr@2
|
287 |
/**
|
williamr@2
|
288 |
* Brightness for text background
|
williamr@2
|
289 |
*/
|
williamr@2
|
290 |
TOcrBackgroundType iBackgroundColor;
|
williamr@2
|
291 |
};
|
williamr@2
|
292 |
|
williamr@2
|
293 |
/**
|
williamr@2
|
294 |
* OCR (Optical Character Recognition) Block Information for Recognizing Blocks
|
williamr@2
|
295 |
*
|
williamr@2
|
296 |
* This class is for recognizing blocks. @see MOCREngineRecognizeBlock::RecognizeSpecialRegionL
|
williamr@2
|
297 |
*
|
williamr@2
|
298 |
* @lib ocrsrv.lib
|
williamr@2
|
299 |
* @since S60 3.1
|
williamr@2
|
300 |
*/
|
williamr@2
|
301 |
class TRegionInfo
|
williamr@2
|
302 |
{
|
williamr@2
|
303 |
public:
|
williamr@2
|
304 |
|
williamr@2
|
305 |
/**
|
williamr@2
|
306 |
* Content Type
|
williamr@2
|
307 |
*/
|
williamr@2
|
308 |
enum TOcrRegionType
|
williamr@2
|
309 |
{
|
williamr@2
|
310 |
EEmailAddress, ///< E-mail address
|
williamr@2
|
311 |
ETelephoneNumber, ///< telephone number
|
williamr@2
|
312 |
EWWWAddress ///< website address
|
williamr@2
|
313 |
};
|
williamr@2
|
314 |
|
williamr@2
|
315 |
public:
|
williamr@2
|
316 |
/**
|
williamr@2
|
317 |
* Region coordinate to be processed
|
williamr@2
|
318 |
*/
|
williamr@2
|
319 |
TRect iRect;
|
williamr@2
|
320 |
|
williamr@2
|
321 |
/**
|
williamr@2
|
322 |
* Brightness for text background
|
williamr@2
|
323 |
*/
|
williamr@2
|
324 |
TOcrBackgroundType iBackgroundColor;
|
williamr@2
|
325 |
|
williamr@2
|
326 |
/**
|
williamr@2
|
327 |
* Content Type
|
williamr@2
|
328 |
*/
|
williamr@2
|
329 |
TOcrRegionType iType;
|
williamr@2
|
330 |
};
|
williamr@2
|
331 |
|
williamr@2
|
332 |
/**
|
williamr@2
|
333 |
* OCR (Optical Character Recognition) Engine Environment Settings
|
williamr@2
|
334 |
*
|
williamr@2
|
335 |
* This class is for setting the thread priority and the maximum heap
|
williamr@2
|
336 |
* allocation for the ocr engine
|
williamr@2
|
337 |
*
|
williamr@2
|
338 |
* @lib ocrsrv.lib
|
williamr@2
|
339 |
* @since S60 3.1
|
williamr@2
|
340 |
*/
|
williamr@2
|
341 |
class TOcrEngineEnv
|
williamr@2
|
342 |
{
|
williamr@2
|
343 |
public:
|
williamr@2
|
344 |
/**
|
williamr@2
|
345 |
* Thread priority. The Engine Factory will create a child thread
|
williamr@2
|
346 |
* for the OCR process, EPriorityLess is recommended for most cases
|
williamr@2
|
347 |
*/
|
williamr@2
|
348 |
TThreadPriority iPriority;
|
williamr@2
|
349 |
|
williamr@2
|
350 |
/**
|
williamr@2
|
351 |
* The maximum heap size for the OCR process, must be larger than
|
williamr@2
|
352 |
* KMinHeapGrowBy x 1200 to do recognition for 1600x1200 images. If
|
williamr@2
|
353 |
* this value is lower(equal) than KMinHeapGrowBy*1000, a leave will
|
williamr@2
|
354 |
* happen in CreateOCREngineL with KErrArgument
|
williamr@2
|
355 |
*/
|
williamr@2
|
356 |
TInt iMaxHeapSize;
|
williamr@2
|
357 |
};
|
williamr@2
|
358 |
|
williamr@2
|
359 |
#endif // OCRCOMMON_H
|
williamr@2
|
360 |
|
williamr@2
|
361 |
// End of file
|