aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecognizer.h
blob: 7938b1f43ee9505040e398a7c55e68ff2d6739fe (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
229
230
231
232
233
234
235
236
237
238
239
240
241
/*****************************************************************************************
* Copyright (c) 2007 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-11-14 17:34:35 +0530 (Fri, 14 Nov 2008) $
 * $Revision: 702 $
 * $Author: royva $
 *
 ************************************************************************/
/************************************************************************
 * FILE DESCR: Definition of LTKShapeRecognizer which would be used as a place holder in LTKShapeRecognizer 
 *			   for anyone of the implemented shape recognizer like PCAShapeRecognizer which is derived from this class
 *
 * CONTENTS:   
 *
 * AUTHOR:     Balaji R.
 *
 * DATE:       December 23, 2004
 * CHANGE HISTORY:
 * Author		Date			Description of change
 ************************************************************************/

#ifndef __LTKShapeRecognizer_H
#define __LTKShapeRecognizer_H

#include "LTKInc.h"

#include "LTKTraceGroup.h"

#include "LTKShapeRecoResult.h"

#include "LTKScreenContext.h"

#include "LTKCaptureDevice.h"

#include "LTKShapeRecoConfig.h"

#include "LTKMacros.h"


#include "LTKShapeFeatureMacros.h"
/**
 * @class LTKShapeRecognizer
 * <p> This is an abstract class. This class will have to be derived by each of the shape recognizers
 * which are to be used for recognition. This class has some pure virtual functions which are
 * to be implemented by the derived class.</p>
 */

class LTKShapeRecognizer
{

protected:

	const string m_shapeRecognizerName;	//	name of the shape recognizer class deriving from the LTKShapeRecognizer class
	bool m_cancelRecognition;

public:

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


	/**
	 * Default Constructor.
	 */

	LTKShapeRecognizer();

	/**
	 * Initialization Constructor. Initialzes the member m_shapeRecognizerName
	 */

	LTKShapeRecognizer(const string& shapeRecognizerName);

	/**
	 * Pure Virtual Destructor
	 */

	virtual ~LTKShapeRecognizer() = 0;

	//@}

	/**
	 * @name Methods
	 */

	//@{

	
	/**
	* This is a pure virtual method to be implemented by the derived class.This method loads the  
	* the Training Data of the derived class.
	*/

	virtual int loadModelData() =  0;

	/**
	* This is a pure virtual method to be implemented by the derived class.This method calls 
	* the recognize method of the derived shape recognizer.
	*
	* @param traceGroupObj The co-ordinates of the shape which is to be recognized
	* @param screenContext Contains information about the input field like whether it is boxed input
	*                 or continuous writing
	* @param captureDevice Contains information about the device like its sampling rate
	* @param shapeSubSet A subset of the entire shape space which is to be used for 
	*                        recognizing the input shape.
	* @param confThreshold A threshold on confidence value of the recognized shape. This is
	*                      used as Rejection Criteria
	* @param numOfChoices Number of top choices to be returned in the result structure
	* @param results The result of recognition
	*/

	virtual int recognize(const LTKTraceGroup& traceGroup,
			const LTKScreenContext& screenContext,
			const vector<int>& subSetOfClasses,
			float confThreshold,
			int  numChoices,
			vector<LTKShapeRecoResult>& resultVector) = 0;

	virtual int recognize(const vector<LTKShapeFeaturePtr>& shapeFeatureVector,
			const vector<int>& subSetOfClasses,
			float confThreshold,
			int  numChoices,
			vector<LTKShapeRecoResult>& resultVector) = 0;

	void requestCancelRecognition() { m_cancelRecognition = true; }
	
	/**
	* This is a pure virtual method to be implemented by the derived class.This method calls 
	* the recognize method of the derived shape recognizer.
	*
	* @param traceGroup The co-ordinates of the shape which is to be recognized
	* @param screenContext Contains information about the input field like whether it is boxed input
	*                 or continuous writing
	* @param captureDevice Contains information about the device like its sampling rate
	* @param shapeIds A subset of the entire shape space for which shape recongizer confidences
	*                 need to be computed
	* @param shapeRecoConfidences the confidence values calculated by the recognizer
	*/

	virtual int getShapeRecoConfidences(const LTKTraceGroup& traceGroup, 
		const LTKScreenContext& screenContext,
		const vector<int>& shapeIds, vector<float>& shapeRecoConfidences){(void)traceGroup;(void)screenContext;(void)shapeIds;(void)shapeRecoConfidences;return FAILURE;}
				 

	/**
	* This is a virtual method to be implemented by the derived class. This method calls the 
	* train method of the derived shape recognizer.
	*
	* @param trainingList The name of the file containing the listing of files to be used for
	*                    training each of the shapes.
	*/

	virtual int train(const string& trainingList,
                      const string& strModelDataHeaderInfoFile, 
                      const string &comment, 
                      const string &dataset, 
                      const string &inFileType=INK_FILE) = 0;	
	
	/**
	* This method unloads all the training data
	*/
	virtual int unloadModelData() = 0;

	/**
	* This method sets the device context for the recognition
	*
	* @param deviceInfo The parameter to be set
	*/

    	virtual int setDeviceContext(const LTKCaptureDevice& deviceinfo) = 0;

	/**
	* This is a pure virtual method to be implemented by the derived class.
	* This method will Add a new shape class
	* shapeID contains classID of new class added
	* Returns Sucess/Failure
	*/

    	virtual int addClass(const LTKTraceGroup& sampleTraceGroup,int& shapeID);

		
	/**
	* This is a pure virtual method to be implemented by the derived class.
	* This method will Add a new shape class for adapt
	* shapeID contains classID of new class added
	* Returns Sucess/Failure
	*/

		virtual int addSample(const LTKTraceGroup& sampleTraceGroup,int shapeID);
		
	/**
	* This is a pure virtual method to be implemented by the derived class.
	* This method will delete shape
	* Returns Sucess/Failure
	*/
	virtual int deleteClass(int shapeID );
	
	/**
	* This is a pure virtual method to be implemented by the derived class.
	* This method will adapt the recent sample recognized
	*  True ShapeID is passed as argument
	* Returns Sucess/Failure
	*/
	virtual int adapt(int shapeID );

	/**
	* This is a pure virtual method to be implemented by the derived class.
	* This method will adapt the sample provided
	*  True ShapeID is also passed as argument
	* Returns Sucess/Failure
	*/

    	virtual int adapt(const LTKTraceGroup& sampleTraceGroup, int shapeID );


};

#endif

//#ifndef __LTKShapeRecognizer_H
//#define __LTKShapeRecognizer_H