aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/3rdparty/lipi-toolkit/src/include/LTKShapeRecoUtil.h
blob: 9a4c37765e7ce6258955834d60f8dfb92c8cf476 (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
/*****************************************************************************************
* 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-07-18 15:00:39 +0530 (Fri, 18 Jul 2008) $
 * $Revision: 561 $
 * $Author: sharmnid $
 *
 ************************************************************************/
#ifndef __LTKSHAPERECOUTIL_H
#define __LTKSHAPERECOUTIL_H

#include "LTKInc.h"
#include "LTKTypes.h"


class LTKShapeFeature;
class LTKTraceGroup;
class LTKCaptureDevice;
class LTKScreenContext;
class LTKPreprocessorInterface;

#include "LTKShapeFeatureMacros.h"

/**
* @class LTKShapeRecoUtil 
* <p> A utility class that offer some common functionalities to all the classifiers <p>
*/
class LTKShapeRecoUtil
{

public:
//	static FN_PTR_DELETE_SHAPE_FTR_PTR m_deleteShapeFeatureFunc;

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

	/**
	* Default Constructor
	*/
	LTKShapeRecoUtil();
	
	/**
	* Destructor
	*/
	~LTKShapeRecoUtil();

	// @}

	/**
	 * @name Utility Methods
	 */
	// @{

	/** 
	* 
	* This method is used to convert the relative path to the absolute path	
	*
	* Semantics
	*
	* 	- Split the line into tokens with delimiters \ and / using LTKStringUtil::tokenizeString
	*
	* 	- If first token is not relative path then return SUCCESS
	*
	* 	- Change the relative path to Absolute path ($LIPI_ROOT -> C:\Lipitk)
	*	
	* @param  pathName     : string : Holds the path of the training file
	* @param  lipiRootPath : string : Holds the lipiroot path
	* @return SUCCESS
	* @exception none
	*/
	int getAbsolutePath (const string& inputPath, 
	                            const string& lipiRootPath, 
	                            string& outPath);	

	/**
	* This method reads the project.cfg to find whether the project is dynamic or not
	*
	* Semantics
	*
	* 	- Read the key value pairs defined in project.cfg into a stringStringMap 
	*		projectCfgAttrs = new LTKConfigFileReader(configFilePath.c_str());
	*
	* 	- Read the value for the key PROJECT_CFG_ATTR_NUMSHAPES_STR
	*		numShapesCfgAttr = projectCfgAttrs[PROJECT_CFG_ATTR_NUMSHAPES_STR];
	*
	* 	- If  numShapesCfgAttr == "Dynamic"
	*		-	returnBool = true; and
	*		-	numShapes = 0
	*
	* 	- If numShapesCfgAttr != "Dynamic"
	*		-	Read the value and convert string to an integer
	*			returnBool = false;
	*			valueFromCFG = numShapesCfgAttr;
	*			tempNumShapes = atoi(valueFromCFG.c_str());
	*
	*		-	If tempNumShapes == 0, Project is treated as dynamic
	*
	* @param  configFilePath : string : Holds the path of the project.cfg
	* @param  numShapes : unsigned short : Holds the NumShapes value from config file
	* @param  returnStauts : int : Holds SUCCESS or ErrorValues
	* @param  strNumShapes : string : Holds the NumShapes value from config file
	*
	* @return True : If project is dynamic
	* @return        "  If the value for key PROJECT_CFG_ATTR_NUMSHAPES_STR is "dynamic"
	* @return        "  If value for key PROJECT_CFG_ATTR_NUMSHAPES_STR is 0
	* @return False: otherwise
	*
	* @exception	ECONFIG_FILE_OPEN		Could not open project.cfg
	* @exception	EINVALID_NUM_OF_SHAPES  Negative value for number of shapes
	*/
        int isProjectDynamic(const string& configFilePath, 
                unsigned short& numShapes, 
                string& strNumShapes,
                bool& outIsDynamic );


	/** This method reads the Ink file and check for empty traces
	*
	* <pre>
	* Semantics
	*
	* 	- Call getAbsolutePath to convert the relative path to absolute path
	*
	* 	- Call the readUnipenInkFile to read the ink file from the disk
	*
	* 	- Call the checkEmptyTraces to check for empty traces
	*
	* @param path		 : string : Holds the ink file path
	* @param lipiRootPath: string : Holds the path of Lipi Root
	* @param inTraceGroup: LTKTraceGroup :
	* @param captureDevice: LTKCaptureDevice :
	* @param screenContext: LTKScreenContext :
	* @return 0 if not have empty traces
	* @return 1 if it having empty traces
	* @exception none	
	*/
        int readInkFromFile(const string& path, const string& lipiRootPath,
                LTKTraceGroup& inTraceGroup, 
                LTKCaptureDevice& captureDevice,
                LTKScreenContext& screenContext);

	
	/** This method is used to check the empty traces
	*
	* <pre>
	* Semantics
	*
	* 	- Iterate all the traces in inTraceGroup
	*
	* 	- Check for number of points for each traces to 0
	*	
	* @param  inTraceGroup: LTKTraceGroup :
	* @return 1 if it contains empty trace group,
	* @return 0 otherwise
	* @exception none
	*/

    int convertHeaderToStringStringMap(const string& header, stringStringMap& headerSequence);

    int shapeFeatureVectorToFloatVector(const vector<LTKShapeFeaturePtr>& shapeFeature, 
                                                   floatVector& outFloatVector);

	
	// @}
};

#endif