williamr@2: /* williamr@2: * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0"" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: APIs of the OCR(Optical Character Recognition), current engine williamr@2: * can recognize 24 bit colored image and 8 bit gray scale image williamr@2: * in BMP format. williamr@2: * williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef OCRCOMMON_H williamr@2: #define OCRCOMMON_H williamr@2: williamr@2: // INCLUDE FILES williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: /** williamr@2: * Bad image or unsupported format williamr@2: */ williamr@2: const TInt KErrOcrBadImage (-1001); williamr@2: williamr@2: /** williamr@2: * Unsupported language williamr@2: */ williamr@2: const TInt KErrOcrBadLanguage (-1002); williamr@2: williamr@2: /** williamr@2: * Bad layout region williamr@2: */ williamr@2: const TInt KErrOcrBadRegion (-1003); williamr@2: williamr@2: /** williamr@2: * Not set any language williamr@2: */ williamr@2: const TInt KErrOcrNotSetLanguage (-1004); williamr@2: williamr@2: /** williamr@2: * Not set any language packages williamr@2: */ williamr@2: const TInt KErrOcrBadDictFile (-1005); williamr@2: williamr@2: /** Type of the text layouts williamr@2: */ williamr@2: enum TOcrLayoutType williamr@2: { williamr@2: /** Texts in the block is horizontal williamr@2: */ williamr@2: EOcrLayoutTypeH, williamr@2: williamr@2: /** Texts in the block is vertical williamr@2: */ williamr@2: EOcrLayoutTypeV williamr@2: }; williamr@2: williamr@2: /** Type of the text williamr@2: */ williamr@2: enum TOcrTextType williamr@2: { williamr@2: /** when the image or recognition area has multi-line format williamr@2: */ williamr@2: EOcrTextMultiLine, williamr@2: williamr@2: /** when the image or recognition area has single-line format williamr@2: */ williamr@2: EOcrTextSingleLine williamr@2: }; williamr@2: williamr@2: /** Type of the text background williamr@2: */ williamr@2: enum TOcrBackgroundType williamr@2: { williamr@2: /** light character with light background williamr@2: */ williamr@2: EOcrBackgroundLight, williamr@2: williamr@2: /** dark character with dark background williamr@2: */ williamr@2: EOcrBackgroundDark, williamr@2: williamr@2: /** un-suspected background williamr@2: */ williamr@2: EOcrBackgroundUnknown williamr@2: }; williamr@2: williamr@2: /** williamr@2: * OCR (Optical Character Recognition) Text Line Information williamr@2: * williamr@2: * This class holds the information from the OCR engine after the recognition williamr@2: * Note that all memory ownership belongs to the OCR engine, so do not need to williamr@2: * either allocate memory for it or push it to the CleanupStack. Engine will williamr@2: * release the memory whenever necessary williamr@2: * williamr@2: * @lib ocrsrv.lib williamr@2: * @since S60 3.1 williamr@2: */ williamr@2: class TOCRTextLineInfo williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Text buffer for the line. Note that after layout analysis, this is NULL williamr@2: * and the buffer will be filled after recognition (Not Own) williamr@2: */ williamr@2: HBufC16* iText; williamr@2: williamr@2: /** williamr@2: * Region coordinate to be processed williamr@2: */ williamr@2: TRect iRect; williamr@2: williamr@2: /** williamr@2: * Array of the character rects. (Not Own) williamr@2: */ williamr@2: TRect* iCharRect; williamr@2: williamr@2: /** williamr@2: * Number of characters williamr@2: */ williamr@2: TInt iCharCount; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * OCR (Optical Character Recognition) Text Line Information williamr@2: * williamr@2: * This class holds the information from the layout analysis, the engine williamr@2: * will allocate the memory of TOCRBlockInfo array, and pass the ownership williamr@2: * to you while you can remove it by delete[] williamr@2: * williamr@2: * @lib ocrsrv.lib williamr@2: * @since S60 3.1 williamr@2: */ williamr@2: class TOCRBlockInfo williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Region coordinate to be processed williamr@2: */ williamr@2: TRect iRect; williamr@2: williamr@2: /** williamr@2: * Layout Type (Horizontal or Vertical) williamr@2: */ williamr@2: TOcrLayoutType iType; williamr@2: williamr@2: /** williamr@2: * Id of the block williamr@2: */ williamr@2: TInt iBlockId; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * OCR (Optical Character Recognition) Text Block Information williamr@2: * williamr@2: * This class holds the information from the OCR engine after the recognition williamr@2: * Note that all memory ownership belongs to the OCR engine, so do not need to williamr@2: * either allocate memory for it or push it to the CleanupStack. Engine will williamr@2: * release the memory whenever necessary williamr@2: * williamr@2: * @lib ocrsrv.lib williamr@2: * @since S60 3.1 williamr@2: */ williamr@2: class TOCRTextRgnInfo williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Region coordinate to be processed williamr@2: */ williamr@2: TRect iRect; williamr@2: williamr@2: /** williamr@2: * Layout Type (Horizontal or Vertical) williamr@2: */ williamr@2: TOcrLayoutType iType; williamr@2: williamr@2: /** williamr@2: * Id of the block williamr@2: */ williamr@2: TInt iBlockId; williamr@2: williamr@2: /** williamr@2: * Text line Information (Not Own) williamr@2: */ williamr@2: TOCRTextLineInfo* iLines; williamr@2: williamr@2: /** williamr@2: * Number of Lines williamr@2: */ williamr@2: TInt iLineCount; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * OCR (Optical Character Recognition) Setting for Layout Analysis williamr@2: * williamr@2: * The setting for layout analysis williamr@2: * williamr@2: * @lib ocrsrv.lib williamr@2: * @since S60 3.1 williamr@2: */ williamr@2: class TOCRLayoutSetting williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Image brightness williamr@2: */ williamr@2: enum TOcrBrightness williamr@2: { williamr@2: ENormal, ///< brightness is normal williamr@2: ELight, ///< brightness is light williamr@2: EDark ///< brightness is dark williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Whether skew adjustment enabled, in most cases williamr@2: * this flag shall be always on; But if images are in williamr@2: * very good contition, this flag can be off to increase williamr@2: * the recognition speed williamr@2: */ williamr@2: TBool iSkew; williamr@2: williamr@2: /** williamr@2: * Brightness for text background williamr@2: */ williamr@2: TOcrBrightness iBrightness; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * OCR (Optical Character Recognition) Setting for Recognize (Reserved) williamr@2: * williamr@2: * The setting for recognition williamr@2: * williamr@2: * @lib ocrsrv.lib williamr@2: * @since S60 3.1 williamr@2: */ williamr@2: class TOCRRecognizeSetting williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Reserved for future use williamr@2: */ williamr@2: TAny* iAny; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * OCR (Optical Character Recognition) Block Information for Recognizing Blocks williamr@2: * williamr@2: * This class is for recognizing blocks. @see MOCREngineRecognizeBlock::RecognizeBlockL williamr@2: * williamr@2: * @lib ocrsrv.lib williamr@2: * @since S60 3.1 williamr@2: */ williamr@2: class TOCRLayoutBlockInfo williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Region coordinate to be processed williamr@2: */ williamr@2: TRect iRect; williamr@2: williamr@2: /** williamr@2: * Layout Type (Horizontal or Vertical) williamr@2: */ williamr@2: TOcrLayoutType iLayout; williamr@2: williamr@2: /** williamr@2: * Text Type (Multi or Single line) williamr@2: */ williamr@2: TOcrTextType iText; williamr@2: williamr@2: /** williamr@2: * Brightness for text background williamr@2: */ williamr@2: TOcrBackgroundType iBackgroundColor; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * OCR (Optical Character Recognition) Block Information for Recognizing Blocks williamr@2: * williamr@2: * This class is for recognizing blocks. @see MOCREngineRecognizeBlock::RecognizeSpecialRegionL williamr@2: * williamr@2: * @lib ocrsrv.lib williamr@2: * @since S60 3.1 williamr@2: */ williamr@2: class TRegionInfo williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Content Type williamr@2: */ williamr@2: enum TOcrRegionType williamr@2: { williamr@2: EEmailAddress, ///< E-mail address williamr@2: ETelephoneNumber, ///< telephone number williamr@2: EWWWAddress ///< website address williamr@2: }; williamr@2: williamr@2: public: williamr@2: /** williamr@2: * Region coordinate to be processed williamr@2: */ williamr@2: TRect iRect; williamr@2: williamr@2: /** williamr@2: * Brightness for text background williamr@2: */ williamr@2: TOcrBackgroundType iBackgroundColor; williamr@2: williamr@2: /** williamr@2: * Content Type williamr@2: */ williamr@2: TOcrRegionType iType; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * OCR (Optical Character Recognition) Engine Environment Settings williamr@2: * williamr@2: * This class is for setting the thread priority and the maximum heap williamr@2: * allocation for the ocr engine williamr@2: * williamr@2: * @lib ocrsrv.lib williamr@2: * @since S60 3.1 williamr@2: */ williamr@2: class TOcrEngineEnv williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Thread priority. The Engine Factory will create a child thread williamr@2: * for the OCR process, EPriorityLess is recommended for most cases williamr@2: */ williamr@2: TThreadPriority iPriority; williamr@2: williamr@2: /** williamr@2: * The maximum heap size for the OCR process, must be larger than williamr@2: * KMinHeapGrowBy x 1200 to do recognition for 1600x1200 images. If williamr@2: * this value is lower(equal) than KMinHeapGrowBy*1000, a leave will williamr@2: * happen in CreateOCREngineL with KErrArgument williamr@2: */ williamr@2: TInt iMaxHeapSize; williamr@2: }; williamr@2: williamr@2: #endif // OCRCOMMON_H williamr@2: williamr@2: // End of file