|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ocrengine definitions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef OCRENGINE_H |
|
20 #define OCRENGINE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "language.h" |
|
24 #include <ocrsrv.h> |
|
25 |
|
26 /** Activate language selection */ |
|
27 enum TLanguageSelected |
|
28 { |
|
29 /** One language selected to be active */ |
|
30 ESignleLanguageSelected = 1, |
|
31 |
|
32 /** Two languages selected to be active */ |
|
33 ETwoLanguageSelected = 2 |
|
34 }; |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class CEngineAdaptor; |
|
38 class COCREngineImplBase; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * Ocr engine wrapper implementation base |
|
44 * |
|
45 * Abstruct for ocr engines |
|
46 * |
|
47 * @lib ocrsrv.lib |
|
48 * @since S60 v3.1 |
|
49 */ |
|
50 class COCREngineImplBase : public MOCREngineBase, |
|
51 public CBase |
|
52 { |
|
53 public: |
|
54 |
|
55 /** |
|
56 * Symbian Two-phased constructor. |
|
57 */ |
|
58 static COCREngineImplBase* NewL(MOCREngineObserver& aObserver, const TOcrEngineEnv aEngineEnv); |
|
59 |
|
60 /** |
|
61 * Default C++ Destructor |
|
62 */ |
|
63 virtual ~COCREngineImplBase(); |
|
64 |
|
65 public: // From MOCREngineInterface |
|
66 |
|
67 /** |
|
68 * Cancel recognition operation |
|
69 * @since S60 v3.1 |
|
70 * @return None |
|
71 */ |
|
72 virtual void CancelOperation(); |
|
73 |
|
74 /** |
|
75 * Get the version of the ocrsrv component |
|
76 * @since S60 v3.1 |
|
77 * @return The version of the module |
|
78 */ |
|
79 virtual TVersion GetVersion() const; |
|
80 |
|
81 /** |
|
82 * Refresh installed language databases |
|
83 * @since S60 v3.1 |
|
84 * @return None |
|
85 */ |
|
86 virtual void RefreshInstalledLanguageL(); |
|
87 |
|
88 /** |
|
89 * Set the language for recognition |
|
90 * @since S60 v3.1 |
|
91 * @param aActiveLanguage A languages to be activated |
|
92 * @return None |
|
93 */ |
|
94 virtual void SetActiveLanguageL(const RArray<TLanguage>& aActiveLanguage); |
|
95 |
|
96 /** |
|
97 * Get the installed file directory |
|
98 * @since S60 v3.1 |
|
99 * @param aLanguages Get installed languages |
|
100 * @return None |
|
101 */ |
|
102 virtual void GetInstalledLanguage(RArray<TLanguage>& aLanguages) const; |
|
103 |
|
104 /** |
|
105 * Test if the language is supported |
|
106 * @since S60 v3.1 |
|
107 * @param aLanguage A language to be tested |
|
108 * @return ETrue if it's supported |
|
109 */ |
|
110 virtual TBool IsLanguageSupported(const TLanguage aLanguage); |
|
111 |
|
112 /** |
|
113 * Release the engine instance |
|
114 * @since S60 v3.1 |
|
115 * @return None |
|
116 */ |
|
117 void Release(); |
|
118 |
|
119 /** |
|
120 * Get adaptor object |
|
121 * @since S60 v3.1 |
|
122 * @return Pointer to the adaptor object |
|
123 */ |
|
124 inline CEngineAdaptor* GetAdaptor() const; |
|
125 |
|
126 /** |
|
127 * Test if the engine is active or not |
|
128 * @since S60 v3.1 |
|
129 * @return None |
|
130 */ |
|
131 virtual TBool IsEngineActive() const; |
|
132 |
|
133 protected: |
|
134 |
|
135 /** |
|
136 * Default Symbian 2nd phase constructor |
|
137 */ |
|
138 void ConstructL(MOCREngineObserver& aObserver, const TOcrEngineEnv aEngineEnv); |
|
139 |
|
140 private: |
|
141 |
|
142 /** |
|
143 * Reset adaptor when active language(s) is changed |
|
144 * @since S60 v3.1 |
|
145 * @param aActiveLanguage New language to be activated |
|
146 * @return None |
|
147 */ |
|
148 void ResetAdaptorL(const RArray<TLanguage>& aActiveLanguage); |
|
149 |
|
150 private: |
|
151 |
|
152 /** |
|
153 * Pointer to the adaptor instance (Own) |
|
154 */ |
|
155 CEngineAdaptor* iAdaptor; |
|
156 |
|
157 /** |
|
158 * Pointer to the engine observer (Not Own) |
|
159 */ |
|
160 MOCREngineObserver* iObserver; |
|
161 |
|
162 /** |
|
163 * Pointer to the current engine (Own) |
|
164 */ |
|
165 COCREngineList* iLanguageEngine; |
|
166 |
|
167 /** |
|
168 * File name of the current loaded Dll |
|
169 */ |
|
170 TFileName iCurrentDll; |
|
171 |
|
172 /** |
|
173 * Settings of the engine working aera |
|
174 */ |
|
175 TOcrEngineEnv iEngineEnv; |
|
176 }; |
|
177 |
|
178 /** |
|
179 * Ocr engine wrapper for recognition with layout analysis |
|
180 * |
|
181 * Abstruct for ocr engines with layout analysis |
|
182 * |
|
183 * @lib ocrsrv.lib |
|
184 * @since S60 v3.1 |
|
185 */ |
|
186 class COCREngineLayoutRecognize : public MOCREngineLayoutRecognize, |
|
187 public CBase |
|
188 { |
|
189 friend class OCREngineFactory; |
|
190 |
|
191 public: |
|
192 /** |
|
193 * Symbian Two-phased constructor. |
|
194 */ |
|
195 static COCREngineLayoutRecognize* NewL(MOCREngineObserver& aObserver, |
|
196 const TOcrEngineEnv aEngineEnv); |
|
197 |
|
198 public: // From MOCREngineWithLayout |
|
199 |
|
200 /** |
|
201 * Layout analysis method |
|
202 * @since S60 v3.1 |
|
203 * @param aBitmapHandle An image to analyzed |
|
204 * @param aSettings Setting for layout analysis |
|
205 * @return None |
|
206 */ |
|
207 virtual void LayoutAnalysisL(const TInt aBitmapHandle, const TOCRLayoutSetting aSettings); |
|
208 |
|
209 /** |
|
210 * Text recognition method |
|
211 * @since S60 v3.1 |
|
212 * @param aSetting Setting for recognition |
|
213 * @param aBlock Block Ids to be recognized |
|
214 * @return None |
|
215 */ |
|
216 virtual void RecognizeL(const TOCRRecognizeSetting aSettings, const RArray<TInt>& aBlock); |
|
217 |
|
218 /** |
|
219 * Provide base functions |
|
220 * @since S60 v3.1 |
|
221 * @return Pointer to the base engine instance |
|
222 */ |
|
223 MOCREngineBase* Base() const; |
|
224 |
|
225 private: |
|
226 |
|
227 /** |
|
228 * Default Symbian 2nd phase constructor |
|
229 */ |
|
230 void ConstructL(MOCREngineObserver& aObserver, const TOcrEngineEnv aEngineEnv); |
|
231 |
|
232 protected: |
|
233 |
|
234 /** |
|
235 * Default C++ Destructor |
|
236 */ |
|
237 virtual ~COCREngineLayoutRecognize(); |
|
238 |
|
239 private: |
|
240 |
|
241 /** |
|
242 * Pointer to the engine base instance (Own) |
|
243 */ |
|
244 COCREngineImplBase* iBase; |
|
245 |
|
246 /** |
|
247 * Pointer to the adaptor instance (Not Own) |
|
248 */ |
|
249 CEngineAdaptor* iAdaptor; |
|
250 }; |
|
251 |
|
252 /** |
|
253 * Ocr engine wrapper for recognition with block recognition |
|
254 * |
|
255 * Abstruct for ocr engines with block recognition |
|
256 * |
|
257 * @lib ocrsrv.lib |
|
258 * @since S60 v3.1 |
|
259 */ |
|
260 class COCREngineRecognizeBlock : public MOCREngineRecognizeBlock, |
|
261 public CBase |
|
262 { |
|
263 friend class OCREngineFactory; |
|
264 |
|
265 public: |
|
266 /** |
|
267 * Description: Two-phased constructor. |
|
268 */ |
|
269 static COCREngineRecognizeBlock* NewL(MOCREngineObserver& aObserver, |
|
270 const TOcrEngineEnv aEngineEnv); |
|
271 |
|
272 public: // From MOCREngineWithoutLayout |
|
273 |
|
274 /** |
|
275 * Recognize block without layout analysis |
|
276 * @since S60 v3.1 |
|
277 * @param aBitmapHandle An image to analyzed |
|
278 * @param aLayoutInfo Layout information |
|
279 * @return None |
|
280 */ |
|
281 virtual void RecognizeBlockL(const TInt aBitmapHandle, |
|
282 const TOCRLayoutBlockInfo aLayoutInfo); |
|
283 |
|
284 /** |
|
285 * Recognize special region |
|
286 * @since S60 v3.1 |
|
287 * @param aBitmapHandle An image to analyzed |
|
288 * @param aRegionInfo Region information |
|
289 * @return None |
|
290 */ |
|
291 virtual void RecognizeSpecialRegionL(const TInt aBitmapHandle, |
|
292 const TRegionInfo aRegionInfo); |
|
293 |
|
294 /** |
|
295 * Provide base functions |
|
296 * @since S60 v3.1 |
|
297 * @return Pointer to the base engine instance |
|
298 */ |
|
299 MOCREngineBase* Base() const; |
|
300 |
|
301 private: |
|
302 |
|
303 /** |
|
304 * Default Symbian 2nd phase constructor |
|
305 */ |
|
306 void ConstructL(MOCREngineObserver& aObserver, const TOcrEngineEnv aEngineEnv); |
|
307 |
|
308 /** |
|
309 * Check the validity of the given rect |
|
310 * If the range is invalid, a leave will be raised with KErrArgument |
|
311 * @since S60 v3.1 |
|
312 * @param aBitmapHandle A bitmap handle |
|
313 * @param aRange A given range |
|
314 * @return None |
|
315 */ |
|
316 void CheckRangeL(const TInt aBitmapHandle, const TRect aRange); |
|
317 |
|
318 protected: |
|
319 |
|
320 /** |
|
321 * Default C++ Destructor |
|
322 */ |
|
323 virtual ~COCREngineRecognizeBlock(); |
|
324 |
|
325 private: |
|
326 |
|
327 /** |
|
328 * Pointer to the engine base instance (Own) |
|
329 */ |
|
330 COCREngineImplBase* iBase; |
|
331 |
|
332 /** |
|
333 * Pointer to the adaptor instance (Not Own) |
|
334 */ |
|
335 CEngineAdaptor* iAdaptor; |
|
336 }; |
|
337 |
|
338 #include "ocrengine.inl" |
|
339 |
|
340 #endif // OCRENGINE_H |
|
341 |
|
342 // End of File |