File indexing completed on 2024-05-12 15:55:07
0001 /*************************************************************************** 0002 kadmosocr.h - Kadmos cpp interface 0003 ------------------- 0004 begin : Fri Jun 30 2000 0005 0006 (c) 2002 re Recognition AG Hafenstrasse 50b CH-8280 Kreuzlingen 0007 Switzerland Phone: +41 (0)71 6780000 Fax: +41 (0)71 6780099 0008 Website: www.reRecognition.com E-mail: info@reRecognition.com 0009 0010 Author: Tamas Nagy (nagy@rerecognition.com) 0011 ***************************************************************************/ 0012 0013 /*************************************************************************** 0014 * * 0015 * This file may be distributed and/or modified under the terms of the * 0016 * GNU General Public License version 2 as published by the Free Software * 0017 * Foundation and appearing in the file COPYING included in the * 0018 * packaging of this file. * 0019 * 0020 * As a special exception, permission is given to link this program * 0021 * with any version of the KADMOS ocr/icr engine of reRecognition GmbH, * 0022 * Kreuzlingen and distribute the resulting executable without * 0023 * including the source code for KADMOS in the source distribution. * 0024 * 0025 * As a special exception, permission is given to link this program * 0026 * with any edition of Qt, and distribute the resulting executable, * 0027 * without including the source code for Qt in the source distribution. * 0028 * * 0029 ***************************************************************************/ 0030 0031 #ifndef __KADMOS_OCR_ 0032 #define __KADMOS_OCR_ 0033 0034 #include <qobject.h> 0035 #include <qstring.h> 0036 0037 #ifdef HAVE_KADMOS 0038 /* class declarations */ 0039 class QImage; 0040 class QPixmap; 0041 class QColor; 0042 class QStringList; 0043 class QRect; 0044 0045 class ocrWord; 0046 class ocrWordList; 0047 0048 namespace Kadmos 0049 { 0050 0051 /* include files */ 0052 0053 #include "kadmos.h" 0054 #include <qptrlist.h> 0055 0056 /* ---------------------------------------- REP ---------------------------------------- */ 0057 //! Maximum number of lines in a paragraph 0058 const int LINE_MAX_LEN = 100; 0059 const int GRID_MAX_LEN = 50; //!< Maximum number of grid elements in a line 0060 const int GRAPH_MAX_LEN = 500; //!< Maximum number of graph elements in a line 0061 const int CHAR_MAX_LEN = 500; //!< Maximum number of characters in a line 0062 0063 /* Error handling */ 0064 const char CPP_ERROR[] = "Kadmos CPP interface error"; 0065 0066 /* ==== CRep ========================================= */ 0067 class CRep : public QObject 0068 { 0069 Q_OBJECT 0070 public: 0071 CRep(); 0072 virtual ~CRep(); 0073 0074 RepResult *getRepResult(int line = 0); 0075 RelGraph *getGraphKnode(int line, int offset = 0); 0076 RelResult *getRelResult(int line, Kadmos::RelGraph *graph, int alternative = 0); 0077 0078 /** 0079 @param ClassifierFilename is a name of a classifier file (*.rec) 0080 */ 0081 KADMOS_ERROR Init(const char *ClassifierFile); 0082 0083 virtual void run(); 0084 virtual bool finished() 0085 { 0086 return true; 0087 } 0088 // KADMOS_ERROR Recognize(); 0089 KADMOS_ERROR End(); 0090 0091 /** 0092 @param Image is an image object 0093 */ 0094 KADMOS_ERROR SetImage(QImage *Image); 0095 KADMOS_ERROR SetImage(const QString); 0096 int GetMaxLine(); 0097 0098 ocrWordList getLineWords(int line); 0099 0100 const char *RepTextLine(int Line, unsigned char RejectLevel = 128, 0101 int RejectChar = '~', long Format = TEXT_FORMAT_ANSI); 0102 0103 void analyseLine(int, QPixmap *); 0104 /** Enable/disable noise reduction 0105 @param TRUE(enable)/FALSE(disable) noise reduction 0106 */ 0107 void SetNoiseReduction(bool bNoiseReduction); 0108 0109 /** Enable/disable scaling (size normalization) 0110 @param TRUE(enable)/FALSE(disable) scaling (size normalization) 0111 */ 0112 void SetScaling(bool bScaling); 0113 0114 /* draw graphic visualiser into the pixmap pointed to */ 0115 virtual void drawLineBox(QPixmap *, const QRect &); 0116 virtual void drawCharBox(QPixmap *, const QRect &); 0117 virtual void drawBox(QPixmap *, const QRect &, const QColor &); 0118 0119 int nextBestWord(int line, int knode, QString &theWord, QRect &brect); 0120 0121 /* Error text in QString */ 0122 QString getErrorText() const; 0123 bool kadmosError(); 0124 private: 0125 void partStrings(int line, int graphKnode, QString soFar); 0126 void CheckError(); 0127 0128 RepData m_RepData; 0129 KADMOS_ERROR m_Error; 0130 char m_Line[2 * CHAR_MAX_LEN]; 0131 int m_currLine; 0132 QStringList m_parts; 0133 QString m_theWord; 0134 int m_recurse; 0135 0136 QChar m_undetectChar; 0137 }; 0138 0139 } /* End of Kadmos namespace */ 0140 0141 #endif /* HAVE KADMOS */ 0142 0143 #endif /* header tagging */