aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/3rdparty/lipi-toolkit/src/reco/wordrec/boxfld/BoxFieldRecognizer.h
blob: d1ccb49688f31319eb68e532f3968dfe844f2246 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*****************************************************************************************
* Copyright (c) 2006 Hewlett-Packard Development Company, L.P.
* Permission is hereby granted, free of charge, to any person obtaining a copy of 
* this software and associated documentation files (the "Software"), to deal in 
* the Software without restriction, including without limitation the rights to use, 
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the 
* Software, and to permit persons to whom the Software is furnished to do so, 
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
* THE SOFTWARE. 
******************************************************************************/

/************************************************************************
 * SVN MACROS
 *
 * $LastChangedDate: 2008-07-18 15:00:39 +0530 (Fri, 18 Jul 2008) $
 * $Revision: 561 $
 * $Author: sharmnid $
 *
 ************************************************************************/
/************************************************************************
 * FILE DESCR: Definitions for DP word recognizer 
 *
 * CONTENTS:   
 *
 * AUTHOR:     Deepu V.
 *
 * DATE:       August 17, 2005
 * CHANGE HISTORY:
 * Author		Date			Description of 
 ************************************************************************/

#ifndef __BOXFIELDRECOGNIZER_H
#define __BOXFIELDRECOGNIZER_H

#include "LTKWordRecognizer.h"
#include "LTKLoggerUtil.h"
#include "LTKWordRecoResult.h"
#include "LTKShapeRecoResult.h"

class LTKShapeRecognizer;
class LTKWordRecoConfig;
class LTKOSUtil;

typedef int (*FN_PTR_CREATESHAPERECOGNIZER)(const LTKControlInfo&,  
											LTKShapeRecognizer**);

typedef int (*FN_PTR_DELETESHAPERECOGNIZER)(LTKShapeRecognizer*);


/**
* @class BoxedFieldWordRecognizer
* <p> This class contains the implementation of the Boxed Field
* word recognizer</p>
*/

class BoxedFieldRecognizer : public LTKWordRecognizer  
{
private:

	/** Boxed Field Recognizer config file name */
	string m_boxedConfigFile;

	/** Lipi root */
	string m_lipiRoot;

	/** Isolated shape recognizer project used for recognizing each box */
	string m_boxedShapeProject;

	/** Profile for the shape recognition project */
	string m_boxedShapeProfile;

	/**
	 * @name shape recognizer related
	 */

	// @{
	LTKShapeRecognizer *m_shapeRecognizer;	// shape recognizer

	/** Number of results from shape recognizer */
	int m_numShapeRecoResults;

	/** The confidence parameter input to shape recognizer */
	float m_shapeRecoMinConfidence; 

	/** Temporary trace group that holds the strokes for recognition */
	LTKTraceGroup m_boxedChar;

	string m_logFile;

	LTKLogger::EDebugLevel m_logLevel;

	string m_toolkitVersion;

    LTKOSUtil* m_OSUtilPtr;
	// @}

	/**
	 * @name Shape recognizer loading
	 */

	/** Factory method to create the shape recognizer */
	FN_PTR_CREATESHAPERECOGNIZER m_module_createShapeRecognizer;

	/** Factory method to delete the shape recognizer */
	FN_PTR_DELETESHAPERECOGNIZER m_module_deleteShapeRecognizer;
	
	//void * m_hAlgoDLLHandle;  //handle to the wordrecognition algorithm

	/**
	 * @name state of recognizer
	 */
	// @{

	/** Number of characters processed so far  */
	int m_numCharsProcessed;	                 

	/** Number of traces processed so far */
	int m_numTracesProcessed;

	/** maintains decoded recognition results after each trace, upto max style length */
	vector <LTKWordRecoResult> m_decodedResults;  
	
	// @}

public:
	/**
	 * @name Constructors and Destructor
	 */
	// @{

    
	/**
	 * Parameterized Constructor
	 */

	 BoxedFieldRecognizer(const LTKControlInfo& controlInfo);
	/**
	 *  Destructor 
	 */

   virtual ~BoxedFieldRecognizer();
	 // @}

  
   /**
	* This method is called from recognition context whenever new traces
	* are added to it.  The Recognizer need to process the new traces 
	* in this methods and updates the internal state.
	* @param rc The recognition context for the current recognition
	*/
     int processInk (LTKRecognitionContext& rc);

   /**
	* This function notifies the recognizer that end of current ink is 
	* the end of a logic segment.  This information could be used in 
	* constraining the recognizer choices
	*/
     void endRecoUnit () ;
     
   /**
	* This is the recognize call. In case of trace by trace recognition
	* The results of the recognition is set on the Recognition context 
	* object.  
	* @param rc The recognition context for the current recognition
	*/
     int recognize (LTKRecognitionContext& rc) ;

   /**
	* This method unloads all the training data
	* To re-initialize the recognizer call the
	* API initialize again
	*/
	int unloadModelData(); 
	
 
   /**
	* This method reset the recognizer.  
	* @param resetParam This parameter could specify what to reset
	*/
     int reset (int resetParam = 0) ;
	// @}
private:

	/**
     *  performs the recognition of the new strokes added to recognition context
     * @param rc The recognitino context
     */

	int recognizeTraces(LTKRecognitionContext& rc);

	/**
     * Erase the state information of the recognizer
     */
    void clearRecognizerState();

	/**
     * This function tries to update the 
     * shape recognition choices with new shape recognition results
     * @param results New results for updating the results
     */
	int updateRecognitionResults(const vector<LTKShapeRecoResult>& results, LTKRecognitionContext& rc);

   /**
    * This function loads and create a shape recognizer
	* from DLL/shared object
	**/
	int createShapeRecognizer(const string& strProjectName, const string& strProfileName,LTKShapeRecognizer** outShapeRecPtr);
    
   /**
    * This function loads functions pointers
	* from the shape recognizer DLL/SO
    **/
	int mapShapeAlgoModuleFunctions();


	int readClassifierConfig();

};
#endif //#ifndef __BOXFIELDRECOGNIZER_H