diff options
Diffstat (limited to 'src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include')
33 files changed, 6741 insertions, 0 deletions
diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKCaptureDevice.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKCaptureDevice.h new file mode 100644 index 00000000..5acb9838 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKCaptureDevice.h @@ -0,0 +1,239 @@ +/****************************************************************************** +* 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: Definition of LTKCaptureDevice which holds the information about + * the digitizer. + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + *****************************************************************************/ + +#ifndef __LTKCAPTUREDEVICE_H +#define __LTKCAPTUREDEVICE_H + +#include "LTKInc.h" + +/** + * @class LTKCaptureDevice + * <p> This class contains meta-data about hardware that was used to acquire + * the ink contained in a file. </p> + */ + +class LTKCaptureDevice +{ +private: + + int m_samplingRate; // sampling rate of the device + + int m_xDpi; // horizontal direction resolution of the device + + int m_yDpi; // vertical direction resolution of the device + + float m_latency; // interval between the time of actual input + // to that of its registration + + bool m_isUniformSamplingRate; // flag to indicate if the sampling is uniform + +public: + + /** + * @name Constructors and Destructor + */ + // @{ + + /** + * Default Constructor + */ + + LTKCaptureDevice(); + + /** + * This constrcutor takes various paramaters about a digitizer. + * @param sRate The sampling rate of bits + * @param uniform Indicates the consistency of sampling rate + * @param lVaue Device latency (in milliseconds) that applies to all channels + * @param xDpi Dots per inch in horizontal direction. + * @param yDpi Dots per inch in vertical direction. + */ + + LTKCaptureDevice(int sRate, bool uniform, float lValue, int xDpi, int yDpi); + + /** + * Copy constructor + */ + + LTKCaptureDevice(const LTKCaptureDevice& captureDevice); + + /** Destructor */ + + ~LTKCaptureDevice(); + + // @} + + /** + * @name Assignment operator + */ + // @{ + + /** + * Assignment operator + * @param captureDevice The object that has to be copied by assignment + * + * @return LTKCaptureDevice object + */ + + LTKCaptureDevice& operator=(const LTKCaptureDevice& captureDevice); + // @} + + /** + * @name Getter Functions + */ + // @{ + + /** + * This function returns the sampling rate measured in samples/sec + * @param void + * + * @return Sampling rate of bits. + */ + + int getSamplingRate() const; + + /** + * This fucntion returns the latency of the real-time channel, + * in msec, from physical action to the API time stamp. + * @param void + * + * @return Basic device latency in milli seconds. + */ + + float getLatency() const; + + /** + * This function returns dots per inch in X direction. + * @param void + * + * @return X dpi of the device + */ + + int getXDPI() const; + + /** + * This function returns dots per inch in Y direction. + * @param void + * + * @return Y dpi of the device + */ + + int getYDPI() const; + + /** + * This function returns a boolean to indicate if the sampling rate is + * regular or irregular + * @param void + * + * @return If the device samples the points uniformly or non-uniformly + */ + + bool isUniformSampling() const; + // @} + + /** + * @name Setter Functions + */ + // @{ + + /** + * This function sets the sampling rate of the device + * @param samplingRate Sampling rate of the device + * + * @return SUCCESS on successful set operation + */ + + int setSamplingRate(int samplingRate); + + /** + * This fucntion returns the latency of the outputs from the device + * in msec, from physical action to the API time stamp. + * @param latency Latency of the device + * + * @return SUCCESS on successful set operation + */ + + int setLatency(float latency); + + /** + * This function sets the boolean to indicate the consistency of sampling rate. + * @param isUniform True if sampling ir regular, False if irregular + * + * @return SUCCESS on successful set operation + */ + + void setUniformSampling(bool isUniform); + + /** + * This function sets the value for dots per inch to be taken in X direction. + * @param xDpi The dots per inch in X direction. + * + * @return SUCCESS on successful set operation + */ + + int setXDPI(int xDpi); + + /** + * This function sets the value for dots per inch to be taken in Y diretion. + * @param yDpi The dots per inch in Y direction. + * + * @return SUCCESS on successful set operation + */ + + int setYDPI(int yDpi); + // @} + +}; + +#endif + +//#ifndef __LTKCAPTUREDEVICE_H +//#define __LTKCAPTUREDEVICE_H + + + + + + + + + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKChannel.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKChannel.h new file mode 100644 index 00000000..e5328bfd --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKChannel.h @@ -0,0 +1,215 @@ +/****************************************************************************** +* 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-10 15:23:21 +0530 (Thu, 10 Jul 2008) $ + * $Revision: 556 $ + * $Author: sharmnid $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: Definition of LTKChannel which has the description of a particular + input stream like x-coordinate stream, y-coordinate stream, + time, pressure etc. + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKCHANNEL_H +#define __LTKCHANNEL_H + +#include "LTKTypes.h" + +/** +* @ingroup Common_Classes +*/ + +/** @brief Stores information about a channel,whose value is captured by a digitizer. + * @class LTKChannel + * <p> Channels captured by a digitizer can have different data types. The memory storage for the + * data types of these channels is thus different. + * LIPI Toolkit requires coordinates to have "float" data type to have same memory allocation + * for coordinate values. </p> + * + * <p> In order to retain the information about a channel,name, datatype, and a boolean (to indicate + * if the channel is Regular or Intermittent) are stored in this class. </p> + * + * <p> LTKChannel class object has to be created prior to any request for recognition. These + * objects are stored in LTKTraceFormat class. </p> + * + * @see LTKTraceFormat + * + */ + + +class LTKChannel +{ +private: + + string m_channelName; // logical name of the channel + + ELTKDataType m_channelType; // data type of values obtained from channel + + bool m_isRegularChannel; // flag to indicate if a value for the channel + // is available at every sampling instance + +public: + + /** @name Constructors and Destructor */ + + //@{ + + /** + * Default Constructor. + */ + + LTKChannel(); + + + LTKChannel(const string& channelName); + + /** + * This constructor initializes the members of the class + * @param channelName Name of the channel + * @param ELTKDataType Data type of the channel is stored. This is stored only for information. + * Internally all channel values are stored as float. + * @param isRegular Boolean variable that indicates if the channel is Regular or Intermittent. + * + */ + + LTKChannel(const string& channelName, ELTKDataType channelType, bool isRegular); + + /** + * Copy Constructor + */ + + LTKChannel(const LTKChannel& channel); + + /** + * Destructor + */ + + ~LTKChannel(); + //@} + + /** + * @name Assignment operator + */ + //@{ + + /** + * Assignment operator + * @param channelObj The object to be copied by assignment + * + * @return LTKChannel object + */ + + LTKChannel& operator=(const LTKChannel& channel); + //@} + + /** + * @name Getter Functions + */ + //@{ + + /** + * This method returns data type of a channel + * @param void + * + * @return enum data type of ELTKDataType . + */ + + ELTKDataType getChannelType() const; + + /** + * This method returns name of the channel. + * @param void + * + * @return name of the channel. + */ + + string getChannelName() const; + + /** + * This method returns a boolen to indicate if the channel is regular or intermittent. + * @param void + * + * @return True if channel is Regular, False if channel is Intermittent. + */ + + bool isRegularChannel() const; + //@} + + /** + * @name Setter Functions + */ + //@{ + + /** + * This method sets the type of a channel + * @param channelType The channel type passed should belong to ELTKDataType. + * + * @return SUCCESS on successful set operation + */ + + void setChannelType(ELTKDataType channelType); + + /** + * This method sets the channel name + * @param channelName The name of the channel which a digitizer can capture. + * + * @return SUCCESS on successful set operation + */ + + int setChannelName(const string& channelName); + + /** + * This method sets a boolean to indicate if the channel is Regular or Intermittent. + * @param isRegular boolean value to indicate if the channel is Regular or Intermittent. + * + * @return SUCCESS on successful set operation + */ + + void setRegularChannel(bool isRegular); + //@} + +}; + +#endif + +//#ifndef __LTKCHANNEL_H +//#define __LTKCHANNEL_H + + + + + + + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKClassifierDefaults.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKClassifierDefaults.h new file mode 100644 index 00000000..745b0bf0 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKClassifierDefaults.h @@ -0,0 +1,73 @@ +/***************************************************************************************** +* 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: 2009-11-24 17:23:35 +0530 (Tue, 24 Nov 2009) $ + * $Revision: 792 $ + * $Author: mnab $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Definition of all classifier config variables (default) settings + * CONTENTS: + * AUTHOR: Balaji MNA + * DATE: 22-Nov-2008 + * CHANGE HISTORY: + * Author Date Description of change + * Balaji MNA 22-Nov-2008 [LIPTKT-405] Cleaning up LTKPreprocDefaults + ************************************************************************/ + +#ifndef __CLASSIFIERDEFAULTS_H__ +#define __CLASSIFIERDEFAULTS_H__ + +#define PREPROC_DEF_TRACE_DIMENSION 60 +#define PREPROC_DEF_RESAMPLINGMETHOD "lengthbased" +#define PREPROC_DEF_SIZE_THRESHOLD 0.01f +#define PREPROC_DEF_PRESERVE_ASPECT_RATIO true +#define PREPROC_DEF_ASPECTRATIO_THRESHOLD 3.0f +#define PREPROC_DEF_PRESERVE_RELATIVE_Y_POSITION false +#define PREPROC_DEF_SMOOTHFILTER_LENGTH 3 +#define NN_DEF_PREPROC_SEQ "{CommonPreProc::normalizeSize,CommonPreProc::resampleTraceGroup,CommonPreProc::normalizeSize}" +#define NN_DEF_PROTOTYPESELECTION "hier-clustering" +#define NN_DEF_PROTOTYPEREDUCTIONFACTOR -1 +#define NN_DEF_FEATURE_EXTRACTOR "PointFloatShapeFeatureExtractor" +#define NN_DEF_DTWEUCLIDEANFILTER -1 +#define NN_DEF_REJECT_THRESHOLD 0.001 +#define NN_DEF_NEARESTNEIGHBORS 1 +#define NN_DEF_PROTOTYPEDISTANCE "dtw" +#define NN_DEF_BANDING 0.33 + +//ActiveDTW parameters +#define ACTIVEDTW_DEF_PERCENTEIGENENERGY 90 +#define ACTIVEDTW_DEF_EIGENSPREADVALUE 16 +#define ACTIVEDTW_DEF_USESINGLETON true +#define ACTIVEDTW_DEF_DTWEUCLIDEANFILTER 100 + +#define NEURALNET_DEF_NORMALIZE_FACTOR 10.0 +#define NEURALNET_DEF_RANDOM_NUMBER_SEED 426 +#define NEURALNET_DEF_LEARNING_RATE 0.5 +#define NEURALNET_DEF_MOMEMTUM_RATE 0.25 +#define NEURALNET_DEF_TOTAL_ERROR 0.00001 +#define NEURALNET_DEF_INDIVIDUAL_ERROR 0.00001 +#define NEURALNET_DEF_HIDDEN_LAYERS_SIZE 1 +#define NEURALNET_DEF_HIDDEN_LAYERS_UNITS 25 +#define NEURALNET_DEF_MAX_ITR 100 +#endif //#ifdef __CLASSIFIERDEFAULTS_H__ diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKErrorsList.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKErrorsList.h new file mode 100644 index 00000000..3307ae9a --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKErrorsList.h @@ -0,0 +1,248 @@ +/***************************************************************************************** +* 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: 2009-11-24 17:23:35 +0530 (Tue, 24 Nov 2009) $ + * $Revision: 792 $ + * $Author: mnab $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: + * + * CONTENTS: + * + * AUTHOR: Vijayakumara M. + * + * DATE: 01-Sept-2005 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ +#ifndef _LTK_ERRORS_LIST_H__ +#define _LTK_ERRORS_LIST_H__ + +/** +* @ingroup util +*/ + +/** @file LTKErrorsList.h +* @brief Contains the error macors used in Lipitk +*/ + + +// File related errors. +#define EINK_FILE_OPEN 100 /**< @brief Ink File Open Error. */ +#define ECONFIG_FILE_OPEN 101 /**< @brief Unable to open the .cfg file. */ +#define EHEADER_INFO_FILE_OPEN 102 /**< @brief Header information file open error */ +#define EMODEL_DATA_FILE_OPEN 103 /**< @brief Model Data file open error. */ +#define ETRAINLIST_FILE_OPEN 104 /**< @brief Training List file open error. */ +#define EMODEL_DATA_FILE_FORMAT 105 /**< @brief Model Data file is not in the format. */ +#define EINVALID_INPUT_FORMAT 106 /**< @brief Model Data file has been corrupted. */ + +//dll related errors +#define ELOAD_SHAPEREC_DLL 107 /**< @brief Error while Loading the shaperecognizer dll/so */ +#define ELOAD_WORDREC_DLL 108 /**< @brief Error while Loading the wordrecognizer dll/so */ +#define ELOAD_PREPROC_DLL 109 /**< @brief Error while Loading the preprocessing dll/so */ +#define EDLL_FUNC_ADDRESS 110 /**< @brief Unable to Get the function address in dll. */ +#define ECREATE_SHAPEREC 111 /**< @brief Unable to create the shaperecognizer instance. */ +#define ECREATE_WORDREC 112 /**< @brief Unable to create the wordrecognizer instance. */ +#define ECREATE_PREPROC 113 /**< @brief Unable to crete the preprocessing instance. */ + +// Path set related errors. +#define ELIPI_ROOT_PATH_NOT_SET 114 /**< @brief Lipi root path is not set */ +#define EINVALID_PROJECT_NAME 115 /**< @brief Invalid Project name given in command prompt. */ +#define EINVALID_CONFIG_ENTRY 116 /**< @brief Invalid configuration entry in cfg file */ +#define ENO_SHAPE_RECOGNIZER 117 /**< @brief Shape Reconginer is not entered in the cfg file. */ +#define ENO_WORD_RECOGNIZER 118 /**< @brief word Reconginer is not entered in the cfg file. */ + +//Invalid Values +#define EINVALID_NUM_OF_TRACES 119 /**< @brief Invalide number of traces processed. */ +#define EINVALID_NUM_OF_SHAPES 120 /**< @brief Invalid value for number of shapes. */ +#define EINVALID_TRACE_DIMENTION 121 /**< @brief Invalid value for Trace Dimension. */ +#define EINVALID_NUMEIGENVECTOR 122 /**< @brief Invalid value for EigenVectors. */ +#define EINVALID_FLOAT_SIZE 123 /**< @brief Invalid size of flaot in Model data header in model data file. */ +#define EINCOMPATIBLE_VERSION 124 /**< @brief Incompatible algorithm version number. */ +#define EINVALID_PREPROC_SEQUENCE 125 /**< @brief Preproccessing sequence error. */ + +//General errors +#define ENO_TOKEN_FOUND 126 /**< @brief No token found, invalid entry for project name */ +#define EINVALID_LOGICAL_NAME 127 /**< @brief Invalide Logical Name entered in project.cfg file. */ + +#define EINVALID_SEGMENT 128 /**< @brief Only Boxed Recognition is supported */ +#define EINVALID_REC_MODE 129 /**< @brief Unsupported reccognizer mode */ + +#define EUNSUPPORTED_STATISTICS 130 /**< @brief Bad name for the statistics to be computed */ + +#define EMAP_NOT_FOUND 131 /**< @brief The function is not implemented for shape recognizer project */ +#define EINVALID_SHAPEID 132 /**< @brief Invalid value for shapID. */ + +#define ENOMAPFOUND_LIPIENGINECFG 133 /**< @brief Cannot map the logical name, no entries in lipiengine.cfg */ +#define EINVALID_NUM_OF_POINTS 134 /**< @brief Number of points in the tracegroup is not normalized */ +#define EEMPTY_TRACE 135 /**< @brief Number of points in the trace is zero */ +#define EEMPTY_TRACE_GROUP 136 /**< @brief Number of traces in the trace group is zero */ +#define ECONFIG_FILE_RANGE 137 /**< @brief The config file variable is not within the correct range */ + +#define EINITSHAPE_NONZERO 138 /**< @brief Intial shape id is not zero. */ +#define EINVALID_LINE_LISTFILE 139 /**< @brief Invalid line in the listfile (train or test ) */ +#define EINVALID_ORDER_LISTFILE 140 /**< @brief Invalid order of shape-ids in the list file ( train ). */ +#define ENUM_NNS 141 /**< @brief Invalid number of nearest neighbours specified */ + + +#define EINKFILE_EMPTY 142 /**< @brief Ink file name is empty */ +#define EINKFILE_CORRUPTED 143 /**< @brief ERROR: Incorrect or corrupted unipen ink file. */ +#define EDLL_FUNC_ADDRESS_CREATE 144 /**< @brief Unable to Get the create function address in dll. */ +#define EDLL_FUNC_ADDRESS_DELETE 145 /**< @brief Unable to Get the delete function address in dll. */ +#define ENO_RESAMPLETRACEGROUP 146 /**< @brief No ResampleTraceGroup in preProcSequence of cfg file */ + +#define EINVALID_SAMPLING_RATE 147 /**< @brief Sampling rate cannot be negative */ +#define EINVALID_X_RESOLUTION 148 /**< @brief m_xDpi values cannot be negative */ +#define EINVALID_Y_RESOLUTION 149 /**< @brief m_yDpi values cannot be negative */ +#define EINVALID_LATENCY 150 /**< @brief m_latency cannot be negative */ +#define EPOINT_INDEX_OUT_OF_BOUND 151 /**< @brief Point index greater than number of points available */ +#define ECHANNEL_INDEX_OUT_OF_BOUND 152 /**< @brief Invalid Channel */ +#define ECHANNEL_SIZE_MISMATCH 153 /**< @brief New channel data not as long as the old one */ +#define ENUM_CHANNELS_MISMATCH 154 /**< @brief Point to be added does not have the same number of channels as the trace */ +#define EDUPLICATE_CHANNEL 155 /**< @brief Channel with the new channel name already present */ +#define ECHANNEL_NOT_FOUND 156 /**< @brief Channel not found */ +#define EZERO_CHANNELS 157 /**< @brief Number of channels cannot be zero */ +#define EINVALID_INPUT_STREAM 158 /**< @brief Input stream does not match with number of channels in the trace */ +#define ECOMPUTE_DISTANCE_ERROR 159 /**< @brief Error: Cannot find distance for test sample with more than 1 stroke */ +#define ECOMPARISON_ERROR 160 /**< @brief Error: Cannot compare with train sample having more than 1 stroke */ +#define ETRAIN_TEST_VECTOR_SIZE_MISMATCH 161 /**< @brief Incompatible: train vector and test vector sizes do not match */ +#define EGRAMMER_FILE_NOT_EXIST 162 /**< @brief Grammar file does not exists */ +#define EVALUES_NOT_PROVIDED 163 /**< @brief Values for the terminal is not Provided */ +#define ECONFIG_FILE_FORMAT 164 /**< @brief No productions or terminals identified in the CFG. Please check the CFG format */ +#define ECYCLIC_DEPENDENCY 165 /**< @brief Cyclic dependency exists! Unable to find paths */ +#define EFILE_OPEN_ERROR 166 /**< @brief Failed to open file */ + +//Feature extractor errors +#define ELOAD_FEATEXT_DLL 167 /**< @brief Error while Loading the Feature Extractor dll/so */ +#define EDLL_FUNC_ADDRESS_CREATE_FEATEXT 168 /**< @brief Unable to Get the create function address in Featuer extractor dll */ +#define EDLL_FUNC_ADDRESS_DELETE_FEATEXT 169 /**< @brief Unable to Get the delete function address in Featuer extractor dll */ +#define EFTR_EXTR_NOT_EXIST 170 /**< @brief Unable to find the feature extractor code */ +#define ENO_FTR_EXTR_IN_CFG 171 /**< @brief No Feature Extractor in Config file */ +#define EFTR_RPRCLASS_NOIMPLEMENTATION 172 /**< @brief No implementation provided */ +#define EINVALID_ORDER_FEATUREFILE 173 /**< @brief Invalid order of shape-ids in the Feature file. */ + +#define ENUMSHAPES_NOT_SET 174 /**< @brief Error code when the NumShapes config value is not set */ +#define EUNEQUAL_LENGTH_VECTORS 175 +#define EINVALID_LOG_LEVEL 176 +#define EPROJ_NOT_DYNAMIC 177 /**< @brief Not allowed to ADD/Delete shape to project with Fixed number of Shapes */ +#define EMORPH_FVEC_SIZE_MISMATCH 178 /*Error: Cannot perform MORPH on features vectors of different sizes*/ +#define ESHAPE_RECOCLASS_NOIMPLEMENTATION 179 /*No implementation provided*/ + +#define ENULL_POINTER 180 /*Null Pointer*/ + +#define EINVALID_X_SCALE_FACTOR 181 /**< @brief Invalid X scale factor. Scale factor must be greater than zero */ +#define EINVALID_Y_SCALE_FACTOR 182 /**< @brief Invalid Y scale factor. Scale factor must be greater than zero */ +#define ECONFIG_MDT_MISMATCH 183 /**< @brief Parameter values in config file and MDT file do not match */ +#define ENEIGHBOR_INFO_VECTOR_EMPTY 184 /* "Distance Index Pair is empty"*/ +#define ERECO_RESULT_EMPTY 185 /*"Recognize result is empty"*/ +#define ESHAPE_SAMPLE_FEATURES_EMPTY 186/* "Features of input TraceGroup is empty"*/ +#define ENO_TOOLKIT_VERSION 187 /* Tookit version not specified */ +#define ETRACE_INDEX_OUT_OF_BOUND 188 +#define EINVALID_CFG_FILE_ENTRY 189 +#define EKEY_NOT_FOUND 190 +#define EFEATURE_INDEX_OUT_OF_BOUND 191 + + +#define EINVALID_FILE_HANDLE 192 +#define EFEATURE_FILE_OPEN 193 /**< @brief Feature file open error. */ +#define EFTR_DISTANCE_NOT_DEFINED 194 /**< @brief Distance between the features not defined */ +#define EINVALID_CLUSTER_ID 195 /**< @brief Distance between the features not defined */ +#define EPROTOTYPE_SET_EMPTY 196 /**< @brief Distance between the features not defined */ +#define ELOG_FILE_NOT_EXIST 197 + +//LTKHierarchicalClustering Errors +#define EDATA_HYPERLINK_VEC_SIZE_MISMATCH 198 //**< @brief Size of the data objects vector and their corresponding hyperlinks vector do not match */ +#define EFILE_CREATION_FAILED 199 //**< @brief File creation failed. Invalid path or no permission. */ +#define EINVALID_NUM_CLUSTERS 200 //**< @brief Invalid number of clusters specified. The number must be greater than or equal to 1 and less than number of data objects. */ +#define ENO_DATA_TO_CLUSTER 201 //**< @brief No elements in the input data vector for clustering. */ +#define EINSUFFICIENT_DATA_FOR_LMETHOD 202 //**< @brief Minimum 6 data objects are required to employ LMethod. */ + + +#define EMODULE_NOT_IN_MEMORY 203 /**< @brief Module index not found in module vector*/ +#define EINVALID_LOG_FILENAME 204 /*Specified Log filename is empty*/ +#define ECREATE_LOGGER 205 /*Error creating logger*/ +#define EINVALID_PROJECT_TYPE 206 /**< @brief Project type in CFG is missing or an invalid value */ + +#define EEMPTY_STRING 207 /**< @brief Empty string */ +#define EEMPTY_VECTOR 208 /**< @brief Empty vector */ + +#define ENON_POSITIVE_NUM 209 /**< @brief Negative or zero value */ +#define EEMPTY_WORDREC_RESULTS 210 /**< @brief The word recogniton result vector is empty */ +#define ENEGATIVE_NUM 211 /**< @brief Negative value */ + + +#define EINVALID_CLASS_ID 212 //**< @brief Invalid Class ID . */ + +#define EINVALID_CONFIDENCE_VALUE 213 //**< @brief Invalid Confidence Value. */ + +#define ENO_SHAPE_RECO_PROJECT 214 //**< @brief Shape Recognizer Project name missing in the word recognizer config file.*/ + +#define EINVALID_RECOGNITION_MODE 215 //**< @brief Unsupported recognition mode */ + +#define ELOGGER_LIBRARY_NOT_LOADED 216 + +#define ESINGLE_POINT_TRACE 217 //**< @brief Single point trace */ + +//ActiveDTW Errors +#define EEMPTY_FEATUREMATRIX 218 /**Feature Matrix is empty **/ + +#define EEMPTY_COVARIANCEMATRIX 219 /**Covariance Matrix is empty **/ + +#define EEMPTY_CLUSTERMEAN 220 /** Empty Cluster Mean **/ + +#define EEMPTY_MEANCORRECTEDDATA 221 /**Empty Mean Corrected Data **/ + +#define EINVALID_RANK 222 /** The rank value to compute eigen vectors is Invalid **/ + +#define EINVALID_NUM_OF_EIGENVECTORS 223 /** The number of eigen vectors is Invalid **/ + +#define EEMPTY_EIGENVALUES 224 /** Eigen values are empty **/ + +#define EEMPTY_EIGENVECTORS 225 /** Eigen Vectors are empty **/ + +#define ENUM_EIGVALUES_NOTEQUALTO_NUM_EIGVECTORS 226 /** Number of eigen values is not equal to number of eigen vectors **/ + +#define EPROTOYPESHAPE_INDEX_OUT_OF_BOUND 227 /** Invalid Index of Prototype Shape Accessed **/ + +#define EINVALID_NUM_SAMPLES 228 /** Invalid Number of Samples in Cluster **/ + +#define EADAPTSCHEME_NOT_SUPPORTED 229 /** Adapt scheme not supported **/ + +//sub stroke +#define EINVALID_SLOPE_VECTOR_DIMENSION 230 //**< @brief Slope vector has a different dimension */ +#define EINVALID_SLOPE 231 //**< @brief Nagative Slope is not allowed */ +#define ENO_SUBSTROKE 232 //**< @brief Sample has no valied substroke */ +#define EINVALID_DIRECTION_CODE 233 //**< @brief Direction code can't be nagative*/ +#define EEMPTY_SLOPE_VECTOR 234 //**< @brif Empty slope vector*/ +#define ESINGLE_SUBSTROKES 235 //**< @brief Single substroke found from the ink file*/ +#define EINVALID_FEATURE_VECTOR_DIMENSION 236 //**< @brif Invalide Feature vector dimention*/ +#define ENUMBER_OF_SUBSTROKES 237 //**< @brif Number of sub-stroke is either zero or less*/ + +#define EINVALID_NUM_OF_INPUT_NODE 238 /**< @brief Invalid value for number of input node. */ +#define EINVALID_NUM_OF_OUTPUT_NODE 239 /**< @brief Invalid value for number of output node. */ +#define EINVALID_NETWORK_LAYER 240 /**< @brief Network layer does not specified correctly. */ + +#endif //#ifndef _LTK_ERRORS_LIST_H__ + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKException.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKException.h new file mode 100644 index 00000000..1914ffa9 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKException.h @@ -0,0 +1,129 @@ +/****************************************************************************** +* 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-10 15:23:21 +0530 (Thu, 10 Jul 2008) $ + * $Revision: 556 $ + * $Author: sharmnid $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Definition of LTKException which holds error message of thrown error + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKEXCEPTION_H +#define __LTKEXCEPTION_H + +#include "LTKInc.h" + +/** @defgroup Exceptions +*/ + +/** @ingroup Exceptions +*/ + +/** + * @class LTKException + * <p>This class is used to contain error message thrown during an exception. </p> + */ + +class LTKException +{ + +protected: + + int m_errorCode; // Error Code of the exception defined in LTKMacros.h + +public: + /** + * @name Constructors and Destructor + */ + // @{ + + /** + * Default Constructor + */ + + LTKException (); + + /** + * Initialization Constructor + * + * @param exceptionMsg - error message + * + */ + + LTKException (int errorCode); + + /** + * Destructor + */ + + ~LTKException (); + + //@} + + /** + * @name Getter Functions + */ + + // @{ + + /** + * This method returns the error message embedded in the class object + * + * @return error message + * + */ + + string getExceptionMessage() const; + + /** + * This method returns the error code embedded in the class object + * + * @return error code + * + */ + + int getErrorCode() const; + + + // @} + +}; + +#endif + +//#ifndef __LTKEXCEPTION_H +//#define __LTKEXCEPTION_H + + + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKInc.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKInc.h new file mode 100644 index 00000000..91fb8dd1 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKInc.h @@ -0,0 +1,68 @@ +/***************************************************************************************** +* 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: 2011-04-14 13:27:55 +0530 (Thu, 14 Apr 2011) $ + * $Revision: 847 $ + * $Author: mnab $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: Contains list of standard include files + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + * Balaji, MNA 06 Jan, 2011 Macros defined in the file are moved to LTKMacros.h + ************************************************************************/ + +#ifndef __LTKINC_H +#define __LTKINC_H + +#include <exception> +#include <iostream> +#include <fstream> +#include <iomanip> + +#include <algorithm> +#include <string> +#include <string.h> +#include <vector> +#include <list> +#include <map> +#include <numeric> //STLOPT +#include <cstdlib> +#include <cfloat> +#include <cmath> +#include <ctime> +#include <limits.h> + +using namespace std; + + +#endif //#ifndef __LTKINC_H + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKLipiEngineInterface.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKLipiEngineInterface.h new file mode 100644 index 00000000..04d315b9 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKLipiEngineInterface.h @@ -0,0 +1,91 @@ +/***************************************************************************************** +* 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: 2011-01-18 15:41:43 +0530 (Tue, 18 Jan 2011) $ + * $Revision: 829 $ + * $Author: mnab $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: Interface definition of LipiEngine interface + * + * CONTENTS: + * + * + * AUTHOR: Thanigai Murugan K + * + * DATE: July 29 2005 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LIPIENGINEINTERFACE_H_ +#define __LIPIENGINEINTERFACE_H_ + +#include "LTKShapeRecognizer.h" +#include "LTKWordRecognizer.h" +#include "LTKRecognitionContext.h" + +class LTKLipiEngineInterface{ +public: + + + virtual void setLipiRootPath(const string& appLipiPath)=0; + + virtual void setLipiLibPath(const string& appLipiLibPath)=0; + + virtual int setLipiLogFileName(const string& appLipiPath) = 0; + + virtual int setLipiLogLevel(const string& appLogLevel)=0; + + /* To initialize the lipiengine */ + virtual int initializeLipiEngine() = 0; + + /* use this to create shape recognizer object, by passing the logical project name */ + virtual int createShapeRecognizer(string &strLogicalProjectName, LTKShapeRecognizer** outShapeRecognizerPtr) = 0; + + /* use this to create shape recognizer object, by passing the project name and profile name*/ + virtual int createShapeRecognizer(const string& strProjectName, + const string& strProfileName, + LTKShapeRecognizer** outShapeRecognizerPtr) = 0; + + /* use this to delete the shape recognizer object created using createShapeRecognizer call */ + virtual int deleteShapeRecognizer(LTKShapeRecognizer*) = 0; + + /* use this to create word recognizer object, by passing the project name and profile name*/ + virtual int createWordRecognizer(const string& strProjectName, + const string& strProfileName, + LTKWordRecognizer** outWordRecPtr) = 0; + + /* use this to create word recognizer object, by passing the logical project name*/ + virtual int createWordRecognizer(const string& strlogicalProjectName, + LTKWordRecognizer** outWordRecPtr) = 0; + + /* use this to delete the word recognizer object created using createShapeRecognizer call */ + virtual int deleteWordRecognizer(LTKWordRecognizer*) = 0; + +}; + +#endif //#ifndef __LIPIENGINEINTERFACE_H_ + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKLogger.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKLogger.h new file mode 100644 index 00000000..e0594d90 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKLogger.h @@ -0,0 +1,184 @@ +/***************************************************************************************** +* 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: 2007-09-12 15:47:40 +0530 (Wed, 12 Sep 2007) $ + * $Revision: 188 $ + * $Author: sharmnid $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Definition of the Debug Logging Module + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef LTKLOGGER_H +#define LTKLOGGER_H + +#include "LTKInc.h" +#include "LTKLoggerInterface.h" + +/** +* @ingroup util +*/ + +/** @brief A concrete class that implements the logger interface +* @class LTKLogger +*/ +class LTKLogger : public LTKLoggerInterface +{ + +private: + + EDebugLevel m_debugLevel; // log level which determines which log messages are to be written into the file + + string m_logFileName; // name of the log file + + ofstream m_logFile; // file pointer to the log file + + ofstream m_ofstream; // used to ignore messages with priority lower than defined by application + + ELogStatus m_logStatus; // status of logging - active or inactive + + bool m_isTimeStamped; // flag to indicate if time is to be printed on the log file along with log message + + static LTKLoggerInterface* loggerInstance; + + /** + * This is a method which writes auxiliary information like date, time and line number + * into the log file + * @param lineNumber - line number of the log message + * @return SUCCESS on successful writing of auxiliary information into log file + */ + + int writeAuxInfo(const string& fileName, int lineNumber); + + /** + * @name Constructors and Destructor + */ + + // @{ + + /** + * Default Constructor + */ + + LTKLogger(); + +public: + + static void destroyLoggerInstance(); + + static LTKLoggerInterface* getInstance(); + + /** + * Destructor + */ + + virtual ~LTKLogger(); + + // @} + + /** + * @name Function call operator + */ + //@{ + + /** + * Function call operator + * @param debugLevel reference to the log level of the message + * @param lineNumber source code line number of the log message + * + * @return reference to an output stream object + */ + + ostream& operator()(const EDebugLevel& debugLevel, const string& fileName, int lineNumber = 0); + + // @} + + /** + * @name Methods + */ + + // @{ + + /** + * This is a method sets the log level of the messages to be considered for + * redirecting to the log file + * @param debugLevel log level of the messages to be considered + * @return SUCCESS on successful set operation + */ + + int setLogLevel(const EDebugLevel& debugLevel); + + /** + * This is a method sets the name of the log file to be used + * @param logFileName Name of the log file to be used for logging + * @param traceGroup trace group into which the ink file has to be read into + * @return SUCCESS on successful set operation + */ + + void setLogFileName(const string& logFileName); + + /** + * This is a method which returns the log level of the messages to be considered for + * redirecting to the log file + * @return the log level of the messages to be considered for redirecting to the log file + */ + + EDebugLevel getLogLevel(); + + /** + * This is a method which returns the name of the file logging is done into + * @return the name of the file logging is done into + */ + + const string& getLogFileName() ; + + /** + * This is a method which starts the logging operation + * @return SUCCESS on successful start of logging + */ + + int startLog(bool timeStamp = true); + + /** + * This method will stop the logging operation. + * @return SUCCESS on successful start of logging + */ + + int stopLog(); + + // @} + + +}; + +#endif + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKLoggerInterface.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKLoggerInterface.h new file mode 100644 index 00000000..8bd94b5e --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKLoggerInterface.h @@ -0,0 +1,118 @@ +/****************************************************************************** +* 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: 2007-09-17 19:00:29 +0530 (Mon, 17 Sep 2007) $ + * $Revision: 209 $ + * $Author: madant $ + * + ************************************************************************/ + +#ifndef __LTKLoggerINTERFACE_H_ +#define __LTKLoggerINTERFACE_H_ + +#include <ostream> + +using namespace std; + +class LTKLoggerInterface +{ +public: + // create dummy stream which just dumps all output + // this is what we use if the DebugLevel is higher than the message importance + // this stream sets a failbit and hence won't attempt to process it's input + + enum ELogStatus + { + INACTIVE, + ACTIVE + }; + + /* + description of the debug levels + ALL writes all messages + DEBUG writes DEBUG, INFO and ERR messages + INFO writes INFO and ERR messages + ERR writes ERROR messages + OFF does not log any messages + */ + + + enum EDebugLevel + { + LTK_LOGLEVEL_ALL, + LTK_LOGLEVEL_VERBOSE, + LTK_LOGLEVEL_DEBUG, + LTK_LOGLEVEL_INFO, + LTK_LOGLEVEL_ERR, + LTK_LOGLEVEL_OFF + }; + +public: + + virtual ostream& operator()(const EDebugLevel& debugLevel, const string &fileName, int lineNumber = 0) = 0; + + virtual int setLogLevel(const EDebugLevel& debugLevel) = 0; + + /** + * This is a method sets the name of the log file to be used + * @param logFileName Name of the log file to be used for logging + * @param traceGroup trace group into which the ink file has to be read into + * @return SUCCESS on successful set operation + */ + + virtual void setLogFileName(const string& logFileName) = 0; + + /** + * This is a method which returns the log level of the messages to be considered for + * redirecting to the log file + * @return the log level of the messages to be considered for redirecting to the log file + */ + + virtual EDebugLevel getLogLevel() = 0; + + /** + * This is a method which returns the name of the file logging is done into + * @return the name of the file logging is done into + */ + + virtual const string& getLogFileName() = 0 ; + + /** + * This is a method which starts the logging operation + * @return SUCCESS on successful start of logging + */ + + virtual int startLog(bool timeStamp = true) = 0; + + virtual int stopLog() = 0; + + /** + * Pure Virtual Destructor + */ + virtual ~LTKLoggerInterface(){}; + +}; + +#endif //#ifndef __LTKLoggerINTERFACE_H_ + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKMacros.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKMacros.h new file mode 100644 index 00000000..b9cc072d --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKMacros.h @@ -0,0 +1,894 @@ +/***************************************************************************************** +* 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: 2011-02-08 11:00:11 +0530 (Tue, 08 Feb 2011) $ + * $Revision: 832 $ + * $Author: dineshm $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: Contains common macro Definitions. + * + * CONTENTS: + * + * AUTHOR: Vijayakumara M. + * + * DATE: December 01, Aug, 2005 + * CHANGE HISTORY: + * Author Date Description of change + * Balaji, MNA 06 Jan, 2011 Macros defined in LTKInc.h are moved to this file + ************************************************************************/ + +#ifndef __COMMONMACORS_H +#define __COMMONMACORS_H + +#include "LTKTypes.h" + +/** @file LTKmacros.h +* @brief Contains the macors used in reco/shaperec/pca and reco/shaperec/dtw modules. +*/ +//macors used in reco/shaperec/pca and reco/shaperec/dtw modules. + +/** @file LTKInc.h +*/ +#define SUCCESS 0 +#define FAILURE 1 + +#ifdef WIN32 + #define SEPARATOR "\\" +#else + #define SEPARATOR "/" +#endif + +#define COMMENTCHAR '#' +#define LIST_FILE_DELIMITER " \t\r" + +//#define LTKReturnError(error) errorCode = error; return error; +#define LTKReturnError(error) return error; + +#define SHAPESETFILE "shapeset.cfg" +#define PROFILEFILE "profile.cfg" +#define WORDFILE "word.cfg" +#define WORDPROFILEFILE "wordprofile.cfg" +#define STATSFILE "stats.txt" +#define NETWORKFILE "network.txt" +#define MODELSLISTFILE "modelslist.txt" +#define DICTIONARYFILE "dictionary.txt" + +//File Extensions +#define CONFIGFILEEXT ".cfg" +#define DATFILEEXT ".mdt" +#define POSFILEEXT ".pos" + +#define PI 3.1415926F +#define EPS 0.00001F +#define EPS1 0.001F + +//Isolated character recognizers +#define PCA "pca" +#define DTW "dtw" +#define POS "pos" +#define ZONE "zone" +#define HOLISTIC "holistic" +#define BCC "bcc" +#define EigDef "eigdef" +#define NN "nn" +#define HMM "hmm" +#define ACTIVEDTW "activedtw" +#define NEURALNET "neuralnet" + +//Feature Extractors +#define POINT_FLOAT "pointfloat" +#define SUBSTROKE "substroke" +#define PARAMETRIC_CURVE "parametriccurve" +#define L7 "l7" +#define L7RADIUS "L7Radius" +#define NPEN "npen" +#define NPEN_WINDOW_SIZE "NPenWindowSize" +#define RELHANDPOSSC "relhandpossc" + +//Word recognizers +#define DP "dp" +#define BOXFLD "boxfld" + +//PCA Config values +#define REVERSEFEATUREVECTORS "ReverseFeatureVectors" +#define TRACEDIMENSION "ResampTraceDimension" +#define NUMEIGENVECTORS "NumEigenVectors" +#define SIZETHRESHOLD "NormLineWidthThreshold" +#define ASPECTRATIOTHRESHOLD "NormPreserveAspectRatioThreshold" +#define DOTTHRESHOLD "NormDotSizeThreshold" +#define LOOPTHRESHOLD "LoopThreshold" +#define HOOKLENGTHTHRESHOLD1 "HookLengthThreshold1" +#define HOOKLENGTHTHRESHOLD2 "HookLengthThreshold2" +#define HOOKANGLETHRESHOLD "HookAngleThreshold" +#define SMOOTHFILTERLENGTH "SmoothWindowSize" +#define DISTANCEMEASURE "DistanceMeasure" +#define QUANTIZATIONSTEP "QuantizationStep" +#define CONFIDENCEMAPPINGFILE "ConfidenceMappingFile" +#define PRESERVEASPECTRATIO "NormPreserveAspectRatio" +#define PRESERVERELATIVEYPOSITION "NormPreserveRelativeYPosition" +#define RESAMPLINGMETHOD "ResampPointAllocation" + + +//NN Config values +#define FEATURES "Features" +#define PROTOTYPEDISTANCE "NNPrototypeDistanceMeasure" +#define NEARESTNEIGHBORS "NNRecoNumNearestNeighbors" +#define FEATUREPOINTDISTANCE "FeaturePointDistance" +#define DTWBANDING "NNDTWBandingRadius" +#define FEATUREEXTRACTOR "FeatureExtractor" +#define FEATUREREPRESENTATION "FeatureRepresentation" +#define LENGTHBASED "lengthbased" +#define POINTBASED "pointbased" +#define INTERPOINTDISTBASED "interpointdistbased" +#define LENGTHBASED_VARIABLE_NUMBER_OF_SAMPLES "lengthbasedvariablenumberofsamples" + +//ACTIVEDTW Config values +#define RETAINPERCENTEIGENENERGY "ActiveDTWRetainPercentEigenEnergy" +#define EIGENSPREADVALUE "ActiveDTWEigenSpreadValue" +#define USESINGLETON "ActiveDTWUseSingleton" +#define MINCLUSTERSIZE "ActiveDTWMinClusterSize" +#define MAXCLUSTERSIZE "ActiveDTWMaxClusterSize" +#define MDTFILEUPDATEFREQ "ActiveDTWMDTFileUpdateFreq" + +//NEURAL NET Config values +#define RANDOM_NUMBER_SEED "SeedValueForRandomNumberGenaretor" +#define NEURALNET_LEARNING_RATE "NeuralNetLearningRate" +#define NEURALNET_MOMEMTUM_RATE "NeuralNetMomemtumRate" +#define NEURALNET_TOTAL_ERROR "NeuralNetTotalError" +#define NEURALNET_INDIVIDUAL_ERROR "NeuralNetIndividualError" +#define NEURALNET_HIDDEN_LAYERS_SIZE "NeuralNetHiddenLayersSize" +#define NEURALNET_HIDDEN_LAYERS_UNITS "NeuralNetHiddenLayersUnitSize" +#define NEURALNET_NORMALISED_FACTOR "NeuralNetNormalizationFactor" +#define NEURALNET_WEIGHT_REESTIMATION "ReestimateNeuralnetConnectionWeights" +#define NEURALNET_TRAINING_ITERATION "NeuralnetTrainingIteration" +#define NEURALNET_TRAINING_SEQUENCE "PrepareTrainingSequence" + +//holistic config values +#define NUMNNS "numnns" +#define WORSTCASEVALUE "worstcasevalue" +#define NUMRESAMPLEPOINTS1 "NumResamplePoints1" +#define NUMRESAMPLEPOINTS2 "NumResamplePoints2" +#define SMOOTHFILTERLENGTH1 "SmoothFilterLength1" +#define SMOOTHFILTERLENGTH2 "SmoothFilterLength2" +#define SWANGNORMFACTOR "SwangNormFactor" +#define SWANGHOOKTHRESH "SwangHookThresh" +#define HORIZSTROKEANGLETHRESH "HorizStrokeAngleThresh" +//#define CONFIDENCEMAPPINGFILE "ConfidenceMappingFile" +//for bcc +#define NUMCHOICES "NumChoices" +#define COMBINATIONSCHEME "Combination" + + +#define NORMALIZETRACES "normalizetraces" +#define RESAMPLETRACES "resampletraces" +#define CENTERTRACES "centertraces" +#define REORDERTRACES "reordertraces" +#define REORIENTTRACES "reorienttraces" +#define NUMXGRIDS "numxgrids" +#define NUMYGRIDS "numygrids" +#define DISTRIBUTIONTHRESHOLD "distributionthreshold" +#define MINSHAPESUBSET "minshapesubset" +#define XTOLERANCE "xtolerance" +#define YTOLERANCE "xtolerance" +#define NUMXZONES "numxzones" +#define NUMYZONES "numyzones" +#define DENSITYTHRESH "densitythresh" +#define SAMPLETHRESH "samplethresh" +#define MAXBOXCOUNT "MaxBoxCount" +#define BOXEDSHAPEPROJECT "BoxedShapeProject" +#define BOXEDSHAPEPROFILE "BoxedShapeProfile" +#define DPSHAPEPROJECT "DPShapeProject" +#define DPSHAPEPROFILE "DPShapeProfile" +#define NUMSYMBOLS "NumSymbols" +#define NUMSHAPECHOICES "NumShapeChoices" +#define MINSHAPECONFID "MinShapeConfid" + + +//settings for DTW +#define FLEXIBILITYINDEX "FlexibilityIndex" +#define PROTOTYPESELECTION "NNTrainPrototypeSelectionMethod" +#define BANDING "Banding" +#define NUMFEATURES "NumFeatures" +#define PROTOREDFACTOR "NNTrainPrototypeReductionFactorPerClass" +#define NUMCLUSTERS "NNTrainNumPrototypesPerClass" +#define DTWEUCLIDEANFILTER "NNRecoDTWEuFilterOutputSize" +#define REJECT_THRESHOLD "NNRecoRejectThreshold" +#define ADAPTIVE_kNN "NNRecoUseAdaptiveKNN" + +//settings of word recognizer +#define REC_UNIT_INFO "rec_unit_info" +#define USE_GRAMMAR "use_grammar" +#define USE_WORDLIST "use_wordlist" +#define USE_POSITIONAL INFO "use_positional_info" +#define REC_MODE "rec_mode" +#define DICTIONARY_MODE "dictionary_mode" + +//For Word recognizer + +#define LTK_TRUE 0x01 +#define LTK_FALSE 0x00 + +//Reset parameters for Recognition context +#define LTK_RST_INK 0x02 +#define LTK_RST_RECOGNIZER 0x04 +#define LTK_RST_ALL 0xff + +//Recognition units +#define REC_UNIT_UNKNOWN 0x08 //No segment info +#define REC_UNIT_SYMBOL 0x10 //Symbol +#define REC_UNIT_CHAR 0x11 //Char +#define REC_UNIT_WORD 0x12 //Word + +//Recognition mode for the recognizer +#define REC_MODE_BATCH 0x14 //batch mode +#define REC_MODE_STREAMING 0x16 //streaming (trace by trace) + + +//Dictionary options +#define DICT_DRIVEN 0x20 //recognizes only the words in the dictio +#define DICT_ASSISTED 0x21 +#define DICT_OFF 0x22 + + +/** +* @brief Defines the sequence of preprocessor functions to be executed +*/ +#define PREPROCSEQUENCE "PreprocSequence" + +/** +* @brief Defines the scale to be used to compute the number of iterations for LVQ training +*/ +#define LVQITERATIONSCALE "LVQIterationScale" + +/** +* @brief Defines initial value of alpha used in LVQ training +*/ +#define LVQINITIALALPHA "LVQInitialAlpha" + +/** +* @brief Defines the distance measure to be used in LVQ training. +*/ +#define LVQDISTANCEMEASURE "LVQDistanceMeasure" + +/** +* @brief Defines the name of the preprocessor dll file +*/ +#define PREPROC "preproc" + +/** +* @brief Defines the string compare functions +*/ +#ifdef _WIN32 +#define LTKSTRCMP _stricmp +#else +#define LTKSTRCMP strcasecmp +#endif + +/** +* @brief Defines the name of the lipiengine dll file +*/ +#define LIPIENGINE_MODULE_STR "lipiengine" + +/** +* @brief Defines the name of the logger dll file +*/ +#define LOGGER_MODULE_STR "logger" + +/** +* @brief Defines the Lipi Root environment string +*/ +#define LIPIROOT "$LIPI_ROOT" + +/** +* @brief Defines the project is dynamic, where the numshapes can take any number of values +*/ +#define DYNAMIC "Dynamic" + +/** +* @brief Defines the header version for the model data file +*/ +#define HEADERVERSION "1.0.0" + + +#define VERSION_STR_LEN_SMALL 4 + +/** +* @brief Defines the length of the version information +*/ +#define VERSION_STR_LEN 10 + +/** +* @brief Defines the checksum header string length +*/ +#define CKSUM_HDR_STR_LEN 10 + +/** +* @brief Defines the starting error number +*/ +#define ERROR_START_NO 100 + +/** +* @brief Defines the maximum error number +*/ +#define MAX_ERROR_NO 240 + +/** +* @brief Defines the maximum file path length +*/ +#define MAX_PATH_LEN 255 + +/** +* @brief Defines the maximum string length +*/ +#define MAX_STRLEN 255 + +/** +* @brief Defines the lipi root environment string used in LipiEngine.cfg +*/ +#define LIPIROOT_ENV_STRING "LIPI_ROOT" + +/** +* @brief Defines the lipi library environment string used in LipiEngine.cfg +*/ +#define LIPILIB_ENV_STRING "LIPI_LIB" + +/** +* @brief Defines the type of project used in LipiEngine.cfg +*/ +#define PROJECT_TYPE_STRING "ProjectType" + +#define PROJECT_TYPE_SHAPEREC "SHAPEREC" + +/** +* @brief Defines the shape recognizer name used in LipiEngine.cfg +*/ +#define SHAPE_RECOGNIZER_STRING "ShapeRecMethod" + +/** +* @brief Defines the word recognizer name used in LipiEngine.cfg +*/ +#define WORD_RECOGNIZER_STRING "WordRecognizer" + +/** +* @brief Defines the path of the project directory in the Lipi tree +*/ +#define PROJECTS_PATH_STRING SEPARATOR + "projects" + SEPARATOR + +/** +* @brief Defines the path of the profile directory in the Lipi tree +*/ +#define PROFILE_PATH_STRING SEPARATOR + "config" + SEPARATOR + +/** +* @brief Defines the name of the default profile +*/ +#define DEFAULT_PROFILE "default" + +/** +* @brief Defines the name of profile config file +*/ +#define PROFILE_CFG_STRING "profile.cfg" + +/** +* @brief Defines the name of project config file +*/ +#define PROJECT_CFG_STRING "project.cfg" + +/** +* @brief Defines the NumShapes attributes in the project config file +*/ +#define PROJECT_CFG_ATTR_NUMSHAPES_STR "NumShapes" + +/** +* @brief Defines the name of the create shape recognizer function +*/ +#define CREATESHAPERECOGNIZER_FUNC_NAME "createShapeRecognizer" + +/** +* @brief Defines the name of the delete shape recognizer function +*/ +#define DELETESHAPERECOGNIZER_FUNC_NAME "deleteShapeRecognizer" + +/** +* @brief Defines the name of the createWordRecognizer function +*/ +#define CREATEWORDRECOGNIZER_FUNC_NAME "createWordRecognizer" + +/** +* @brief Defines the name of the deleteWordRecognizer function +*/ +#define DELETEWORDRECOGNIZER_FUNC_NAME "deleteWordRecognizer" + +/** +* @brief Defines the name of the resampleTraceGroup function +*/ +#define RESAMPLE_TRACE_GROUP_FUNC "resampleTraceGroup" + +/** +* @brief Defines the name of the resampleTraceGroup1 function +*/ +#define RESAMPLE_TRACE_GROUP_ONE_FUNC "resampleTraceGroup1" + +/** +* @brief Defines the name of the preprocess function +*/ +#define PREPROCESS_FUNC "preprocess" + +/** +* @brief Defines the name of the normalizeSize function +*/ +#define NORMALIZE_FUNC "normalizeSize" + +#define NORMALIZE_LARGE_FUNC "normalizeLargerSize" + +/** +* @brief Defines the name of the removeDuplicate function +*/ +#define REMOVE_DUPLICATE_POINTS_FUNC "removeDuplicatePoints" + +/** +* @brief Defines the name of another removeDuplicate function +*/ +#define REMOVE_DUPLICATE_POINTS_BY_ISI_FUNC "removeDuplicatePointsByISI" + +/** +* @brief Defines the name of the smoothenTraceGroup function +*/ +#define SMOOTHEN_TRACE_GROUP_FUNC "smoothenTraceGroup" + +#define SMOOTHEN_MOVINGAVERAGE_TRACE_GROUP_FUNC "smoothingByMovingAverage" + +/** +* @brief Defines the name of the dehookTraces function +*/ +#define DEHOOKTRACES_FUNC "dehookTraces" + +/** +* @brief Defines the name of the normalizeOrientation function +*/ +#define NORMALIZE_ORIENTATION_FUNC "normalizeOrientation" + +/** +* @brief Defines the Delimiter sequence for tokenize the strings +*/ +#define DELEMITER_SEQUENCE " {}," + +/** +* @brief Defines the Delimiter character for separating the function name with class name +*/ +#define DELEMITER_FUNC "::" + +/** +* @brief Defines the Delimiter sequence for tokenize the header information +*/ +#define TOKENIZE_DELIMITER "<>=\n\r" + +/** +* @brief Defines the string "CKS" (ChecKSum) +*/ +#define CKS "CKS" + +/** +* @brief Defines the project name used for header information +*/ +#define PROJNAME "PROJNAME" + +/** +* @brief Defines the project type used for header information +*/ +#define PROJTYPE "PROJTYPE" + +/** +* @brief Defines the recognizer name used for header information +*/ +#define RECNAME "RECNAME" + +/** +* @brief Defines the recognizer version used for header information +*/ +#define RECVERSION "RECVERSION" + +/** +* @brief Defines the string CREATETIME for header information +*/ +#define CREATETIME "CREATETIME" + +/** +* @brief Defines the string MODTIME for header information +*/ +#define MODTIME "MODTIME" + +/** +* @brief Defines the platform name (Windows or Linux) +*/ +#define PLATFORM "PLATFORM" + +/** +* @brief Defines the length of the comment used in header +*/ +#define COMMENTLEN "COMMENTLEN" + +/** +* @brief Defines the data offset length used in header +*/ +#define DATAOFFSET "DATAOFFSET" + +/** +* @brief Defines the number of shapes used in header information +*/ +#define NUMSHAPES "NUMSHAPES" + +/** +* @brief Defines the size of integer used in header information +*/ +#define SIZEOFINT "SIZEOFINT" + +/** +* @brief Defines the size of unsigned integer used in header information +*/ +#define SIZEOFUINT "SIZEOFUINT" + +/** +* @brief Defines the size of short integer used in header information +*/ +#define SIZEOFSHORTINT "SIZEOFSHORTINT" + +/** +* @brief Defines the size of float used in header information +*/ +#define SIZEOFFLOAT "SIZEOFFLOAT" + +/** +* @brief Defines the size of character used in header information +*/ +#define SIZEOFCHAR "SIZEOFCHAR" + +/** +* @brief Defines the header length +*/ +#define HEADERLEN "HEADERLEN" + +#define HIDDENLAYERSUNIT "HIDDENLAYERSUNIT" + +/** +* @brief Defines the dataset for header information +*/ +#define DATASET "DATASET" + +/** +* @brief Defines the comment information in header +*/ +#define COMMENT "COMMENT" + +/** +* @brief Defines the type of byte order (Little Endian or Big Endian) +*/ +#define BYTEORDER "BYTEORDER" + +/** +* @brief Defines the operating system version +*/ +#define OSVERSION "OSVERSION" + +/** +* @brief Defines the type of processor architecture +*/ +#define PROCESSOR_ARCHITEC "PROCESSOR_ARCHITEC" + +/** +* @brief Defines the Header version for header information +*/ +#define HEADERVER "HEADERVER" + + +#define PCA_ALGO "PCA" +#define WINDOWS "Windows" +#ifndef LINUX +#define LINUX "Linux" +#endif + +//Defined twice +#define BYTEORDER "BYTEORDER" + +/** +* @brief Defines the create preprocessor method name +*/ +#define CREATEPREPROCINST "createPreprocInst" + +/** +* @brief Defines the delete preprocessor method name +*/ +#define DESTROYPREPROCINST "destroyPreprocInst" + +#define FI_MIN 0 +#define FI_MAX 2 + +/** +* @brief Defines the minimum value in which the prototype reduction factor can take +*/ +#define PROTOTYPEREDFACT_MIN 0 + +/** +* @brief Defines the maximum value in which the prototype reduction factor can take +*/ +#define PROTOTYPEREDFACT_MAX 100 + +/** +* @brief Defines the input file type is the ink file +*/ +#define INK_FILE "ink" + +/** +* @brief Defines the input file type is the feature file +*/ +#define FEATURE_FILE "feature" + +/** +* @brief Defines the DTW type of distance to be calculated +*/ +#define DTW_DISTANCE "dtw" + +/** +* @brief Defines the euclidean type of distance to be calculated +*/ +#define EUCLIDEAN_DISTANCE "eu" + +/** +* @brief Defines the delimiter for the feature extractor +*/ +#define FEATURE_EXTRACTOR_DELIMITER "|" + +/** +* @brief Define the delimiter for the hidden layer unit +*/ +#define HIDDEN_LAYER_UNIT_DELIMITER ":" + +/** +* @brief Defines the delimiter for the space (assuming only signle space between +* class and the features in MDT file +*/ +#define CLASSID_FEATURES_DELIMITER " " + +/** +* @brief Defines the code for PointFloat Feature Extractor +*/ +#define POINT_FLOAT_SHAPE_FEATURE_EXTRACTOR 101 + +/** +* @brief Define the code for Angle Feature Extractor +*/ +#define SUBSTROKE_SHAPE_FEATURE_EXTRACTOR 103 + +/** +* @brief Define the code for spline Feature Extractor +*/ +#define PARAMETRIC_CURVE_SHAPE_FEATURE_EXTRACTOR 104 + + +/** +* @brief Uesd in computation of Feature Extraction (Angle) +*/ +#define DIRECTION_CODE_EAST 1 + +#define DIRECTION_CODE_NORTH_EAST 2 + +#define DIRECTION_CODE_NORTH 3 + +#define DIRECTION_CODE_NORTH_WEST 4 + +#define DIRECTION_CODE_WEST 5 + +#define DIRECTION_CODE_SOUTH_WEST 6 + +#define DIRECTION_CODE_SOUTH 7 + +#define DIRECTION_CODE_SOUTH_EAST 8 + +#define OVERLAP_THRESHOLD 15.0 + + +/** +* @brief Defines the code for L7 Feature Extractor +*/ +#define L7_SHAPE_FEATURE_EXTRACTOR 102 + +/** +* @brief Defines the create preprocessor method name +*/ +#define CREATE_SHAPE_FEATURE_EXTRACTOR "createShapeFeatureExtractor" + +/** +* @brief Defines the delete preprocessor method name +*/ +#define DELETE_SHAPE_FEATURE_EXTRACTOR "deleteShapeFeatureExtractor" + +#define LEARNING_RATE "LEARNING_RATE" + +#define HIDDEN_LAYER "HIDDEN_LAYER" + +#define NORMALISED_FACTOR "NORMALISED_FACTOR" + +#define MOMEMTUM_RATE "MOMEMTUM_RATE" + +#define FE_NAME "FE_NAME" + +#define FE_VER "FE_VER" + +#define PREPROC_SEQ "PREPROC_SEQ" + +#define DOT_SIZE_THRES "DOT_SIZE_THRES" + +#define ASP_RATIO_THRES "ASP_RATIO_THRES" + +#define DOT_THRES "DOT_THRES" + +#define PRESER_REL_Y_POS "PRESER_REL_Y_POS" + +#define PRESER_ASP_RATIO "PRESER_ASP_RATIO" + +#define NORM_LN_WID_THRES "NORM_LN_WID_THRES" + +#define RESAMP_POINT_ALLOC "RESAMP_POINT_ALLOC" + +#define SMOOTH_WIND_SIZE "SMOOTH_WIND_SIZE" + +#define TRACE_DIM "TRACE_DIM" + +#define PROTOTYPE_SELECTION_CLUSTERING "hier-clustering" + +#define PROTOTYPE_SELECTION_LVQ "lvq" + +#define PROTO_RED_FACTOR_AUTOMATIC "automatic" + +#define PROTO_RED_FACTOR_NONE "none" + +#define PROTO_RED_FACTOR_COMPLETE "complete" + +#define DTW_EU_FILTER_ALL "all" + +#define NAME_POINT_FLOAT_SHAPE_FEATURE_EXTRACTOR "PointFloatShapeFeatureExtractor" + +#define NAME_SUBSTROKE_SHAPE_FEATURE_EXTRACTOR "SubStrokeShapeFeatureExtractor" + +#define NAME_PARAMETRIC_CURVE_SHAPE_FEATURE_EXTRACTOR "ParametricCurveShapeFeatureExtractor" + +#define NAME_L7_SHAPE_FEATURE_EXTRACTOR "L7ShapeFeatureExtractor" + +#define NAME_NPEN_SHAPE_FEATURE_EXTRACTOR "NPenShapeFeatureExtractor" + +#define NAME_RELHANDPOSSC_SHAPE_FEATURE_EXTRACTOR "RelHandPosSCFeatureExtractor" + +#define NEW_LINE_DELIMITER '\n' + +#define DELTE_SHAPE_FTR_POINTER_FUNC "deleteShapeFeaturePtr" + +#define MDT_FOPEN_MODE "MDT_OPEN_MODE" + +/** +@brief Defines the log file name +*/ +#define LOG_FILE_NAME "LogFile" + +/** +@brief Defines the log level +*/ +#define LOG_LEVEL "LogLevel" + +#define DEFAULT_LOG_FILE "lipi.log" + +#define DEFAULT_LOG_LEVEL LTKLogger::LTK_LOGLEVEL_ERR + +#define LOG_LEVEL_DEBUG "DEBUG" + +#define LOG_LEVEL_ERROR "ERR" + +#define LOG_LEVEL_INFO "INFO" + +#define LOG_LEVEL_ALL "ALL" + +#define LOG_LEVEL_VERBOSE "VERBOSE" + +#define LOG_LEVEL_OFF "OFF" + +#define MDT_UPDATE_FREQUENCY "NNMDTFileUpdateFreq" +/** + @brief Used in computation of Confidence +*/ +#define MIN_NEARESTNEIGHBORS 2 + +#define EUCLIDEAN_FILTER_OFF -1 + +#define CONF_THRESHOLD_FILTER_OFF 0 + +#define NUM_CHOICES_FILTER_OFF -1 + +#define LTK_START_SHAPEID 0 + +#define ADAPT_SCHEME "AdaptScheme" + +#define NAME_ADD_LVQ_ADAPT_SCHEME "AddLVQ" + +#define MAX_PROTOTYPES "MaxNumPrototypes" + +#define ADAPT_CONF_LOWER_BOUND "ConfidenceLowerBound" + +#define ADAPT_CONF_UPPER_BOUND "ConfidenceUpperBound" + +#define ADAPT_MISMATCH_HIGH_CONF "MismatchHighConfidence" + +#define ADAPT_MISMATCH_LOW_CONF "MismatchLowConfidence" + +#define ADAPT_MATCH_HIGH_CONF "MatchHighConfidence" + +#define ADAPT_MATCH_LOW_CONF "MatchLowConfidence" + +#define ADAPT_MIN_NUMBER_SAMPLES_PER_CLASS "MinimumNumberOfSamplesPerClass" +#define DEFAULT_PROFILE "default" + +#define DEFAULT_CHANNEL_NAME "X" + +#define DEFAULT_DATA_TYPE DT_FLOAT + +#define X_CHANNEL_NAME "X" + +#define Y_CHANNEL_NAME "Y" + +#define DEFAULT_SAMPLING_RATE 100 + +#define DEFAULT_X_DPI 2000 + +#define DEFAULT_Y_DPI 2000 + +#define DEFAULT_LATENCY 0.0 + +#define DEFAULT_ERROR_CODE -1 + +#define LIPIENGINE_CFG_STRING "lipiengine.cfg" + +#define DEFAULT_SHAPE_RECO_CHOICES 5 + +#define DEFAULT_SHAPE_RECO_MIN_CONFID 0.0 + +#define EMPTY_STRING " " + +#define MDT_FILE_OPEN_MODE "NNMDTFileOpenMode" + +#define MIN_PERCENT_EIGEN_ENERGY 1 + +#define MAX_PERCENT_EIGEN_ENERGY 100 + +#define MIN_EIGENSPREADVALUE 1 + +//neuralnet +#define CONTINUE 0 +#define EXIT_FAILURE 1 +#define EXIT_SUCCESSFULLY 2 + +//for hmm clasifire + +#define FEATURE_DIMENTION 8 + +#endif // #ifndef __COMMONMACORS_H + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKOSUtil.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKOSUtil.h new file mode 100644 index 00000000..88a56ac8 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKOSUtil.h @@ -0,0 +1,111 @@ +/****************************************************************************** +* 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-08-12 11:34:07 +0530 (Tue, 12 Aug 2008) $ + * $Revision: 604 $ + * $Author: sharmnid $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: + * + * CONTENTS: + * + * AUTHOR: + * + * DATE: May 29, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKOSUTIL_H +#define __LTKOSUTIL_H + +#include "LTKTypes.h" + +class LTKOSUtil +{ +public: + + /** + * @name Constructors and Destructor + */ + + // @{ + + /** + * Default Constructor + */ + + LTKOSUtil(){}; + + /** + * Destructor + */ + + virtual ~LTKOSUtil(){}; + + // @} + + /** @brief Given library name, this function loads it into the adress space. + * @param lipiLibPath + * @param sharedLibName : name of the library to be loaded + * @param libHandle: pointer to the library handle + */ + virtual int loadSharedLib(const string& lipiLibPath, + const string& sharedLibName, + void** libHandle)=0; + + /** + */ + virtual int unloadSharedLib(void* libHandle)=0; + + virtual int getFunctionAddress(void * libHandle, + const string& functionName, + void** functionHandle)=0; + + virtual int getPlatformName(string& outStr)=0; + + virtual int getProcessorArchitechure(string& outStr)=0; + + virtual int getOSInfo(string& outStr)=0; + + virtual int recordStartTime()=0; + + virtual int recordEndTime()=0; + + virtual int diffTime(string& outStr)=0; + + virtual int getSystemTimeString(string& outStr)=0; + + virtual void* getLibraryHandle(const string& libName)=0; + + virtual string getEnvVariable(const string& envVariableName) =0; + + + +}; + +#endif + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKOSUtilFactory.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKOSUtilFactory.h new file mode 100644 index 00000000..2427d80e --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKOSUtilFactory.h @@ -0,0 +1,58 @@ +/****************************************************************************** +* 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-10 15:23:21 +0530 (Thu, 10 Jul 2008) $ + * $Revision: 556 $ + * $Author: sharmnid $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: + * + * CONTENTS: + * + * AUTHOR: + * + * DATE: May 29, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKOSUTILFACTORY_H +#define __LTKOSUTILFACTORY_H + +class LTKOSUtil; + +class LTKOSUtilFactory +{ + +public: + + static LTKOSUtil* getInstance(); + +}; + +#endif + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKPreprocDefaults.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKPreprocDefaults.h new file mode 100644 index 00000000..36179a7c --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKPreprocDefaults.h @@ -0,0 +1,73 @@ +/***************************************************************************************** +* 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: 2009-04-01 12:32:40 +0530 (Wed, 01 Apr 2009) $ + * $Revision: 751 $ + * $Author: royva $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Definition of all factory preprocessor (default) settings + * + * CONTENTS: + * + * AUTHOR: Thanigai Murugan + * + * DATE: 11-AUG-2005 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __PREPROCDEFAULTS_H__ +#define __PREPROCDEFAULTS_H__ + +#define PREPROC_DEF_NORMALIZEDSIZE 10.0f +#define PREPROC_DEF_DOT_THRESHOLD 0.01f +#define PREPROC_DEF_LOOP_THRESHOLD 0.25f +#define PREPROC_DEF_HOOKLENGTH_THRESHOLD1 0.17f +#define PREPROC_DEF_HOOKLENGTH_THRESHOLD2 0.33f +#define PREPROC_DEF_HOOKANGLE_THRESHOLD 30 +#define PREPROC_DEF_QUANTIZATIONSTEP 5 +#define PREPROC_DEF_FILTER_LENGTH 3 +#define NN_NUM_CLUST_INITIAL -2 + +#define PREPROC_DEF_INTERPOINT_DIST_FACTOR 15 + +// LVQ parameters +#define NN_DEF_LVQITERATIONSCALE 40 +#define NN_DEF_LVQINITIALALPHA 0.3 +#define NN_DEF_LVQDISTANCEMEASURE "eu" + +#define NN_DEF_MDT_UPDATE_FREQ 5 +#define NN_DEF_RECO_NUM_CHOICES 2 + +#define NN_MDT_OPEN_MODE_BINARY "binary" +#define NN_MDT_OPEN_MODE_ASCII "ascii" + + + +//ADAPT parameters +#define ADAPT_DEF_MIN_NUMBER_SAMPLES_PER_CLASS 5 +#define ADAPT_DEF_MAX_NUMBER_SAMPLES_PER_CLASS 10 +#endif //#ifdef__PREPROCDEFAULTS_H__ + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKPreprocessor.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKPreprocessor.h new file mode 100644 index 00000000..8ef68249 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKPreprocessor.h @@ -0,0 +1,632 @@ +/***************************************************************************************** +* 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: 2009-07-01 16:41:37 +0530 (Wed, 01 Jul 2009) $ + * $Revision: 783 $ + * $Author: mnab $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: Definition of LTKPreprocessor which is a library of standard pre-processing functions + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKPREPROCESSOR_H +#define __LTKPREPROCESSOR_H + +#define SUPPORTED_MIN_VERSION "3.0.0" + +#include "LTKCaptureDevice.h" + +#include "LTKScreenContext.h" + +#include "LTKMacros.h" + +#include "LTKInc.h" + +#include "LTKPreprocessorInterface.h" + +class LTKTrace; +class LTKShapeRecoConfig; + +/** + * @class LTKPreprocessor + * <p> This class performs pre-processing on a trace group. </p> + * + * <p> Different functions performing steps in pre-processing are implemented in different + * implementation files. Pre-processed trace group is the output of this class module </p> + * <p> Paramaters used across all pre -processor modules of a shape recognizer will be obtained + * from the shape recognizer's configuration file. The shape recognizer sets these paramaters in the pre-processor + * by calling the suitable setter functions defined in LTKPreprocessor.h </p> + */ + +class LTKPreprocessor : public LTKPreprocessorInterface +{ +private: + + float m_sizeThreshold; // threshold below which a trace will not be size normalized + + float m_loopThreshold; // threshold below which a trace will not be considered a loop + + float m_aspectRatioThreshold; // threshold above which the aspect ratio of a trace is maintained after size normalization + + float m_dotThreshold; // a threshold to detect shapes which are just dots + + float m_hookLengthThreshold1; + + float m_hookLengthThreshold2; + + float m_hookAngleThreshold; + + map<string, FN_PTR_PREPROCESSOR> m_preProcMap; // Holds the address of preprocessor functions. + + bool m_preserveAspectRatio; + + bool m_preserveRelativeYPosition; + + LTKCaptureDevice m_captureDevice; + + LTKScreenContext m_screenContext; + + int m_filterLength; + + int m_traceDimension; + + int m_quantizationStep; // quantization step for resampling + + string m_resamplingMethod; // type of resampling scheme to be used point based or length based + + float m_interPointDist; //distance between successive points + +public: + /** + * @name Constructors and Destructor + */ + // @{ + + + LTKPreprocessor(const LTKControlInfo& controlInfo); + + /** + * Copy Constructor + */ + + LTKPreprocessor(const LTKPreprocessor& preprocessor); + + /** + * Destructor + */ + + virtual ~LTKPreprocessor(); + + + /** + * @name Pre-processing Functions + */ + // @{ + + /** + * This function normalizes the size for a trace group. + * <p> If the width of the stroke set is more than the threshold, + * they are normalised by width and scale; otherwise they are traslated to the + * center if bounding box determined by scale. </p> + * + * @param traceGroup Object of LTKTraceGroup + * + * @return void + */ + + /** + * @name Getter Functions + */ + // @{ + + + /** + * The function returns the scale(width or height) of the trace group assumed after normalization. + * @param void + * + * @return The value of scale for coordinate axis. + */ + + + bool getPreserveAspectRatio() const; + + /** + * The function returns the scale(width or height) of the trace group assumed after normalization. + * @param void + * + * @return The value of scale for coordinate axis. + */ + + bool getPreserveRealtiveYPosition() const; + + /** + * The fucntion returns the size threshold that a trace group is required to have. + * @param void + * + * @return The size threshold that is pre-determined. + */ + + float getSizeThreshold() const; + + /** + * This function returns the loop threshold of a trace group. + * @param void + * + * @return The value of loop threshold. + */ + + float getLoopThreshold() const; + + /** + * This function returns the threshold below which aspect ratio will be maintained + * @param void + * + * @return Threshold below which aspect ratio will be maintained + */ + float getAspectRatioThreshold() const; + + /** + * This function returns the threshold used to detect dots + * @param void + * + * @return Threshold used to detect dots + */ + float getDotThreshold() const; + + /** + * This function returns the value of the m_quantizationStep variable of the preprocessor + * @param void + * + * @return the m_quantizationStep of preprocessor + */ + int getQuantizationStep() const; + + /** + * This function returns the resampling method being used by the preprocessor + * @param void + * + * @return the m_resamplingMethod value + */ + string getResamplingMethod() const; + + /** + * This function returns the value of the m_traceDimension variable of the preprocessor + * @param void + * + * @return the m_traceDimension; of preprocessor + */ + const int getTraceDimension() const; + + + /** + * This function returns the value of the m_filterLength variable of the preprocessor + * @param void + * + * @return the m_filterLength of preprocessor + */ + const int getFilterLength() const; + + /** + * This function returns the max y coord of the tracegroup given to the findingBoundingBox function + * @param void + * + * @return the max y coord of the tracegroup given to the findingBoundingBox function + */ + + const LTKCaptureDevice& getCaptureDevice() const; + + /** + * This function returns the max y coord of the tracegroup given to the findingBoundingBox function + * @param void + * + * @return the max y coord of the tracegroup given to the findingBoundingBox function + */ + + const LTKScreenContext& getScreenContext() const; + + /** + * @name Setter Functions + */ + // @{ + + + /** + * This function sets member variable preserve aspect ratio with the flag specified. + * @param flag can be true or false + * + * @return SUCCESS on successful set operation + */ + + void setPreserveAspectRatio(bool flag); + /** + * This function sets member variable preserve relative y position with the flag specified. + * @param flag can be true or false + * + * @return SUCCESS on successful set operation + */ + + void setPreserveRelativeYPosition(bool flag); + + /** + * This function sets the threshold value for a trace group. + * @param sizeThreshold This threshold determines what normalization has to be done for a trace group. + * + * @return SUCCESS on successful set operation + */ + + int setSizeThreshold(float sizeThreshold); + + /** + * This function sets the loop threshold if a trace group is curved. + * @param loopThreshold Threshold to determine whether trace is a closed curve or not. + * + * @return SUCCESS on successful set operation + */ + + int setLoopThreshold(float loopThreshold); + + /** + * This function sets threshold below which aspect ratio will be maintained after normalization + * @param aspectRatioThreshold Threshold below which aspect ratio will be maintained + * + * @return SUCCESS on successful set operation + */ + + int setAspectRatioThreshold(float aspectRatioThreshold); + + /** + * This function sets threshold to detect dots + * @param dotThreshold Threshold to detect dots + * + * @return SUCCESS on successful set operation + */ + + int setDotThreshold(float dotThreshold); + + /** + * This function sets filter length. + * @param fileterLength + * + * @return SUCCESS on successful set operation + */ + int setFilterLength (int filterLength); + + /** + * This method sets the length threshold to detect hooks. + * + * @param hookLengthThreshold1 - length threshold to detect hooks. + * @return SUCCESS on successful set operation + */ + int setHookLengthThreshold1(float hookLengthThreshold1); + + /** + * This method sets the length threshold to detect hooks + * + * @param hookLengthThreshold1 - length threshold to detect hooks. + * @return SUCCESS on successful set operation + */ + int setHookLengthThreshold2(float hookLengthThreshold2); + + /** + * This method sets the angle threshold to detect hooks + * + * @param hookAngleThreshold - angle threshold to detect hooks + * @return SUCCESS on successful set operation + */ + int setHookAngleThreshold(float hookAngleThreshold); + + /** + * This function returns the max y coord of the tracegroup given to the findingBoundingBox function + * @param void + * + * @return the max y coord of the tracegroup given to the findingBoundingBox function + */ + + void setCaptureDevice(const LTKCaptureDevice& captureDevice); + + /** + * This function returns the max y coord of the tracegroup given to the findingBoundingBox function + * @param void + * + * @return the max y coord of the tracegroup given to the findingBoundingBox function + */ + + void setScreenContext(const LTKScreenContext& screenContext); + + + /** + * This function sets the value of the m_quantizationStep variable of the preprocessor + * @param void + * + * @return SUCCESS on successful set operation + */ + int setQuantizationStep(int quantizationStep) ; + + /** + * This function sets the resampling method to be used by the preprocessor + * @param void + * + * @return SUCCESS on successful set operation + */ + int setResamplingMethod(const string& resamplingMethod); + + /** + * This function adds the function name and the Address of the function into the + * maping variable. + * @param void + * + * @returns 0 on success. + */ + + void initFunAddrMap(); + + /** + * This function takes the function name as an argument and returns the + * pointer to the function. + * @param function name + * + * @return the pointer to the function. + */ + + FN_PTR_PREPROCESSOR getPreprocptr(const string &funName); + + /** + * This function assigns the factory default values + * for the preprocessor attributes + * @param void + * + * @return 0 on success + */ + + void initPreprocFactoryDefaults(); + // @} + + /** + * This function is called on a trace group to normalize it's size. + * + * @param inTraceGroup input trace group that must be normalized. + * @param outTraceGroup The trace group whose traces are normalized. + * + * @return void + * + */ + + int normalizeSize(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup); + + + /** + * This function is called on a trace group to normalize its orientation + * + * @param inTraceGroup input trace group that must be normalized. + * @param outTraceGroup The trace group whose traces are normalized. + * + * @return void + * + */ + + int normalizeOrientation(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup); + + /** + * @param traceGroup Object of LTKTracegroup + * @param traceDimension Average number of points expected in a trace + * + * @return void + */ + + int duplicatePoints(const LTKTraceGroup& traceGroup, int traceDimension); + + /** + * This function shifts the origin of eack stroke to the centroid of the stroke + * + * @param inTraceGroup Trace group input, whose traces have to be centered. + * @param outTraceGroup The output trace group that whose traces are centered. + * + * @return void + */ + + int centerTraces(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup); + + /** + * This function dehooks the given tracegroup + * + * @param inTraceGroup Tracegroup which has to be dehooked + * @param outTraceGroup The dehooked tracegroup + * + * @return void + */ + + int dehookTraces(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup); + + /** + * This function removes consecutively repeating x, y coordinates (thinning) + * + * @param inTraceGroup trace group to be thinned + * @param outTraceGroup thinned trace group + * + * @return SUCCESS on successful thinning operation + */ + + int removeDuplicatePoints(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup); + + /** + * This function calculates the slopes of the strokes w.r.t maximum and minimum coordinates + * and reorders the strokes. + * + * @param inTraceGroup Object of LTKTraceGroup, whose traces have to be ordered. + * @param outTraceGroup The output trace group, whose traces are ordered. + * + * @return void + */ + + int orderTraces(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup); + + /** + * This function reorients the given stroke + * + * @param inTrace Trace which has to be reversed + * @param outTrace The reversed trace + * + * @return void + */ + + int reverseTrace(const LTKTrace& inTrace, LTKTrace& outTrace); + + /** + * This function takes trace by trace from a trace group and resamples the points in them + * according to the trace dimension. + * + * @param inTrace The input trace from trace group + * @param resamplePoints The ideal number of points to which the trace must be resampled. + * @param outTrace The output trace that has resampled points. + * + * @return void + */ + + int resampleTrace(const LTKTrace& inTrace,int resamplePoints, LTKTrace& outTrace); + + + + /** + * This function smoothens the incoming tracegroup using moving average technique + * + * @param inTraceGroup The input trace group + * @param filterLength is the number of points used for smoothening a single point + * @param outTraceGrouo The output tracegroup that has smoothened points. + * + * @return SUCCESS + */ + + int smoothenTraceGroup(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup); + + /** + * This method extracts the quantised Slope values from the input trace group. + * + * @param Input trace group, Quantised Slope Vector + * + * @return SUCCESS. + */ + + int getQuantisedSlope(const LTKTrace& trace, vector<int>& qSlopeVector); + + /** + * This method identify the dominant points in the trace group based on the quantised + * slope information. + * + * @param QSlopeVector,flexibility Index + * @return Dominant Points + */ + + int determineDominantPoints(const vector<int>& qSlopeVector, int flexibilityIndex, vector<int>& dominantPts); + + /** + * Computes the length of the given trace between two given point indices. + * + * @param trace - trace whose total/partial length is required. + * @param fromPoint - point from which the trace length has to be computed. + * @param toPoint - point to which the trace length has to be computed. + * + * @return total/partial length of the trace. + */ + + + // May define TRACE_BEGIN_POINT TRACE_END_POINT macros and let fromPoint and toPoint + //take these as default values + int computeTraceLength(const LTKTrace& trace, int fromPoint, int toPoint, float& outLength); + + int resampleTraceGroup(const LTKTraceGroup& inTraceGroup, + LTKTraceGroup& outTraceGroup + ); + + int setTraceDimension(int traceDimension); + + // @} + +private: + + /** + * This function calculates slope of 2 points. + * + * @param x1,x2,y1,y2 coordinates of 2 points + * + * @return Slope of two points. + */ + + float calculateSlope(float x1,float y1,float x2,float y2); + + /** + * This function calculates Euclidian distance between 2 points. + * + * @param x1,x2,y1,y2 Coordinates of two points. + * + * @return Euclidian Distance between two points. + */ + + float calculateEuclidDist(float x1,float x2,float y1,float y2); + + /** + * This method calculates the swept angle of the curve. + * + * @param Input trace + * @return Swept angle of the trace. + */ + + int calculateSweptAngle(const LTKTrace& trace, float& outSweptAngle); + + int readConfig(const string& cfgFilePath); + + bool isDot(const LTKTraceGroup& inTraceGroup); + +}; + +#endif //#ifndef __LTKPREPROCESSOR_H + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKPreprocessorInterface.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKPreprocessorInterface.h new file mode 100644 index 00000000..fb913100 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKPreprocessorInterface.h @@ -0,0 +1,213 @@ +/****************************************************************************** +* 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-10 15:23:21 +0530 (Thu, 10 Jul 2008) $ + * $Revision: 556 $ + * $Author: sharmnid $ + * + ************************************************************************/ +#ifndef __LTKPREPROCESSORINTERFACE_H +#define __LTKPREPROCESSORINTERFACE_H + +#include "LTKTraceGroup.h" + +class LTKPreprocessorInterface; + +typedef int (LTKPreprocessorInterface::*FN_PTR_PREPROCESSOR)(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup); + +class LTKPreprocessorInterface +{ + +public: + + /** + * This function normalizes the size for a trace group. + * <p> If the width of the stroke set is more than the threshold, + * they are normalised by width and scale; otherwise they are traslated to the + * center if bounding box determined by scale. </p> + * + * @param traceGroup Object of LTKTraceGroup + * + * @return void + */ + + /** + * @name Getter Functions + */ + // @{ + + /** + * The function get the function name as the argument and return the address of the + * function. + * @param funName + * + * @return address of the function. + */ + + virtual FN_PTR_PREPROCESSOR getPreprocptr(const string &funName) = 0; + + /** + * @name Setter Functions + */ + // @{ + + + virtual int normalizeSize(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup) = 0; + + /** + * This function is called on a trace group to normalize its orientation + * + * @param inTraceGroup input trace group that must be normalized. + * @param outTraceGroup The trace group whose traces are normalized. + * + * @return void + * + */ + + virtual int normalizeOrientation(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup) = 0; + + /** + * @param traceGroup Object of LTKTracegroup + * @param traceDimension Average number of points expected in a trace + * + * @return void + */ + + virtual int duplicatePoints(const LTKTraceGroup& traceGroup, int traceDimension) = 0; + + /** + * This function shifts the origin of eack stroke to the centroid of the stroke + * + * @param inTraceGroup Trace group input, whose traces have to be centered. + * @param outTraceGroup The output trace group that whose traces are centered. + * + * @return void + */ + + virtual int centerTraces(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup) = 0; + + /** + * This function dehooks the given tracegroup + * + * @param inTraceGroup Tracegroup which has to be dehooked + * @param outTraceGroup The dehooked tracegroup + * + * @return void + */ + + virtual int dehookTraces(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup) = 0; + + /** + * This function removes consecutively repeating x, y coordinates (thinning) + * + * @param inTraceGroup trace group to be thinned + * @param outTraceGroup thinned trace group + * + * @return SUCCESS on successful thinning operation + */ + + virtual int removeDuplicatePoints(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup) = 0; + + /** + * This function calculates the slopes of the strokes w.r.t maximum and minimum coordinates + * and reorders the strokes. + * + * @param inTraceGroup Object of LTKTraceGroup, whose traces have to be ordered. + * @param outTraceGroup The output trace group, whose traces are ordered. + * + * @return void + */ + + virtual int orderTraces(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup) = 0; + + /** + * This function reorients the given stroke + * + * @param inTrace Trace which has to be reversed + * @param outTrace The reversed trace + * + * @return void + */ + + virtual int reverseTrace(const LTKTrace& inTrace, LTKTrace& outTrace) = 0; + + /** + * This function takes trace by trace from a trace group and resamples the points in them + * according to the trace dimension. + * + * @param inTrace The input trace from trace group + * @param resamplePoints The ideal number of points to which the trace must be resampled. + * @param outTrace The output trace that has resampled points. + * + * @return void + */ + + virtual int resampleTrace(const LTKTrace& inTrace, int resamplePoint, LTKTrace& outTrace) = 0; + + + /** + * This function smoothens the incoming tracegroup using moving average technique + * + * @param inTraceGroup The input trace group + * @param filterLength is the number of points used for smoothening a single point + * @param outTraceGrouo The output tracegroup that has smoothened points. + * + * @return SUCCESS + */ + + virtual int smoothenTraceGroup(const LTKTraceGroup& inTraceGroup, LTKTraceGroup& outTraceGroup) = 0; + + virtual int resampleTraceGroup(const LTKTraceGroup& inTraceGroup, + LTKTraceGroup& outTraceGroup)=0; + virtual int getQuantisedSlope(const LTKTrace& trace, vector<int>& qSlopeVector) = 0; + + virtual int determineDominantPoints(const vector<int>& qSlopeVector, int flexibilityIndex, vector<int>& dominantPts) = 0; + + virtual void setCaptureDevice(const LTKCaptureDevice& captureDevice) = 0; + + virtual void setScreenContext(const LTKScreenContext& screenContext) = 0; + + virtual bool getPreserveAspectRatio()const = 0 ; + + virtual float getAspectRatioThreshold()const= 0 ; + + virtual bool getPreserveRealtiveYPosition()const = 0 ; + + virtual float getSizeThreshold()const =0 ; + + virtual float getDotThreshold()const = 0 ; + + virtual string getResamplingMethod()const = 0 ; + + virtual const int getTraceDimension()const = 0 ; + + virtual const int getFilterLength()const = 0 ; + + virtual ~LTKPreprocessorInterface(){}; + + +}; + +#endif + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKRecognitionContext.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKRecognitionContext.h new file mode 100644 index 00000000..cf1bcc62 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKRecognitionContext.h @@ -0,0 +1,329 @@ +/***************************************************************************************** +* 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 $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Definitions for Recognition Context Module + * + * CONTENTS: + * + * AUTHOR: Deepu V. + * + * DATE: February 21, 2005 + * CHANGE HISTORY: + * Author Date Description of change + * Thanigai 3-AUG-2005 Added default constructor and setWordRecoEngine + * methods. + * + * Deepu 30-AUG-2005 Replaced LTKWordRecoEngine with LTKWordRecognizer + * Changed the representation of m_recognitionFlags + * since there was a problem with dlls + ************************************************************************/ +#ifndef __LTKRECOGNITIONCONTEXT_H +#define __LTKRECOGNITIONCONTEXT_H + +#include "LTKTypes.h" +#include "LTKCaptureDevice.h" +#include "LTKScreenContext.h" + +class LTKTrace; +class LTKTraceGroup; +class LTKWordPreprocessor; +class LTKWordRecoResult; +class LTKWordRecognizer; +typedef vector<LTKTraceGroup> LTKTraceGroupVector; + +typedef vector<LTKWordRecoResult> LTKWordRecoResultVector; + + +/** + * @class LTKRecognitionContext This class holds the recognition context for a particular field. + * <p> + * LTKRecognitionContext specifies UI parameters (like Screen context, device context, segment info etc.) + * , application specific parameters (lexicon to be used, other language models) and recognition + * related configurations (number of results, confidence threshold etc)</p> + * + */ + + +class LTKRecognitionContext +{ +private: + float m_confidThreshold; //confidence threshold for the recognizer + + LTKCaptureDevice m_deviceContext; //the device context in which the ink is collected + + LTKTraceVector m_fieldInk; //the input ink to be recognized + + int m_numResults; //number of results that the recognizer will return + + vector< pair<string,int> > m_recognitionFlags; //recognition flags. + + stringStringMap m_languageModels; //the language models that contains dictionary name, grammar model etc. + + LTKScreenContext m_screenContext; //the screen context object + + LTKWordRecognizer* m_wordRecPtr; //the recognition engine + + LTKWordRecoResultVector m_results; //Results from the recognizer + + int m_nextBestResultIndex ; //this points to the next best result to be returned + + +public: + /** + * @name Constructors and Destructor + */ + + // @{ + + LTKRecognitionContext(); + + + LTKRecognitionContext(LTKWordRecognizer *wordRecPtr ); + + + int setWordRecoEngine(LTKWordRecognizer *wordRecPtr); + + ~LTKRecognitionContext(); + // @} + + /** + * @name Functions to add traces to the recognition context + */ + // @{ + + /** + * This function adds a trace to the recognition context for recognition + * @param trace is the trace to be added + * @return SUCCESS/FAILURE + */ + int addTrace (const LTKTrace& trace); + + /** + * This function adds a vector of tracegroup for recognition in the recognition context + * @param fieldInk is the ink to be added. + * @return SUCCESS/FAILURE + */ + + int addTraceGroups (const LTKTraceGroupVector& fieldInk); + + /** + * This function marks the beginning of a recognition unit of Ink. + * The recognition unit is determined based on the flag set in recognition flags + * @return SUCCESS/FAILURE + */ + + void beginRecoUnit ( ); + + /** + * This function clears all the recognition results + * @param void + * @return SUCCESS/FAILURE + */ + + //void clearRecognitionResult( ); + int clearRecognitionResult( ); + + /** + * This function marks the ending of a recognition unit of Ink. + * The recognition unit is determined based on the flag set in recognition flags + * @return SUCCESS/FAILURE + */ + + //void endRecoUnit ( ); + void endRecoUnit ( ); + + // @} + + /** + * @name get/set Functions + */ + // @{ + + /** + * This function returns a reference to internal Ink data. + * The recognition engine uses the reference to access the data + * @return const reference to vector of LTKTrace + */ + const LTKTraceVector& getAllInk () const; + + /** + * Returns the value of confidence threshold + * @return float confidence threshold value + */ + float getConfidThreshold () const; + + /** + * This function returns current device const. + * The recognition engine uses the reference to access the data + * @return const reference to device context object + */ + const LTKCaptureDevice& getDeviceContext ( ) const; + + /** + * This function retrieves flag indexed by string key from the map and returns the value + * @param key index of map + * @return value(integer) of the queried flag + */ + + //int getFlag (const string& key,int& value) const; + int getFlag (const string& key,int& outValue) const; + + /** + * This function returns the current language model indexed by the key + * @param key : the index + * @return value (string) of the queried language model + */ + //int getLanguageModel (string& key,string& value) const; + int getLanguageModel (const string& key,string& outValue) const; + + /** + * This function returns the next best results + * @param numResults : number of results to be retrieved. + * @param results[out] :Result vector returned + * @return SUCCESS/FAILURE + */ + int getNextBestResults (int numResults, + LTKWordRecoResultVector& outWordRecResults); + + + /** + * This function returns the number of results set in the recognition context. + * @return number of results + */ + int getNumResults () const; + + /** + * This function returns the screen context + * @return const reference to screen context + */ + const LTKScreenContext& getScreenContext ( ) const; + + + /** + * This function gives top result of word recognition + * @return const reference to screen context + */ + int getTopResult (LTKWordRecoResult& outTopResult); + + /** + * This function set the confidence threshold + * @param thresh : the threshold value to be set + * @return SUCCESS/FAILURE + */ + + //int setConfThreshold (float thresh); + int setConfidThreshold (float thresh); + + /** + * This function set the device context + * @param dc: the reference to be LTKDeviceContext to be set + * @return SUCCESS/FAILURE + */ + void setDeviceContext (const LTKCaptureDevice& dc); + + /** + * This function sets different flags + * @param key : name of the flag to be set + * @param value : value to be set + * @return SUCCESS/FAILURE + */ + //void setFlag (const string& key, int value); + int setFlag (const string& key, int value); + + /** + * This function sets language models + * @param property : name of the flag to be set + * @param value : value to be set + * @return SUCCESS/FAILURE + */ + + //void setLanguageModel (const string& property, const string& value); + int setLanguageModel (const string& property, const string& value) ; + + /** + * This function sets number of results required from the recognizer + * @param num : number of results + * @param value : value to be set + * @return SUCCESS/FAILURE + */ + int setNumResults (int numResults); + + /** + * This function sets the screen context object for the recognition + * @param sc : the screen context object to be set + * @return SUCCESS/FAILURE + */ + + //void setScreenContext (const LTKScreenContext& sc); + void setScreenContext (const LTKScreenContext& sc); + + // @} + + /** + * @name Recognition related functions + */ + + // @{ + /** + * This function is used by the recognizer to set the results back in the recognition context + * @param result : the LTKRecognitionResult object to be added + * @return SUCCESS/FAILURE + */ + + //void addRecognitionResult (const LTKWordRecoResult& result); + void addRecognitionResult (const LTKWordRecoResult& result); + + /** + * This function is the recogniz call from the application + * This calls the recognize method of the recognizer internally + * @return SUCCESS/FAILURE + */ + int recognize (); + // @} + + /** + * @name Misc + */ + + // @{ + + /** + * This function is used to reset the different components of recognition context + * @param resetParam : parameter that identifies the component to be reset + * @return SUCCESS/FAILURE + */ + int reset (int resetParam); + + + // @} + +}; + +#endif // #ifndef __LTKRECOGNITIONCONTEXT_H + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKRefCountedPtr.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKRefCountedPtr.h new file mode 100644 index 00000000..3b67c9ee --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKRefCountedPtr.h @@ -0,0 +1,225 @@ +/***************************************************************************************** +* 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. +*****************************************************************************************/ + +/************************************************************************ + * FILE DESCR: Definitions of Agglomerative Hierarchical Clustering module + * + * CONTENTS: + * + * + * AUTHOR: Bharath A + * + * DATE: December 14, 2007 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKREFCOUNTEDPTR_H +#define __LTKREFCOUNTEDPTR_H + +template <class TargetClass> +class LTKRefCountedPtr +{ + +private: + +//instance of this counter is maintained for each object +struct SharedCounter +{ + TargetClass* objPtr; //target object + int refCount; //count of current references to target object + + SharedCounter(TargetClass* ptr = NULL) + { + if(ptr!=NULL) + { + objPtr = ptr; + refCount = 1; + } + else + { + objPtr = NULL; + } + + } + +}* m_sharedCounterPtr; //pointer to common counter instance + + +public: +/********************************************************************************** +* AUTHOR : Bharath A +* DATE : 14-DEC-2007 +* NAME : LTKRefCountedPtr +* DESCRIPTION : Constructor to create a shared counter instance and point to a new object +* ARGUMENTS : newObj - new object that needs to be tracked +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + + //"explicit" keyword required to avoid construction from pointers of arbitrary type + explicit LTKRefCountedPtr(TargetClass* newObj = NULL) + { + if(newObj!=NULL) + { + //creating the shared counter for the new object + m_sharedCounterPtr = new SharedCounter(newObj); + + } + else + { + m_sharedCounterPtr = NULL; + } + } + +/********************************************************************************** +* AUTHOR : Bharath A +* DATE : 14-DEC-2007 +* NAME : LTKRefCountedPtr +* DESCRIPTION : Copy constructor +* ARGUMENTS : inObj - input object to get constructed from +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + LTKRefCountedPtr(const LTKRefCountedPtr& inObj) + { + m_sharedCounterPtr = inObj.m_sharedCounterPtr; + + if(m_sharedCounterPtr!=NULL) + { + //incrementing the number of current references to the input object + m_sharedCounterPtr->refCount = m_sharedCounterPtr->refCount + 1; + } + + } + +/********************************************************************************** +* AUTHOR : Bharath A +* DATE : 14-DEC-2007 +* NAME : operator= +* DESCRIPTION : Assignment operator overloading +* ARGUMENTS : inObj - input object to get assigned +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + LTKRefCountedPtr& operator=(const LTKRefCountedPtr& inObj) + { + if (this != &inObj) + { + if(m_sharedCounterPtr!=NULL) + { + //decrementing the number of references to the object poninted to + m_sharedCounterPtr->refCount = m_sharedCounterPtr->refCount - 1; + + //if there are no references to the object, delete the object + //and the shared counter + if(m_sharedCounterPtr->refCount == 0) + { + delete m_sharedCounterPtr->objPtr; + + delete m_sharedCounterPtr; + } + + m_sharedCounterPtr = NULL; + } + + //start pointing to the new object's shared counter + m_sharedCounterPtr = inObj.m_sharedCounterPtr; + + if(m_sharedCounterPtr!=NULL) + { + //incrementing the number of current references to the new object + m_sharedCounterPtr->refCount = m_sharedCounterPtr->refCount + 1; + } + + } + return *this; + } + +/********************************************************************************** +* AUTHOR : Bharath A +* DATE : 14-DEC-2007 +* NAME : operator* +* DESCRIPTION : Dereferencing operator overloading +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + TargetClass& operator*() const + { + return *m_sharedCounterPtr->objPtr; + } + +/********************************************************************************** +* AUTHOR : Bharath A +* DATE : 14-DEC-2007 +* NAME : operator-> +* DESCRIPTION : Arrow operator overloading +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + inline TargetClass* operator->() const + { + return m_sharedCounterPtr->objPtr; + } + +/********************************************************************************** +* AUTHOR : Bharath A +* DATE : 14-DEC-2007 +* NAME : ~LTKRefCountedPtr +* DESCRIPTION : Destructor +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + ~LTKRefCountedPtr() + { + if(m_sharedCounterPtr!=NULL) + { + //decrementing the nubmer of current references to the pointed to + m_sharedCounterPtr->refCount = m_sharedCounterPtr->refCount - 1; + + //if there are no references to the object, delete the object + if(m_sharedCounterPtr->refCount == 0) + { + delete m_sharedCounterPtr->objPtr; + delete m_sharedCounterPtr; + } + + m_sharedCounterPtr = NULL; + } + } + + }; + +#endif + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKScreenContext.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKScreenContext.h new file mode 100644 index 00000000..08374256 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKScreenContext.h @@ -0,0 +1,238 @@ +/****************************************************************************** +* 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-10 15:23:21 +0530 (Thu, 10 Jul 2008) $ + * $Revision: 556 $ + * $Author: sharmnid $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: Definition of LTKScreenContext which holds the co-ordinates of + * the writing area provided for the set of traces being sent for + * recognition + * + * CONTENTS: + * + * AUTHOR: Balaji Raghavan. + * + * DATE: Dec 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + * Deepu 01-MAR-2005 Added hLines and vLines to the class + * Also incorporated the accessor functions + ************************************************************************/ + +#ifndef __LTKSCREENCONTEXT_H +#define __LTKSCREENCONTEXT_H + +#include "LTKInc.h" +#include "LTKTypes.h" + + + /** + * @class LTKScreenContext + * <p> This class contains the co-ordinates of the writing area. </p> + */ + + +class LTKScreenContext +{ +private: + + float m_bboxLeft; // leftmost x-coord of the writing area + + float m_bboxBottom; // bottommost y-coord of the writing area + + float m_bboxRight; // rightmost x-coord of the writing area + + float m_bboxTop; // topmost y-coord of the writing area + + floatVector m_hLines; // Vector of horizontal reference lines + + floatVector m_vLines; // Vector of vertical reference lines + + +public: + + /** + * @name Constructors and Destructor + */ + // @{ + + /** + * Default Constructor + */ + + LTKScreenContext (); + + /** + * This constrcutor takes various paramaters about a writing area. + * @param bboxLeft Gets the left x co-ordinate of the writing area + * @param bboxBotton Gets the bottom y co-ordinate of the writing area + * @param bboxRight Gets the right x co-ordinate of the writing area + * @param bboxTop Gets the top y co-ordinate of the writing area + */ + + LTKScreenContext(float bboxLeft, float bboxBotton, float bboxRight, + float bboxTop); + + /** Destructor */ + + ~LTKScreenContext (); + + // @} + + /** + * @name Getter Functions + */ + // @{ + + /** + * This function returns the bottom left x co-ordinate of the writing area + * @param void + * + * @return Left x co-ordinate of the writing area. + */ + + float getBboxLeft() const; + + /** + * This function returns the bottom left y co-ordinate of the writing area + * @param void + * + * @return Bottom y co-ordinate of the writing area. + */ + + float getBboxBottom() const; + + /** + * This function returns the top right x co-ordinate of the writing area + * @param void + * + * @return Right x co-ordinate of the writing area. + */ + + float getBboxRight() const; + + /** + * This function returns the top right y co-ordinate of the writing area + * @param void + * + * @return Top y co-ordinate of the writing area. + */ + + float getBboxTop() const; + + /** + * This function returns the horizontal lines + * @param void + * + * @return const reference to vector of ordinates of horizontal lines + */ + + const floatVector& getAllHLines() const; + + /** + * This function returns the vertical lines + * @param void + * + * @return const reference to vector of abscissae of vertical lines + */ + + const floatVector& getAllVLines() const; + + // @} + + /** + * @name Setter Functions + */ + // @{ + + /** + * This function adds a horizontal line + * in the screen context + * @param ordinate of the horizontal line + * + * @return SUCCESS on successful set operation + */ + + int addHLine(float ordinate); + + /** + * This function adds a vertical line + * in the screen context + * @param abscissa of the horizontal line + * + * @return SUCCESS on successful set operation + */ + + int addVLine(float abscissa); + + /** + * This function sets the bottom left x co-ordinate of the writing area + * @param bboxLeft Left x co-ordinate of the writing area + * + * @return SUCCESS on successful set operation + */ + + int setBboxLeft(float bboxLeft); + + /** + * This function sets the bottom left y co-ordinate of the writing area + * @param bboxBottom Bottom y co-ordinate of the writing area + * + * @return SUCCESS on successful set operation + */ + + int setBboxBottom(float bboxBottom); + + /** + * This function sets the top right x co-ordinate of the writing area + * @param bboxRight Right x co-ordinate of the writing area + * + * @return SUCCESS on successful set operation + */ + + int setBboxRight(float bboxRight); + + /** + * This function sets the top right y co-ordinate of the writing area + * @param bboxTop Top y co-ordinate of the writing area + * + * @return SUCCESS on successful set operation + */ + + int setBboxTop(float bboxTop); + + // @} + +}; + +#endif + +//#ifndef __LTKSCREENCONTEXT_H +//#define __LTKSCREENCONTEXT_H + + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeFeatureMacros.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeFeatureMacros.h new file mode 100644 index 00000000..7d107dd1 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeFeatureMacros.h @@ -0,0 +1,26 @@ +/***************************************************************************************** +* 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. +*****************************************************************************************/ +#ifndef __LTKFEATUREEXTMACROS_H +#define __LTKFEATUREEXTMACROS_H + +class LTKShapeFeature; +#include "LTKRefCountedPtr.h" + +typedef LTKRefCountedPtr<LTKShapeFeature> LTKShapeFeaturePtr; +#endif diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoConfig.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoConfig.h new file mode 100644 index 00000000..1c9bc299 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoConfig.h @@ -0,0 +1,221 @@ +/***************************************************************************************** +* 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 $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Definition of LTKShapeRecoConfig which holds the configuration information read + * from the configuration files + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKSHAPERECOCONFIG_H +#define __LTKSHAPERECOCONFIG_H + +#include "LTKTypes.h" + +/** + * @class LTKShapeRecoConfig + * <p> This class contains data about the location of the configuration files which are to be + * loaded during the instanatiation of various shape recognizers. It is passed as an argument during + * the instantiation of a shape recognizer</p> + */ + +class LTKShapeRecoConfig +{ + +private: + + string m_lipiRoot; // root path of the lipi tool kit + + string m_shapeSet; // shapeset of the recognition problem + + string m_profile; // profile of the recognition problem + + string m_shapeRecognizerName; // logical name of the shape recognizer + + int m_numShapes; // number of shapes in the recognition problem + +public: + + /** + * @name Constructors and Destructor + */ + // @{ + + /** + * Default Constructor + */ + + LTKShapeRecoConfig(); + + /** + * This constructor takes various arguments which are used to intialize the members of + * this class during its instantiation. + * @param lipiRoot Root path of Lipi Toolkit + * @param shapeSet Shape set + * @param profile Profile name + * @param shapeRecongizerName Name of the shape recognizer + * @param numShapes number of shapes in the recognition problem + */ + + LTKShapeRecoConfig(const string& lipiRoot, const string& shapeSet, const string& profile, + const string& shapeRecognizerName, int numShapes); + + /** + * Destructor + */ + + ~LTKShapeRecoConfig(); + + // @} + + /** + * @name Methods + */ + + // @{ + + /** + * This function reads the configuration information from the config files + * @param configFile - full path of the main configuration file + * + * @return SUCCESS on successful read operation + */ + + int readConfigInfo(const string& configFile); + + // @} + + /** + * @name Getter Functions + */ + // @{ + + /** + * This function returns the Lipi Root + * @param void + * + * @return Lipi Root. + */ + + const string& getLipiRoot(); + + /** + * This function returns the Shape Set Directory name + * @param void + * + * @return Shape Set Directory name. + */ + + const string& getShapeSet(); + + /** + * This function returns the Profile Directory name + * @param void + * + * @return Profile Directory name. + */ + + const string& getProfile(); + + /** + * This function returns the shape recognizer name + * @param void + * + * @return shape recognizer name. + */ + + const string& getShapeRecognizerName(); + + /** + * This function returns the number of shapes in the recognition problem + * @param void + * + * @return number of shapes in the recognition problem. + */ + + int getNumShapes(); + + // @} + + /** + * @name Setter Functions + */ + + // @{ + + /** + * This function sets the Lipi Root Path + * @param lipiRootStr Lipi Root Path + */ + + int setLipiRoot(const string& lipiRootStr); + + /** + * This function sets the Shape Set Directory name + * @param shapeSetStr Shape Set Directory name + */ + + int setShapeSet(const string& shapeSetStr); + + /** + * This function sets the Profile Directory name + * @param profileStr Profile Directory name + */ + + int setProfile(const string& profileStr); + + /** + * This function sets shape recognizer name + * @param shapeRecognizerName shape recognizer name + */ + + int setShapeRecognizerName(const string& shapeRecognizerName); + + /** + * This function sets number of shapes in the recognition problem + * @param numShapes number of shapes in the recognition problem + */ + + int setNumShapes(int numShapes); + + // @} + +}; + +#endif + +//#ifndef __LTKSHAPERECOCONFIG_H +//#define __LTKSHAPERECOCONFIG_H + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoEngine.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoEngine.h new file mode 100644 index 00000000..c33b727b --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoEngine.h @@ -0,0 +1,178 @@ +/***************************************************************************************** +* 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 $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: Definition of LTKShapeRecoEngine which has the interface to the shape recognition engine + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKShapeRecoEngine_H +#define __LTKShapeRecoEngine_H + +#include "LTKShapeRecognizer.h" + +#include "LTKTraceGroup.h" + +#include "LTKShapeRecoResult.h" + +#include "LTKScreenContext.h" + +#include "LTKCaptureDevice.h" + +/** + * @class LTKShapeRecoEngine + * <p> This class provides the interface to the Shape Recognition Engine. + * The required shape recognizer is instantiated dynamically and its corresponding + * recognize functions are called</p> + */ + +class LTKShapeRecoEngine +{ + +private: + + LTKShapeRecognizer* m_shapeRecognizer; // a pointer to a derived class of LTKShapeRecognizer + + +public: + + /** + * @name Constructors and Destructor + */ + // @{ + + /** + * Default Constructor + */ + + LTKShapeRecoEngine(); + + /** + * Destructor + */ + + ~LTKShapeRecoEngine(); + + // @} + + + /** + * @name Methods + */ + + // @{ + + /** + * This method loads a shape recognizer with a particular profile for a particular + * recognition problem by using the information in the configuration file and the lipi tool + * kit root path passed to it as arguments + * @param configFileName The configuration file to load a shape recognizer + * @param lipiRoot root path of the lipi tool kit + */ + + int initializeShapeRecoEngine(const string& configFileName, string lipiRoot = ""); + + /** + * This method calls the loadTrainingData method of the instantiated shape recognizer. + */ + + int loadTrainingData(); + + /** + * This method calls the recognize method of the instantiated shape recognizer. + * + * @param traceGroupObj The co-ordinates of the shape which is to be recognized + * @param uiParams Contains information about the input field like whether it is boxed input + * or continuous writing + * @param deviceParams Contains information about the device like its sampling rate + * @param shapeSubSet A subset of the entire set of shapes 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 + */ + + int recognize(const LTKTraceGroup& traceGroup, const LTKScreenContext& screenContext, + const LTKCaptureDevice& captureDevice, const vector<bool>& shapeSubSet, float confThreshold, + int numChoices, vector<LTKShapeRecoResult>& results); + + /** + * 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 + */ + + int getShapeRecoConfidences(const LTKTraceGroup& traceGroup, + const LTKScreenContext& screenContext,const LTKCaptureDevice& captureDevice, + const vector<int>& shapeIds, vector<float>& shapeRecoConfidences); + + /** + * This method calls the learn method of the instantiated shape recognizer. + * + * @param prototype The sample to be used for adaptation + * @param shapeId The shape id of the added prototype + * @param uiParams Contains information about the input field like whether it is boxed input + * or continuous writing + * @param deviceParams Contains information about the device like its sampling rate + */ + + int learn(const LTKTraceGroup& prototype, int shapeId, const LTKScreenContext& screenContext, + const LTKCaptureDevice& captureDevice); + + /** + * This method calls the train method of the instantiated shape recognizer. + * @param trainingList The name of the file containing the listing of files to be used for + * training each of the shapes. + */ + + int train(const string& trainingList); + + // @} + +}; + +#endif + +//#ifndef __LTKShapeRecoEngine_H +//#define __LTKShapeRecoEngine_H + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoResult.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoResult.h new file mode 100644 index 00000000..7dc74129 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoResult.h @@ -0,0 +1,142 @@ +/***************************************************************************************** +* 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 $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Definition of LTKShapeRecoResult which holds the recognition results of the + * shape recognition engine + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKSHAPERECORESULT_H +#define __LTKSHAPERECORESULT_H + + +/** + * @class LTKShapeRecoResult + * <p> This class is used to return recognition result back to the application program. + * It contains a shapeId and the confidence that the shape with this Id is the true shape + * of the input sample. </p> + */ +class LTKShapeRecoResult +{ + +private: + + int m_shapeId; // shape id of the recognition result + + float m_confidence; // corresponding confidence of recognition + +public: + + /** + * @name Constructors and Destructor + */ + + // @{ + + /** + * Default Constructor + */ + + LTKShapeRecoResult(); + + /** + * This constrcutor takes two paramaters. + * @param shapeId shape Id of the shape + * @param confidence Confidence that this shape is the true shape of input sample + */ + + LTKShapeRecoResult(int shapeId, float confidence); + + /** Destructor */ + + ~LTKShapeRecoResult(); + + // @} + + /** + * @name Getter Functions + */ + // @{ + + /** + * This function returns the shape Id of the result + * @param void + * + * @return shape Id of the result. + */ + + int getShapeId() const; + + /** + * This function returns the Confidence of the result + * @param void + * + * @return Confidence of the result. + */ + + float getConfidence() const; + + // @} + + /** + * @name Setter Functions + */ + + // @{ + + /** + * This function sets shape Id of the result + * @param shapeId Identification tag of the shape + */ + + int setShapeId(int shapeId); + + /** + * This function sets confidence of the recognized shape + * @param confidence Confidence value that the recognized shape is the true shape + */ + + int setConfidence(float confidence); + + // @} + +}; + +#endif + +//#ifndef __LTKSHAPERECORESULT_H +//#define __LTKSHAPERECORESULT_H + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoUtil.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoUtil.h new file mode 100644 index 00000000..9a4c3776 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecoUtil.h @@ -0,0 +1,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 diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecognizer.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecognizer.h new file mode 100644 index 00000000..7938b1f4 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKShapeRecognizer.h @@ -0,0 +1,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 + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTrace.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTrace.h new file mode 100644 index 00000000..f114cd7a --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTrace.h @@ -0,0 +1,304 @@ +/****************************************************************************** +* 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: Definition of LTKTrace which holds series of points from a pen down event to the next + * immediate pen up event + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + * Thanigai 09-AUG-2005 Added emptyTrace function to empty the trace + ************************************************************************/ + +#ifndef __LTKTRACE_H +#define __LTKTRACE_H + +#include "LTKTypes.h" +#include "LTKTraceFormat.h" + +class LTKTraceFormat; + +/** @defgroup Common_Classes Common classes +*/ + +/** +* @ingroup Common_Classes +*/ + +/** @brief Stores contiguous series of coordinates for one stroke. + * @class LTKTrace + * This class contains contiguous series of coordinates for one stroke. + * All channel values are stored internally as float. Hence the coordinates to be + * passed to LTKTrace should be first converted to "float" type. + */ + +class LTKTrace +{ + +private: + + vector<floatVector> m_traceChannels;//values of channels which make up the trace + + LTKTraceFormat m_traceFormat; + + +public: + + /** + * @name Constructors and Destructor + */ + //@{ + + /** + * Default Constructor + */ + + LTKTrace(); + + /** + * This constructor initialises a vector of channel values with a vector of float. + * + * @param allChannelValues A vector of float that contains contiguous channel values + * @param channelFormat An object of LTKTraceFormat that provides information about + * the channel positions. + */ + + LTKTrace(const floatVector& allChannelsVec, const LTKTraceFormat& channelformat); + + /** + * This constructor initialises a trace according to the specified trace format + * + * @param channelFormat An object of LTKTraceFormat that provides information about + * the channel positions + */ + + LTKTrace(const LTKTraceFormat& channelformat); + + /** + * Copy Constructor + */ + + LTKTrace(const LTKTrace& trace); + + /** + * Destructor + */ + + virtual ~LTKTrace(); + //@} + + /** + * @name Assignment operator + */ + //@{ + + /** + * Assignment operator + * @param traceObj The object to be copied by assignment + * + * @return LTKTrace object + */ + + LTKTrace& operator=(const LTKTrace& trace); + //@} + + /** + * @name Getter Functions + */ + //@{ + + /** + * This function returns the number of points that a stroke contains. + * Number of points is obtained by dividing the total number of contiguous channel values + * with the number of channels in trace format. + * + * @param void + * + * @return number of points in trace are returned. + * + */ + + int getNumberOfPoints() const; + + /** + * This method returns a specific point in a stroke. + * @param pointIndex The point index at which channel values are desired. + * + * @return A vector of float that contains channel values of a desired point. + * + */ + + int getPointAt(int pointIndex, floatVector& outPointCoordinates) const; + + /** + * This method returns vector of float that contains all values + * of a specific channel in the stroke. + * + * @param channelName The name of the channel, whose coordinates are required. + * + * @return A vector of float that contains all values of a desired channel. + */ + + int getChannelValues(const string& channelName, floatVector& outChannelValues) const; + + /** + * This method returns vector of float that contains all values + * a channel at a specific position. + * + * @param channelIndex Index of the channel,at which all coordinates are required. + * + * @return A vector of float that contains all values of a desired channel + */ + + int getChannelValues(int channelIndex, floatVector& outChannelValues) const; + + /** + * This method returns a channel value at a specific point. + * + * @param Name of the channel whose value is required. + * @param the point number at which a channel's value is required. + * + * @return channel value at the specified point. This is a float. + * + */ + + int getChannelValueAt(const string& channelName, int pointIndex, + float& outValue) const; + + + + //@} + + /** + * @name SetFunctions + */ + // @{ + + /** + * This method reassigns the values of the channel specified. The size of the + * vector is expected to be same as that of the current channel size. + * + * @param channelName Name of the channel + * @param channelValues Vector that holds the new channel values + * + * + * @return errorCode + * + */ + + int reassignChannelValues(const string& channelName, + const floatVector& channelValues); + + /** + * This method reassigns the values of all the channels. The number of rows + * in the input 2D vector must be equal to the current number of channels with + * each row having the same length. And this assumes one-to-one correspondence + * with the channel vector. + * + * @param allChannelValues new values of all the channels + * + * @return errorCode + * + */ + int setAllChannelValues(const float2DVector& allChannelValues); + + + /** + * This method adds a point of coordinates to the existing set of points, + * of a trace. + * + * @param pointVec vector of coordinates of a point. + * + * @return void + * + */ + int addPoint(const floatVector& pointVec); + + + /** + * This function adds channel values of a new channel. + * + * @param channelValuesVec The channel values of the new channel. + * @param channelName The new channel to be added. + * + * @return void + */ + + int addChannel(const floatVector &channelValuesVec,const LTKChannel& channel); + + /** + * This function empties the trace + * + * @param + * + * @return int + */ + + void emptyTrace(); + + /** + * Returns true if the data vector is empty + * + * @param + * + * @return bool + */ + + bool isEmpty() const; + + + /** + * Getter on the current trace format + * + * @param + * + * @return const LTKTraceFormat& + */ + + const LTKTraceFormat& getTraceFormat() const; + + + int setChannelValues(const string& channelName, + const floatVector &inputChannelValuesVec); + //@} + + + +}; + +#endif + +//#ifndef __LTKTRACE_H +//#define __LTKTRACE_H + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTraceFormat.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTraceFormat.h new file mode 100644 index 00000000..26901b05 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTraceFormat.h @@ -0,0 +1,214 @@ +/****************************************************************************** +* 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: Definition of LTKTraceFormat which holds the information about the type and number of + * channel data available at each pen point + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKTRACEFORMAT_H +#define __LTKTRACEFORMAT_H + +#include "LTKTypes.h" + +class LTKChannel; + +/** +* @ingroup Common_Classes +*/ + +/** @brief Contains the format of channels in which ink coordinates are stored. + * @class LTKTraceFormat + * This class contains the format of channels in which ink coordinates are stored. + * Contains a vector of LTKChannel objects. + */ + +class LTKTraceFormat +{ +private: + + LTKChannelVector m_channelVector; //group of channels defining the trace format + +public: + + /** + * @name Constructor and Destructors + */ + //@{ + + /** + * Default Constructor. + * Default channels are X and Y. + * Therfore contains LTKChannle objects for X and Y channels. + */ + + LTKTraceFormat(); + + /** + * Takes a vector of LTKChannel objects. vector of these objects + * have to be first constructed outside and then passed to constructor. + */ + + LTKTraceFormat(const LTKChannelVector& channelsVec); + + /** + * Copy Constructor + */ + + LTKTraceFormat(const LTKTraceFormat& traceFormat); + + /** + * Destructor + */ + + ~LTKTraceFormat(); + + //@} + + /** + * @name Assignment operator + */ + //@{ + + /** + * Assignment operator + * @param traceFormatObj The object to be copied by assignment + * + * @return LTKTraceFormat object + */ + + LTKTraceFormat& operator=(const LTKTraceFormat& traceFormat); + //@} + + /** + * @name Getter Functions + */ + //@{ + + /** + * This method returns the position at which a channel coordinate is stored + * in a point. + * + * @param channelName + * + * @param returnIndex + * + * @return SUCCESS or FAILURE + * + */ + + int getChannelIndex(const string& channelName, int& outReturnIndex) const ; + + /** + * This method returns the number of channels for which positions of + * electronic pen are captured. + * + * @param void + * + * @return number of channels + */ + + int getNumChannels() const ; + + /** + * This method returns the name of a channel at a particular Index. + * + * @param index The index at which a channel name is required + * + * @param channelName A string passed by reference that holds the name of the + * channel at the specified index + * + * @return SUCCESS or ECHANNEL_INDEX_OUT_OF_BOUND. + */ + + int getChannelName(int index, string& outChannelName) const ; + + /** + * This method is used to know the regular channels that are present in + * trace format. + * + * @param void + * + * @return A vector of channel names that are regular + */ + + stringVector getRegularChannelNames() const ; + + /** + * This method is used to know all channels that are present in trace format + * + * @param void + * + * @return A vector of all channel names + */ + + stringVector getAllChannelNames() const ; + //@} + + /** + * @name Setter Functions + */ + //@{ + + /** + * This method sets channel format if a different ordering of channels is required. + * @param A vector of LTKChannel objects + * + * @return The channels of the previous format used. + */ + + void setChannelFormat(const LTKChannelVector& channelFormatVec); + + /** + * This method is used to add a channel to the trace format + * @param LTKChannel object that contains details of the channel to be added + * + * @return ERROR + */ + + int addChannel(const LTKChannel& channel); + + //@} + +}; + +#endif + +//#ifndef __LTKTRACEFORMAT_H +//#define __LTKTRACEFORMAT_H + + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTraceGroup.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTraceGroup.h new file mode 100644 index 00000000..e96b4a63 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTraceGroup.h @@ -0,0 +1,294 @@ +/****************************************************************************** +* 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: Definition of LTKTraceGroup which holds a sequence of LTKTrace + * type objects + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + * Deepu V. March 7,2005 Added new assignment operator + * LTKTraceGroup (const LTKTrace& trace) + * and copy constructor + * LTKTraceGroup& operator = (const LTKTrace& trace) + * Thanigai 09-AUG-2005 Added a function to empty the trace group + *****************************************************************************/ + +#ifndef __LTKTRACEGROUP_H +#define __LTKTRACEGROUP_H + +#include "LTKTypes.h" + +class LTKTrace; + +/** +* @ingroup Common_Classes +*/ + +/** @brief Contains set of traces that have similar characteristic. + * @class LTKTraceGroup + * This class contains set of traces that have similar characteristic. + * Trace objects should be constructed and a vector that contains trace objects + * should be passed to the constructor of the class. + * + */ + +class LTKTraceGroup +{ + +private: + + float m_xScaleFactor; //scale factor of the x channel + + float m_yScaleFactor; //scale factor of the y channel + + LTKTraceVector m_traceVector; //traces forming the trace group + +public: + + /** + * @name Constructors and Destructor + */ + // @{ + + /** + * Default constructor. + */ + + + LTKTraceGroup (); + + /** + * This constructor takes a vector of LTKTrace objects. + */ + + LTKTraceGroup(const LTKTraceVector& inTraceVector, + float xScaleFactor=1.0, float yScaleFactor=1.0); + + /** + * Copy Constructor. + */ + + LTKTraceGroup (const LTKTraceGroup& traceGroup); + + /** + * Constructor makes a Trace group with a single trace + */ + + LTKTraceGroup (const LTKTrace& trace, float xScaleFactor=1.0, + float yScaleFactor=1.0); + + /** + * Destructor + */ + + ~LTKTraceGroup (); + //@} + + /** + * @name Assignment operartor. + */ + //@{ + + /** + * Assignment operator + * @param traceGroupObj The object to be copied by assignment + * + * @return LTKTraceGroup object + */ + + LTKTraceGroup& operator = (const LTKTraceGroup& traceGroup); + + /** + * Assignment operator + * @param trace The trace object to be copied by assignment + * + * @return LTKTraceGroup object + */ + + LTKTraceGroup& operator = (const LTKTrace& trace); + + //@} + + /** + * @name Getter Functions + */ + //@{ + + /** + * This function returns all traces that are present in the trace group. + * + * @param void + * + * @return Returns reference to vector of LTKTrace objects, that form a trace group. + * + */ + + const LTKTraceVector& getAllTraces () const; + + + /** + * This function gives a trace at a specified index in a trace group. + * + * @param traceIndex index of a trace in trace group + * + * @return Reference to LTKTrace object + */ + + int getTraceAt (int traceIndex, LTKTrace& outTrace) const; + + /** + * This fucntion returns the number of traces present in trace group. + * + * @param void + * + * @return Number of traces present in trace group. + * + */ + + int getNumTraces () const; + + float getXScaleFactor() const; + float getYScaleFactor() const; + + //@} + + /** + * Setter Fucntions + */ + //@{ + + /** + * This function is used to add traces to a trace group object. + * + * @param traceObj trace object that has to be added to trace group. + * + * @return void + * + */ + + int addTrace (const LTKTrace& trace); + + /** + * This function replaces vector of all traces in a trace group with the + * new traces vector. + * + * @param tracesVector The new traces which to have accessed. + * + * @return void + */ + + int setAllTraces (const LTKTraceVector& tracesVec, float xScaleFactor=1.0, + float yScaleFactor=1.0); + + /** + * This function empties the tracevector + * + * @param void + * + * @return int + */ + + void emptyAllTraces(); + /** + * This function calculates the maximum and minimum of coordinates in a trace group. + * + * @param xMin reference to minimum value of x channel + * + * @param yMin reference to minimum value of y channel + * + * @param xMax reference to maximum value of x channel + * + * @param yMax reference to maximum value of y channel + * + * @return int error code + */ + + int getBoundingBox(float& outXMin,float& outYMin,float& outXMax,float& outYMax) const; + + + + /** + * Scales the tracegroup according to the x and y scale factors taking into account the current scale factors. + * After scaling, the tracegroup is translated in order to preserve the "cornerToPreserve". + * + * @param xScaleFactor factor by which x dimension has to be scaled + * @param yScaleFactor factor by which y dimension has to be scaled + * @param cornerToPreserve corner to be retained after scaling + * @return int error code + */ + + int scale(float xScaleFactor,float yScaleFactor,TGCORNER cornerToPreserve); + + + + /** + * Translates the tracegroup so that the "referenceCorner" is moved to (x,y) + * + * + * @param x x value of the point to which referenceCorner has to be moved + * @param y y value of the point to which referenceCorner has to be moved + * @param referenceCorner - the reference corner in the tracegroup that has to be moved to (x,y) + * @return int error code + */ + + int translateTo(float x,float y,TGCORNER referenceCorner); + + + /** + * Scales the tracegroup according to the x and y scale factors. + * After scaling, the "referenceCorner" of the tracegroup is translated to + *(translateToX,translateToY) + * + * @param xScaleFactor factor by which x dimension has to be scaled + * @param yScaleFactor factor by which y dimension has to be scaled + * @param referenceCorner corner to be retained after scaling and moved to (translateToX,translateToY) + * @return int error code + */ + + int affineTransform(float xScaleFactor,float yScaleFactor,float translateToX, + float translateToY,TGCORNER referenceCorner); + + bool containsAnyEmptyTrace() const; + + + //@} + +}; + +#endif + +//#ifndef __LTKTRACEGROUP_H +//#define __LTKTRACEGROUP_H + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTypes.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTypes.h new file mode 100644 index 00000000..6c10ccc2 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKTypes.h @@ -0,0 +1,126 @@ +/***************************************************************************************** +* 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:33:34 +0530 (Fri, 18 Jul 2008) $ + * $Revision: 564 $ + * $Author: sharmnid $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Contains list of standard type definitions + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKTYPES_H +#define __LTKTYPES_H + +#include "LTKInc.h" +//class LTKShapeFeature; +class LTKChannel; +class LTKTrace; + +typedef vector<bool> boolVector; +typedef vector<int> intVector; +typedef vector<float> floatVector; +typedef vector<double> doubleVector; +typedef vector<string> stringVector; +typedef vector<intVector> int2DVector; +typedef vector< floatVector> float2DVector; +typedef vector<doubleVector> double2DVector; +typedef vector<float2DVector > float3DVector; +typedef map<string, string> stringStringMap; +typedef float (*distPointer)(const vector<float>&,const vector<float>&); +typedef int (*reduceFunctionPointer)(const vector<vector<float> >&,vector<vector<float> >&); +typedef vector <float> Features; +typedef vector <Features> Character; +typedef map<string,int> stringIntMap; +//typedef double (*FN_PTR_DELETE_SHAPE_FTR_PTR)(LTKShapeFeature*); +typedef vector<LTKChannel> LTKChannelVector; +typedef vector<LTKTrace> LTKTraceVector; +typedef pair<string,string> stringStringPair; +typedef map<int,int> intIntMap; + +typedef struct ModuleRefCount +{ + vector<void*> vecRecoHandles; + void* modHandle; + int iRefCount; +} MODULEREFCOUNT; + + +/* @enum ELTKDataType This enumerator stores the data type of a channel. + * All channel values are stored in memory as float. + */ + +enum ELTKDataType +{ + DT_BOOL, DT_SHORT, DT_INT, DT_LONG, DT_FLOAT, DT_DOUBLE, DT_NULL +}; + +enum ELTKTraceGroupStatistics +{ + TG_MAX, TG_MIN, TG_AVG +}; + +struct LTKControlInfo +{ + string projectName; + string profileName; + string cfgFileName; + string cfgFilePath; + string lipiRoot; + string lipiLib; + string toolkitVersion; + + // constructor + LTKControlInfo(): + projectName(""), + profileName(""), + cfgFileName(""), + cfgFilePath(""), + lipiRoot(""), + lipiLib(""), + toolkitVersion("") + { + } + +}; + +//Enumerator to indicate corner point of a tracegroup + enum TGCORNER + { + XMIN_YMIN, + XMIN_YMAX, + XMAX_YMIN, + XMAX_YMAX +}; + +#endif //#ifndef __LTKTYPES_H + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKWordRecoConfig.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKWordRecoConfig.h new file mode 100644 index 00000000..535b4c2a --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKWordRecoConfig.h @@ -0,0 +1,203 @@ +/***************************************************************************************** +* 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 $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: Definition of LTKWordRecoConfig holds the config data for + * the recognizer at the time of loading. + * + * CONTENTS: + * + * AUTHOR: Mudit Agrawal + * + * DATE: Mar 2, 2005 + * CHANGE HISTORY: + * Author Date Description of change + * Deepu 24-MAR-2005 Added getGrammarPath + * + ************************************************************************/ + +#ifndef __LTKWORDRECOCONFIG_H +#define __LTKWORDRECOCONFIG_H + +#include "LTKInc.h" +#include "LTKTypes.h" + +/** +* @class LTKWordRecoConfig +* <p> This class contains the config data for the recognizer at the time of loading </p> +*/ + +class LTKWordRecoConfig +{ +private: + string m_classifierName; //name of the classifier to be loaded + + string m_dictionaryPath; //path where dictionaries are present + + string m_grammarPath; //path where grammar is present + + string m_lipiRoot; //specifies the lipi root directory + + string m_problemName; //specifies the logical name for the problem of recognition. e.g. devanagari-word-recognition + + string m_profile; //refers to main.cfg. This in turn refers to word.cfg and profile.cfg + + string m_script; //script that is to be recognized + +public: + /** + * @name Constructors and Destructor + */ + // @{ + + /** + * Default Constructor + */ + + LTKWordRecoConfig(); + + /** + * This constrcutor takes one paramater about the recognizer + * @param lipiRoot + */ + + LTKWordRecoConfig(const string& lipiRoot); + + + /** Destructor */ + + ~LTKWordRecoConfig(); + + // @} + + /** + * @name Getter Functions + */ + // @{ + + /** + * This function returns the classifier name + * @param void + * + * @return classifier name + */ + + string getClassifierName() const; + + /** + * This function returns the Dictionary Path + * @param void + * + * @return Dictionary Path + */ + + string getDictionaryPath() const; + + /** + * This function returns the Grammar Path + * @param void + * + * @return Grammar Path + */ + + string getGrammarPath() const; + + /** + * This function returns the lipi root + * @param void + * + * @return lipi root + */ + + string getLipiRoot() const; + + /** + * This function returns the profile + * @param void + * + * @return profile + */ + + string getProfile() const; + + /** + * This function returns the script + * @param void + * + * @return script name + */ + + string getScript() const; + + /** + * This function returns the problem Name + * @param void + * + * @return problem Name + */ + + string getProblemName() const; + + /** + * @name Setter Functions + */ + // @{ + + /** + * This function reads the main config file and inturn other config files also (defined in main.cfg) + * + * @param path of the main config file + * + * @return SUCCESS on successful read operation of all config files + */ + + int readConfigFile(const string& configFileName); + + /** + * @name Setter Functions + */ + // @{ + + /** + * This function sets the lipi root + * + * @param lipi root + * + * @return SUCCESS on successful set operation + */ + + int setLipiRoot(const string& lipiRoot); + + + +}; + + +#endif + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKWordRecoResult.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKWordRecoResult.h new file mode 100644 index 00000000..3d54d6c2 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKWordRecoResult.h @@ -0,0 +1,128 @@ +/***************************************************************************************** +* 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 $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: The word recognition result class + * + * CONTENTS: + * + * AUTHOR: Deepu V. + * + * DATE: March 10, 2005 + * CHANGE HISTORY: + * Author Date Description of change + * Deepu V. 23-Aug-05 Added update word recognition result method + ************************************************************************/ +#ifndef __LTKWORDRECORESULT_H +#define __LTKWORDRECORESULT_H + +#include "LTKTypes.h" + +/** +* @class LTKWordFeatureExtractor +* <p> This is an abstract class. This contains the interface definitions of a wordrecognizer</p> +*/ + +class LTKWordRecoResult +{ +private: + + vector<unsigned short> m_word; //The result word as unicode string + + float m_confidence; //confidence returned by the recognizer for this + + +public: + /** + * @name Constructors and Destructor + */ + // @{ + + /** + * Default Constructor + */ + LTKWordRecoResult(); + + /** + * Constructor that takes two arguements + */ + + //LTKWordRecoResult(const vector< unsigned short >& word, float confidence); + LTKWordRecoResult(const vector< unsigned short >& word, float confidence); + + /** + * Destructor + */ + virtual ~LTKWordRecoResult(); + // @} + + /** + * This method adds to the existing word recognition result + * with a new symbol + * @param newSymbol - This will be appended to the existing word + * @param confidence - confidence of the new symbol, will be added to existing confidence + * @return SUCCESS/FAILURE + */ + int updateWordRecoResult( unsigned short newSymbol, float confidence); + + /** + * This method sets the word recognition result + * @param word The result + * @param confidence The result + * @return SUCCESS/FAILURE + */ + + //int setWordRecoResult(const vector< unsigned short >& word, float confidence); + int setWordRecoResult(const vector< unsigned short >& word, float confidence); + + /** + * This method gets the word recognition result + * @param void + * @return the unicode string + */ + const vector<unsigned short>& getResultWord() const; + + /** + * This method gets the confidence of the result + * @param void + * @return confidence value + */ + float getResultConfidence() const; + + /** + * This method sets the confidence of the result + * @param float value of confidence + * @return SUCCESS if completed successfully + */ + int setResultConfidence(float confidence); + +}; + +#endif //#ifndef __LTKWORDRECORESULT_H + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKWordRecognizer.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKWordRecognizer.h new file mode 100644 index 00000000..0322b79c --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/LTKWordRecognizer.h @@ -0,0 +1,143 @@ +/***************************************************************************************** +* 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-10 15:23:21 +0530 (Thu, 10 Jul 2008) $ + * $Revision: 556 $ + * $Author: sharmnid $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: The abstract class for a word recognizer + * + * CONTENTS: + * + * AUTHOR: Deepu V. + * + * DATE: March 10, 2005 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LTKWORDRECOGNIZER_H +#define __LTKWORDRECOGNIZER_H + +#include "LTKTypes.h" + +#include "LTKInc.h" + +#include "LTKTraceGroup.h" + +class LTKRecognitionContext; +/** +* @class LTKWordFeatureExtractor +* <p> This is an abstract class. This contains the interface definitions of a wordrecognizer</p> +*/ + +class LTKWordRecognizer +{ +protected: + const string m_wordRecognizerName; // name of the word recognizer class deriving from the LTKShapeRecognizer class + +public: + /** + * @name Constructors and Destructor + */ + // @{ + + /** + * Default Constructor + */ + LTKWordRecognizer() + { + + } + + /** + * Initialization Constructor. Initialzes the member m_shapeRecognizerName + */ + + LTKWordRecognizer(const string& wordRecognizerName): + m_wordRecognizerName(wordRecognizerName) + { + + } + + /** + * Virtual Destructor + */ + virtual ~LTKWordRecognizer() + { + + } + + // @} + + /** + * This is a pure virtual method to be implemented by the derived class. + * 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 + */ + + //virtual int processInk (const LTKRecognitionContext& rc) = 0; + virtual int processInk (LTKRecognitionContext& rc) = 0; + + /** + * This is a pure virtual method to be implemented by the derived class. + * 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 + */ + virtual void endRecoUnit () = 0; + + /** + * This is a pure virtual method to be implemented by the derived class. + * 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 + */ + + // virtual int recognize (const LTKRecognitionContext& rc) = 0; + virtual int recognize (LTKRecognitionContext& rc) = 0; + + /** + * This is a pure virtual method to be implemented by the derived class. + * This method reset the recognizer. + * @param resetParam This parameter could specify what to reset + */ + virtual int reset (int resetParam = 0) = 0; + + /** + * This method unloads all the training data + * To re-initialize the recognizer call the + * API initialize again + */ + virtual int unloadModelData() =0; + +}; + +#endif // #ifndef __LTKWORDRECOGNIZER_H + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/TpcError.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/TpcError.h new file mode 100644 index 00000000..acace684 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/TpcError.h @@ -0,0 +1,162 @@ +/************************************************************************ + * SVN MACROS + * + * $LastChangedDate: 2007-05-14 14:33:50 +0530 (Mon, 14 May 2007) $ + * $Revision: 94 $ + * $Author: sharmnid $ + * + ************************************************************************/ +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 2002. +// +// File: TPCError.h +// Microsoft Tablet PC API Error Code definitions +// +//-------------------------------------------------------------------------- + +#ifndef _WINERROR_ +#include <winerror.h> +#endif + +/*** TPC_E_INVALID_PROPERTY 0x80040241 -2147220927 +* The property was not found, or supported by the recognizer. +*/ +#define TPC_E_INVALID_PROPERTY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x241) + +/*** TPC_E_NO_DEFAULT_TABLET 0x80040212 -2147220974 +* No default tablet. +*/ +#define TPC_E_NO_DEFAULT_TABLET MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x212) + +/*** TPC_E_UNKNOWN_PROPERTY 0x8004021b -2147220965 +* Unknown property specified. +*/ +#define TPC_E_UNKNOWN_PROPERTY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x21b) + +/*** TPC_E_INVALID_INPUT_RECT 0x80040219 -2147220967 +* An invalid input rectangle was specified. +*/ +#define TPC_E_INVALID_INPUT_RECT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x219) + +/*** TPC_E_INVALID_STROKE 0x80040222 -2147220958 +* The stroke object was deleted. +*/ +#define TPC_E_INVALID_STROKE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x222) + +/*** TPC_E_INITIALIZE_FAIL 0x80040223 -2147220957 +* Initialize failure. +*/ +#define TPC_E_INITIALIZE_FAIL MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x223) + +/*** TPC_E_NOT_RELEVANT 0x80040232 -2147220942 +* The data required for the operation was not supplied. +*/ +#define TPC_E_NOT_RELEVANT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x232) + +/*** TPC_E_RECOGNIZER_NOT_REGISTERED 0x80040235 -2147220939 +* There are no Recognizers registered. +*/ +#define TPC_E_RECOGNIZER_NOT_REGISTERED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x235) + +/*** TPC_E_INVALID_RIGHTS 0x80040236 -2147220938 +* User does not have the necessary rights to read recognizer information. +*/ +#define TPC_E_INVALID_RIGHTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x236) + +/*** TPC_E_OUT_OF_ORDER_CALL 0x80040237 -2147220937 +* API calls were made in an incorrect order. +*/ +#define TPC_E_OUT_OF_ORDER_CALL MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x237) + +#define FACILITY_INK 40 +#define INK_ERROR_BASE 0x0000 + +#define MAKE_INK_HRESULT(sev, err) MAKE_HRESULT(sev,FACILITY_INK,err) +#define MAKE_INK_ERROR(err) MAKE_INK_HRESULT(SEVERITY_ERROR,err+INK_ERROR_BASE) +#define MAKE_INK_SCODE(scode) MAKE_INK_HRESULT(SEVERITY_SUCCESS,scode+INK_ERROR_BASE) + +// IErrorInfo helper for objects that support error info (CLSID_IFoo && IID_IFoo) +#define MAKE_OBJ_ERROR_INFO( ID, hr, helpid, helpfile ) \ + AtlReportError( CLSID_##ID , IDS_##hr, \ + helpid, helpfile, \ + IID_I##ID, hr, \ + _Module.GetModuleInstance()) + +// IErrorInfo helper for interfaces that support error info, but are not cocreatable +// (e.g. IID_IFoo, but NOT CLSID_IFoo) +#define MAKE_INT_ERROR_INFO( ID, hr, helpid, helpfile ) \ + AtlReportError( GUID_NULL , IDS_##hr, \ + helpid, helpfile, \ + IID_I##ID, hr, \ + _Module.GetModuleInstance()) + +/*** E_INK_EXCEPTION 0x80280001 -2144862207 +* An internal exception occurred while executing the method or property. +*/ +#define E_INK_EXCEPTION MAKE_INK_ERROR(0x001) + +/*** E_INK_MISMATCHED_INK_OBJECT 0x80280002 -2144862206 +* The object is already associated with an ink object and cannot be reassociated. +*/ +#define E_INK_MISMATCHED_INK_OBJECT MAKE_INK_ERROR(0x002) + +/*** E_INK_COLLECTOR_BUSY 0x80280003 -2144862205 +* The operation cannot be performed while the user is actively inking. +*/ +#define E_INK_COLLECTOR_BUSY MAKE_INK_ERROR(0x003) + +/*** E_INK_INCOMPATIBLE_OBJECT 0x80280004 -2144862204 +* The interface pointer points to an object that is incompatible with the Ink API +*/ +#define E_INK_INCOMPATIBLE_OBJECT MAKE_INK_ERROR(0x004) + +/*** E_INK_WINDOW_NOT_SET 0x80280005 -2144862203 +* The window handle must be set before ink collection can occur. +*/ +#define E_INK_WINDOW_NOT_SET MAKE_INK_ERROR(0x005) + +/*** E_INK_INVALID_MODE 0x80280006 -2144862202 +* The InkCollector must be gesture mode for gesture features, + and single tablet mode for single tablet features. +*/ +#define E_INK_INVALID_MODE MAKE_INK_ERROR(0x006) + +/*** E_INK_COLLECTOR_ENABLED 0x80280007 -2144862201 +* The operation cannot be performed while the InkCollector is enabled. +*/ +#define E_INK_COLLECTOR_ENABLED MAKE_INK_ERROR(0x007) + +/*** E_INK_NO_STROKES_TO_RECOGNIZE 0x80280008 -2144862200 +* There are no strokes for the recognizer to process. +*/ +#define E_INK_NO_STROKES_TO_RECOGNIZE MAKE_INK_ERROR(0x008) + +/*** E_INK_EMPTY_RECOGNITION_RESULT 0x80280009 -2144862199 +* There are no strokes for the recognizer to process. +*/ +#define E_INK_EMPTY_RECOGNITION_RESULT MAKE_INK_ERROR(0x009) + +/*** E_INK_OVERLAPPING_INPUT_RECT 0x80280010 -2144862198 +* "The window input rectangle overlaps with an enabled InkCollector's window input rectangle." +*/ +#define E_INK_OVERLAPPING_INPUT_RECT MAKE_INK_ERROR(0x010) + + +// Recognizer Engine Driver Error Codes + +/*** TPC_E_INVALID_PACKET_DESCRIPTION 0x80040233 -2147220941 +* Invalid packet description. +*/ +#define TPC_E_INVALID_PACKET_DESCRIPTION MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x233) + +#define TPC_E_INSUFFICIENT_BUFFER HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) + +// +// Definition of Success codes +// +#define TPC_S_TRUNCATED MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_ITF, 0x252) +#define TPC_S_INTERRUPTED MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_ITF, 0x253) + + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/headers.pri b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/headers.pri new file mode 100644 index 00000000..b84d5e53 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/include/headers.pri @@ -0,0 +1,33 @@ +HEADERS += \ + $$PWD/LTKCaptureDevice.h \ + $$PWD/LTKChannel.h \ + $$PWD/LTKClassifierDefaults.h \ + $$PWD/LTKErrorsList.h \ + $$PWD/LTKException.h \ + $$PWD/LTKInc.h \ + $$PWD/LTKLipiEngineInterface.h \ + $$PWD/LTKLogger.h \ + $$PWD/LTKLoggerInterface.h \ + $$PWD/LTKMacros.h \ + $$PWD/LTKOSUtil.h \ + $$PWD/LTKOSUtilFactory.h \ + $$PWD/LTKPreprocDefaults.h \ + $$PWD/LTKPreprocessor.h \ + $$PWD/LTKPreprocessorInterface.h \ + $$PWD/LTKRecognitionContext.h \ + $$PWD/LTKRefCountedPtr.h \ + $$PWD/LTKScreenContext.h \ + $$PWD/LTKShapeFeatureMacros.h \ + $$PWD/LTKShapeRecoConfig.h \ + $$PWD/LTKShapeRecoEngine.h \ + $$PWD/LTKShapeRecoResult.h \ + $$PWD/LTKShapeRecoUtil.h \ + $$PWD/LTKShapeRecognizer.h \ + $$PWD/LTKTrace.h \ + $$PWD/LTKTraceFormat.h \ + $$PWD/LTKTraceGroup.h \ + $$PWD/LTKTypes.h \ + $$PWD/LTKWordRecoConfig.h \ + $$PWD/LTKWordRecoResult.h \ + $$PWD/LTKWordRecognizer.h \ + $$PWD/TpcError.h |