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