1.1 --- a/epoc32/include/mw/ocrcommon.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/mw/ocrcommon.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,361 @@
1.4 -ocrcommon.h
1.5 +/*
1.6 +* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description: APIs of the OCR(Optical Character Recognition), current engine
1.19 +* can recognize 24 bit colored image and 8 bit gray scale image
1.20 +* in BMP format.
1.21 +*
1.22 +*
1.23 +*/
1.24 +
1.25 +
1.26 +#ifndef OCRCOMMON_H
1.27 +#define OCRCOMMON_H
1.28 +
1.29 +// INCLUDE FILES
1.30 +#include <e32std.h>
1.31 +#include <e32def.h>
1.32 +#include <e32base.h>
1.33 +
1.34 +/**
1.35 +* Bad image or unsupported format
1.36 +*/
1.37 +const TInt KErrOcrBadImage (-1001);
1.38 +
1.39 +/**
1.40 +* Unsupported language
1.41 +*/
1.42 +const TInt KErrOcrBadLanguage (-1002);
1.43 +
1.44 +/**
1.45 +* Bad layout region
1.46 +*/
1.47 +const TInt KErrOcrBadRegion (-1003);
1.48 +
1.49 +/**
1.50 +* Not set any language
1.51 +*/
1.52 +const TInt KErrOcrNotSetLanguage (-1004);
1.53 +
1.54 +/**
1.55 +* Not set any language packages
1.56 +*/
1.57 +const TInt KErrOcrBadDictFile (-1005);
1.58 +
1.59 +/** Type of the text layouts
1.60 +*/
1.61 +enum TOcrLayoutType
1.62 + {
1.63 + /** Texts in the block is horizontal
1.64 + */
1.65 + EOcrLayoutTypeH,
1.66 +
1.67 + /** Texts in the block is vertical
1.68 + */
1.69 + EOcrLayoutTypeV
1.70 + };
1.71 +
1.72 +/** Type of the text
1.73 +*/
1.74 +enum TOcrTextType
1.75 + {
1.76 + /** when the image or recognition area has multi-line format
1.77 + */
1.78 + EOcrTextMultiLine,
1.79 +
1.80 + /** when the image or recognition area has single-line format
1.81 + */
1.82 + EOcrTextSingleLine
1.83 + };
1.84 +
1.85 +/** Type of the text background
1.86 +*/
1.87 +enum TOcrBackgroundType
1.88 + {
1.89 + /** light character with light background
1.90 + */
1.91 + EOcrBackgroundLight,
1.92 +
1.93 + /** dark character with dark background
1.94 + */
1.95 + EOcrBackgroundDark,
1.96 +
1.97 + /** un-suspected background
1.98 + */
1.99 + EOcrBackgroundUnknown
1.100 + };
1.101 +
1.102 +/**
1.103 + * OCR (Optical Character Recognition) Text Line Information
1.104 + *
1.105 + * This class holds the information from the OCR engine after the recognition
1.106 + * Note that all memory ownership belongs to the OCR engine, so do not need to
1.107 + * either allocate memory for it or push it to the CleanupStack. Engine will
1.108 + * release the memory whenever necessary
1.109 + *
1.110 + * @lib ocrsrv.lib
1.111 + * @since S60 3.1
1.112 + */
1.113 +class TOCRTextLineInfo
1.114 + {
1.115 +public:
1.116 +
1.117 + /**
1.118 + * Text buffer for the line. Note that after layout analysis, this is NULL
1.119 + * and the buffer will be filled after recognition (Not Own)
1.120 + */
1.121 + HBufC16* iText;
1.122 +
1.123 + /**
1.124 + * Region coordinate to be processed
1.125 + */
1.126 + TRect iRect;
1.127 +
1.128 + /**
1.129 + * Array of the character rects. (Not Own)
1.130 + */
1.131 + TRect* iCharRect;
1.132 +
1.133 + /**
1.134 + * Number of characters
1.135 + */
1.136 + TInt iCharCount;
1.137 + };
1.138 +
1.139 +/**
1.140 + * OCR (Optical Character Recognition) Text Line Information
1.141 + *
1.142 + * This class holds the information from the layout analysis, the engine
1.143 + * will allocate the memory of TOCRBlockInfo array, and pass the ownership
1.144 + * to you while you can remove it by delete[]
1.145 + *
1.146 + * @lib ocrsrv.lib
1.147 + * @since S60 3.1
1.148 + */
1.149 +class TOCRBlockInfo
1.150 + {
1.151 +public:
1.152 +
1.153 + /**
1.154 + * Region coordinate to be processed
1.155 + */
1.156 + TRect iRect;
1.157 +
1.158 + /**
1.159 + * Layout Type (Horizontal or Vertical)
1.160 + */
1.161 + TOcrLayoutType iType;
1.162 +
1.163 + /**
1.164 + * Id of the block
1.165 + */
1.166 + TInt iBlockId;
1.167 + };
1.168 +
1.169 +/**
1.170 + * OCR (Optical Character Recognition) Text Block Information
1.171 + *
1.172 + * This class holds the information from the OCR engine after the recognition
1.173 + * Note that all memory ownership belongs to the OCR engine, so do not need to
1.174 + * either allocate memory for it or push it to the CleanupStack. Engine will
1.175 + * release the memory whenever necessary
1.176 + *
1.177 + * @lib ocrsrv.lib
1.178 + * @since S60 3.1
1.179 + */
1.180 +class TOCRTextRgnInfo
1.181 + {
1.182 +public:
1.183 +
1.184 + /**
1.185 + * Region coordinate to be processed
1.186 + */
1.187 + TRect iRect;
1.188 +
1.189 + /**
1.190 + * Layout Type (Horizontal or Vertical)
1.191 + */
1.192 + TOcrLayoutType iType;
1.193 +
1.194 + /**
1.195 + * Id of the block
1.196 + */
1.197 + TInt iBlockId;
1.198 +
1.199 + /**
1.200 + * Text line Information (Not Own)
1.201 + */
1.202 + TOCRTextLineInfo* iLines;
1.203 +
1.204 + /**
1.205 + * Number of Lines
1.206 + */
1.207 + TInt iLineCount;
1.208 + };
1.209 +
1.210 +/**
1.211 + * OCR (Optical Character Recognition) Setting for Layout Analysis
1.212 + *
1.213 + * The setting for layout analysis
1.214 + *
1.215 + * @lib ocrsrv.lib
1.216 + * @since S60 3.1
1.217 + */
1.218 +class TOCRLayoutSetting
1.219 + {
1.220 +public:
1.221 +
1.222 + /**
1.223 + * Image brightness
1.224 + */
1.225 + enum TOcrBrightness
1.226 + {
1.227 + ENormal, ///< brightness is normal
1.228 + ELight, ///< brightness is light
1.229 + EDark ///< brightness is dark
1.230 + };
1.231 +
1.232 + /**
1.233 + * Whether skew adjustment enabled, in most cases
1.234 + * this flag shall be always on; But if images are in
1.235 + * very good contition, this flag can be off to increase
1.236 + * the recognition speed
1.237 + */
1.238 + TBool iSkew;
1.239 +
1.240 + /**
1.241 + * Brightness for text background
1.242 + */
1.243 + TOcrBrightness iBrightness;
1.244 + };
1.245 +
1.246 +/**
1.247 + * OCR (Optical Character Recognition) Setting for Recognize (Reserved)
1.248 + *
1.249 + * The setting for recognition
1.250 + *
1.251 + * @lib ocrsrv.lib
1.252 + * @since S60 3.1
1.253 + */
1.254 +class TOCRRecognizeSetting
1.255 + {
1.256 +public:
1.257 +
1.258 + /**
1.259 + * Reserved for future use
1.260 + */
1.261 + TAny* iAny;
1.262 + };
1.263 +
1.264 +/**
1.265 + * OCR (Optical Character Recognition) Block Information for Recognizing Blocks
1.266 + *
1.267 + * This class is for recognizing blocks. @see MOCREngineRecognizeBlock::RecognizeBlockL
1.268 + *
1.269 + * @lib ocrsrv.lib
1.270 + * @since S60 3.1
1.271 + */
1.272 +class TOCRLayoutBlockInfo
1.273 + {
1.274 +public:
1.275 +
1.276 + /**
1.277 + * Region coordinate to be processed
1.278 + */
1.279 + TRect iRect;
1.280 +
1.281 + /**
1.282 + * Layout Type (Horizontal or Vertical)
1.283 + */
1.284 + TOcrLayoutType iLayout;
1.285 +
1.286 + /**
1.287 + * Text Type (Multi or Single line)
1.288 + */
1.289 + TOcrTextType iText;
1.290 +
1.291 + /**
1.292 + * Brightness for text background
1.293 + */
1.294 + TOcrBackgroundType iBackgroundColor;
1.295 + };
1.296 +
1.297 +/**
1.298 + * OCR (Optical Character Recognition) Block Information for Recognizing Blocks
1.299 + *
1.300 + * This class is for recognizing blocks. @see MOCREngineRecognizeBlock::RecognizeSpecialRegionL
1.301 + *
1.302 + * @lib ocrsrv.lib
1.303 + * @since S60 3.1
1.304 + */
1.305 +class TRegionInfo
1.306 + {
1.307 +public:
1.308 +
1.309 + /**
1.310 + * Content Type
1.311 + */
1.312 + enum TOcrRegionType
1.313 + {
1.314 + EEmailAddress, ///< E-mail address
1.315 + ETelephoneNumber, ///< telephone number
1.316 + EWWWAddress ///< website address
1.317 + };
1.318 +
1.319 +public:
1.320 + /**
1.321 + * Region coordinate to be processed
1.322 + */
1.323 + TRect iRect;
1.324 +
1.325 + /**
1.326 + * Brightness for text background
1.327 + */
1.328 + TOcrBackgroundType iBackgroundColor;
1.329 +
1.330 + /**
1.331 + * Content Type
1.332 + */
1.333 + TOcrRegionType iType;
1.334 + };
1.335 +
1.336 +/**
1.337 + * OCR (Optical Character Recognition) Engine Environment Settings
1.338 + *
1.339 + * This class is for setting the thread priority and the maximum heap
1.340 + * allocation for the ocr engine
1.341 + *
1.342 + * @lib ocrsrv.lib
1.343 + * @since S60 3.1
1.344 + */
1.345 +class TOcrEngineEnv
1.346 + {
1.347 +public:
1.348 + /**
1.349 + * Thread priority. The Engine Factory will create a child thread
1.350 + * for the OCR process, EPriorityLess is recommended for most cases
1.351 + */
1.352 + TThreadPriority iPriority;
1.353 +
1.354 + /**
1.355 + * The maximum heap size for the OCR process, must be larger than
1.356 + * KMinHeapGrowBy x 1200 to do recognition for 1600x1200 images. If
1.357 + * this value is lower(equal) than KMinHeapGrowBy*1000, a leave will
1.358 + * happen in CreateOCREngineL with KErrArgument
1.359 + */
1.360 + TInt iMaxHeapSize;
1.361 + };
1.362 +
1.363 +#endif // OCRCOMMON_H
1.364 +
1.365 +// End of file