diff options
Diffstat (limited to 'src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common')
7 files changed, 1940 insertions, 0 deletions
diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecoConfig.cpp b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecoConfig.cpp new file mode 100644 index 00000000..8ff31c80 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecoConfig.cpp @@ -0,0 +1,538 @@ +/***************************************************************************************** +* 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-02-08 11:00:11 +0530 (Tue, 08 Feb 2011) $ + * $Revision: 832 $ + * $Author: dineshm $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Implementation of LTKShapeRecoConfig which holds the configuration information read + * from the configuration files + * + * CONTENTS: + * readConfigInfo + * getLipiRoot + * getShapeSet + * getProfile + * getShapeRecognizerName + * getNumberOfShapes + * setLipiRoot + * setShapeSet + * setProfile + * setShapeRecognizerName + * setNumShapes + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#include "LTKShapeRecoConfig.h" +#include "LTKErrorsList.h" +#include "LTKLoggerUtil.h" +#include "LTKErrors.h" +#include "LTKShapeRecoConfig.h" +#include "LTKException.h" +#include "LTKConfigFileReader.h" +#include "LTKMacros.h" + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : LTKShapeRecoConfig +* DESCRIPTION : Default Constructor +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +LTKShapeRecoConfig::LTKShapeRecoConfig() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered default constructor of LTKShapeRecoConfig" << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting default constructor of LTKShapeRecoConfig" << endl; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : LTKShapeRecoConfig +* DESCRIPTION : Constructor initializing the member variables +* ARGUMENTS : lipiRoot - root directory of the Lipi Tool Kit +* shapeSet - shape set to be used for training/recognition +* profile - profile to be used for training/recognition +* shapeRecognizerName - name of the shape recognizer to be used for training/recognition +* numShapes - number of shapes in the recognition problem +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* ************************************************************************************/ + +LTKShapeRecoConfig::LTKShapeRecoConfig(const string& lipiRoot, const string& shapeSet, + const string& profile, const string& shapeRecognizerName, int numShapes) : + m_lipiRoot(lipiRoot), m_shapeSet(shapeSet), m_profile(profile), + m_shapeRecognizerName(shapeRecognizerName), m_numShapes(numShapes) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered initialization constructor of LTKShapeRecoConfig" << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_lipiRoot = " << m_lipiRoot << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_shapeSet = " << m_shapeSet << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_profile = " << m_profile << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_shapeRecognizerName = " << m_shapeRecognizerName << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_numShapes = " << m_numShapes << endl; + + int errorCode; + if(m_numShapes <= 0) + { + errorCode = EINVALID_NUM_OF_SHAPES; + + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Invalid value for number of shapes :" << m_numShapes << endl; + + throw LTKException(errorCode); + } + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting initialization constructor of LTKShapeRecoConfig" << endl; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : readConfig +* DESCRIPTION : Reads the configuration files +* ARGUMENTS : configFile - name of the main configuration file +* RETURNS : SUCCESS on successful reading of the configuration file +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* ************************************************************************************/ + +int LTKShapeRecoConfig::readConfigInfo(const string& configFile) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::readConfig" << endl; + + string shapeSetCfg; // shape set configuration file + + string profileCfg; // profile configuration file + + LTKConfigFileReader* mainProperties; // main config file name value pairs + + LTKConfigFileReader* shapesetProperties; // shapeset config name value pairs + + LTKConfigFileReader* profileProperties; // profile config name value pairs + + // reading the main configuration file + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Main configuration file is " << configFile << endl; + + mainProperties = new LTKConfigFileReader(configFile); + + LOG( LTKLogger::LTK_LOGLEVEL_INFO) << + "Main configuration read" << endl; + + // setting config information + + mainProperties->getConfigValue("shapeset", m_shapeSet); + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "shapeSet = " << m_shapeSet << endl; + + mainProperties->getConfigValue("profile", m_profile); + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "profile = " << m_profile << endl; + + // composing the shape set configuration file name + + shapeSetCfg = m_lipiRoot + SEPARATOR + m_shapeSet + SEPARATOR + SHAPESETFILE; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Shapeset configuration file is " << shapeSetCfg << endl; + + // reading the shape set configuration file + + shapesetProperties = new LTKConfigFileReader(shapeSetCfg); + + LOG( LTKLogger::LTK_LOGLEVEL_INFO) << + "Shapeset configuration read" << endl; + + // setting config information + string numShapesStr; + shapesetProperties->getConfigValue(PROJECT_CFG_ATTR_NUMSHAPES_STR, numShapesStr); + m_numShapes = atoi(numShapesStr.c_str()); + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_numShapes = " << m_numShapes << endl; + + if(m_numShapes <= 0) + { + delete mainProperties; + delete shapesetProperties; + + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Invalid value for number of shapes : " << m_numShapes << endl; + + LTKReturnError(EINVALID_NUM_OF_SHAPES); // Error while reading project.cfg + + //throw LTKException("numShapes cannot be less than or equal to zero"); + } + + // composing the proile configuration file name + + profileCfg = m_lipiRoot + SEPARATOR + m_shapeSet + SEPARATOR + m_profile + SEPARATOR + PROFILEFILE; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Profile configuration file is " << profileCfg << endl; + + // reading the profile configuration file + + profileProperties = new LTKConfigFileReader(profileCfg); + + LOG( LTKLogger::LTK_LOGLEVEL_INFO) << "Profile configuration read" << endl; + + // setting config information + + profileProperties->getConfigValue(SHAPE_RECOGNIZER_STRING, m_shapeRecognizerName); + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_shapeRecognizerName = " << m_shapeRecognizerName << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting LTKShapeRecoConfig::readConfig" << endl; + + delete mainProperties; + delete shapesetProperties; + delete profileProperties; + return SUCCESS; + +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : getLipiRoot +* DESCRIPTION : returns the root directory of the lipi tool kit +* ARGUMENTS : +* RETURNS : root directory of the lipi tool kit +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* ************************************************************************************/ + +const string& LTKShapeRecoConfig::getLipiRoot() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::getLipiRoot" << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting LTKShapeRecoConfig::getLipiRoot with return value " << + m_lipiRoot << endl; + + return m_lipiRoot; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : getShapeSet +* DESCRIPTION : returns the shape set to be used for training/recognition +* ARGUMENTS : +* RETURNS : shape set to be used for training/recognition +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* ************************************************************************************/ + +const string& LTKShapeRecoConfig::getShapeSet() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::getShapeSet" << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting LTKShapeRecoConfig::getShapeSet with return value " << + m_shapeSet << endl; + + return m_shapeSet; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : getProfile +* DESCRIPTION : returns the profile to be used for training/recognition +* ARGUMENTS : +* RETURNS : profile to be used for training/recognition +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +const string& LTKShapeRecoConfig::getProfile() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::getProfile" << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting LTKShapeRecoConfig::getProfile with return value " << + m_profile << endl; + + return m_profile; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : getShapeRecognizerName +* DESCRIPTION : returns the name of the shape recognizer being used +* ARGUMENTS : +* RETURNS : name of the shape recognizer being used +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* ************************************************************************************/ + +const string& LTKShapeRecoConfig::getShapeRecognizerName() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::getShapeRecognizerName" << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting LTKShapeRecoConfig::getShapeRecognizerName with return value " << + m_shapeRecognizerName << endl; + + return m_shapeRecognizerName; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : getNumShapes +* DESCRIPTION : returns the number of shapes in the recognition problem +* ARGUMENTS : +* RETURNS : number of shapes in the recognition problem +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* ************************************************************************************/ + +int LTKShapeRecoConfig::getNumShapes() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::getNumShapes" << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting LTKShapeRecoConfig::getNumShapes with return value " << m_numShapes << endl; + + return m_numShapes; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : setLipiRoot +* DESCRIPTION : sets the root directory of the lipi tool kit +* ARGUMENTS : lipiRootStr - root directory of the lipi tool kit +* RETURNS : SUCCESS on successful set operation +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* ************************************************************************************/ + +int LTKShapeRecoConfig::setLipiRoot(const string& lipiRootStr) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::setLipiRoot" << endl; + + this->m_lipiRoot = lipiRootStr; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_lipiRoot = " << m_lipiRoot << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting LTKShapeRecoConfig::setLipiRoot" << endl; + + return SUCCESS; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : setShapeSet +* DESCRIPTION : sets the shape set to be used for training/recognition +* ARGUMENTS : shapeSetStr - shape set to be used for training/recognition +* RETURNS : SUCCESS on successful set operation +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +int LTKShapeRecoConfig::setShapeSet(const string& shapeSetStr) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::setShapeSet" << endl; + + this->m_shapeSet = shapeSetStr; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_shapeSet = " << m_shapeSet << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting LTKShapeRecoConfig::setShapeSet" << endl; + + return SUCCESS; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : setProfile +* DESCRIPTION : sets the profile to be used for training/recognition +* ARGUMENTS : profileStr - profile to be used for training/recognition +* RETURNS : SUCCESS on successful set operation +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +int LTKShapeRecoConfig::setProfile(const string& profileStr) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::setProfile" << endl; + + this->m_profile = profileStr; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_profile = " << m_profile << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting LTKShapeRecoConfig::setProfile" << endl; + + return SUCCESS; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : setShapeRecognizerName +* DESCRIPTION : sets the name of the shape recognizer to be used for training/recognition +* ARGUMENTS : shapeRecognizerName - name of the shape recognizer to be used for training/recognition +* RETURNS : SUCCESS on successful set operation +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* ************************************************************************************/ + +int LTKShapeRecoConfig::setShapeRecognizerName(const string& shapeRecognizerName) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::setShapeRecognizerName" << endl; + + this->m_shapeRecognizerName = shapeRecognizerName; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_shapeRecognizerName = " << m_shapeRecognizerName << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting LTKShapeRecoConfig::setShapeRecognizerName" << endl; + + return SUCCESS; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : setNumShapes +* DESCRIPTION : sets the number of shapes in the recongition problem +* ARGUMENTS : numShapes - number of shapes in the recongition problem +* RETURNS : SUCCESS on successful set operation +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* ************************************************************************************/ + +int LTKShapeRecoConfig::setNumShapes(int numShapes) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered LTKShapeRecoConfig::setNumShapes" << endl; + + this->m_numShapes = numShapes; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "m_numShapes = " << m_numShapes << endl; + + if(m_numShapes <= 0) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Invalid value for number of shapes : " << m_numShapes << endl; + + LTKReturnError(EINVALID_NUM_OF_SHAPES) + //return ECONFIG_FILE_OPEN_ERR; // Error while reading project.cfg + + //throw LTKException("m_numShapes cannot be less than or equal to zero"); + } + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting LTKShapeRecoConfig::setNumShapes" << endl; + + return SUCCESS; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : ~LTKShapeRecoConfig +* DESCRIPTION : destructor +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* ************************************************************************************/ + +LTKShapeRecoConfig::~LTKShapeRecoConfig() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entered destructor of LTKShapeRecoConfig" << endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting destructor of LTKShapeRecoConfig" << endl; +} diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecoResult.cpp b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecoResult.cpp new file mode 100644 index 00000000..746d45dc --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecoResult.cpp @@ -0,0 +1,223 @@ +/***************************************************************************************** +* 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-11 13:48:17 +0530 (Tue, 11 Jan 2011) $ + * $Revision: 827 $ + * $Author: mnab $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Implementation of LTKShapeRecoResult which holds the recognition results of the + * shape recognition engine + * + * CONTENTS: + * getShapeID + * getConfidence + * setShapeID + * setConfidence + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#include "LTKInc.h" + +#include "LTKMacros.h" + +#include "LTKErrors.h" + +#include "LTKErrorsList.h" + +#include "LTKShapeRecoResult.h" + +#include "LTKLoggerUtil.h" + + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : LTKShapeRecoResult +* DESCRIPTION : Default Constructor +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +LTKShapeRecoResult::LTKShapeRecoResult() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecoResult::LTKShapeRecoResult()" <<endl; + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoResult::LTKShapeRecoResult()" <<endl; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : LTKShapeRecoResult +* DESCRIPTION : Constructor initializing the member variables +* ARGUMENTS : shapeId - shape id of the result +* confidence - its corresponding confidence value +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +LTKShapeRecoResult::LTKShapeRecoResult(int shapeId, float confidence) : m_shapeId(shapeId), + m_confidence(confidence) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecoResult::LTKShapeRecoResult(int, float)" <<endl; + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoResult::LTKShapeRecoResult(int, float)" <<endl; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : getShapeId +* DESCRIPTION : returns the shape id of the result +* ARGUMENTS : +* RETURNS : shape id of the result +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +int LTKShapeRecoResult::getShapeId() const +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecoResult::getShapeId()" <<endl; + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoResult::getShapeId()" <<endl; + return m_shapeId; +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : getConfidence +* DESCRIPTION : returns the confidence value of the result +* ARGUMENTS : +* RETURNS : confidence value of the result +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +float LTKShapeRecoResult::getConfidence() const +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecoResult::getConfidence()" <<endl; + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoResult::getConfidence()" <<endl; + return m_confidence; +} + +/********************************************************************************** + * AUTHOR : Balaji R. + * DATE : 23-DEC-2004 + * NAME : setShapeId + * DESCRIPTION : sets the shape id of the result + * ARGUMENTS : shapeId - shape id of the result + * RETURNS : SUCCESS on successful set function + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + *************************************************************************************/ + +int LTKShapeRecoResult::setShapeId(int shapeId) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecoResult::setShapeId()" <<endl; + + if(shapeId < 0) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< + getErrorMessage(EINVALID_CLASS_ID)<< + " LTKShapeRecoResult::setShapeId()" <<endl; + + LTKReturnError(EINVALID_CLASS_ID); + } + this->m_shapeId = shapeId; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoResult::setShapeId()" <<endl; + + return SUCCESS; +} + +/********************************************************************************** + * AUTHOR : Balaji R. + * DATE : 23-DEC-2004 + * NAME : setConfidence + * DESCRIPTION : sets the confidence of the result + * ARGUMENTS : confidenceVal - confidence of the result + * RETURNS : SUCCESS on successful set function + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + *************************************************************************************/ + +int LTKShapeRecoResult::setConfidence(float confidenceVal) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecoResult::setConfidence()" <<endl; + + if( confidenceVal < 0 || confidenceVal > 1) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< + getErrorMessage(EINVALID_CONFIDENCE_VALUE)<< + " LTKShapeRecoResult::setShapeId()" <<endl; + + LTKReturnError(EINVALID_CONFIDENCE_VALUE); + } + + this->m_confidence = confidenceVal; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoResult::setConfidence()" <<endl; + + return SUCCESS; +} + +/********************************************************************************** + * AUTHOR : Balaji R. + * DATE : 23-DEC-2004 + * NAME : ~LTKShapeRecoResult + * DESCRIPTION : destructor + * ARGUMENTS : + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + *************************************************************************************/ + +LTKShapeRecoResult::~LTKShapeRecoResult() +{ +} diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecoUtil.cpp b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecoUtil.cpp new file mode 100644 index 00000000..2d944d0c --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecoUtil.cpp @@ -0,0 +1,486 @@ +/***************************************************************************************** +* 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: Implementation for LTKShapeRecoUtil +* +* CONTENTS: +* getAbsolutePath +* isProjectDynamic +* initializePreprocessor +* deletePreprocessor +* unloadPreprocessor +* readInkFromFile +* checkEmptyTraces +* shapeFeatureVectorToFloatVector +* shapeFeatureVectorToIntVector +* +* AUTHOR: Saravanan R. +* +* DATE: January 23, 2004 +* CHANGE HISTORY: +* Author Date Description of change +************************************************************************/ + +#ifdef _WIN32 +#include "windows.h" +#endif + +#include "LTKInc.h" +#include "LTKLoggerUtil.h" +#include "LTKTrace.h" +#include "LTKMacros.h" +#include "LTKErrors.h" +#include "LTKException.h" +#include "LTKErrorsList.h" +#include "LTKInkFileReader.h" +#include "LTKTraceGroup.h" +#include "LTKStringUtil.h" +#include "LTKConfigFileReader.h" +#include "LTKShapeRecoUtil.h" +#include "LTKShapeFeatureExtractor.h" +#include "LTKShapeFeature.h" +#include "LTKPreprocessorInterface.h" + + +//FN_PTR_DELETE_SHAPE_FTR_PTR LTKShapeRecoUtil::m_deleteShapeFeatureFunc = NULL; + +/********************************************************************************** +* AUTHOR : Saravanan. R +* DATE : 11-01-2007 +* NAME : LTKShapeRecoUtil +* DESCRIPTION : Constructor +* ARGUMENTS : None +* RETURNS : None +* NOTES : +* CHANGE HISTROY +* Author Date Description +*************************************************************************************/ +LTKShapeRecoUtil::LTKShapeRecoUtil() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entered LTKShapeRecoUtil::LTKShapeRecoUtil()" <<endl; + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoUtil::LTKShapeRecoUtil()" <<endl; +} + +/********************************************************************************** + * AUTHOR : Saravanan. R + * DATE : 31-01-2007 + * NAME : LTKShapeRecoUtil + * DESCRIPTION : Destructor + * ARGUMENTS : None + * RETURNS : None + * NOTES : + * CHANGE HISTROY + * Author Date Description + *************************************************************************************/ +LTKShapeRecoUtil::~LTKShapeRecoUtil() +{ +} + +/********************************************************************************** + * AUTHOR : Saravanan. R + * DATE : 11-01-2007 + * NAME : getAbsolutePath + * DESCRIPTION : This method is used to convert the relative path to the absolute path + * ARGUMENTS : pathName : string : Holds the path of the training file + * lipiRootPath : string : Holds the lipiroot path + * + * RETURNS : SUCCESS only + * NOTES : + * CHANGE HISTROY + * Author Date Descriptionh + *************************************************************************************/ +int LTKShapeRecoUtil::getAbsolutePath (const string& inputPath, + const string& lipiRootPath, + string& outPath) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entered LTKShapeRecoUtil::getAbsolutePath()" <<endl; + + outPath = ""; + vector<string> tokens; + + int returnStatus = SUCCESS; + + //Split the path name into number of tokens based on the delimter + returnStatus = LTKStringUtil::tokenizeString(inputPath, "\\/", tokens); + + if(returnStatus != SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<"Error: " << + getErrorMessage(returnStatus) << + " LTKShapeRecoUtil::getAbsolutePath()" <<endl; + + LTKReturnError(returnStatus); + } + + //The first token must be the $LIPI_ROOT. Otherwise return from the function + if (tokens[0] != LIPIROOT) + { + outPath = inputPath; + return SUCCESS; + } + + //Store the Environment variable into the tokens + tokens[0] = lipiRootPath; + + //Reinitialize the outPath + for(int i=0 ; i < tokens.size() ; i++) + { + outPath += tokens[i] + SEPARATOR; + } + + // Erase the last character '\' + outPath.erase(outPath.size()-1,1); + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoUtil::getAbsolutePath()" <<endl; + + return SUCCESS; +} + + +/*********************************************************************************** + * AUTHOR : Saravanan. R + * DATE : 19-01-2007 + * NAME : isProjectDynamic + * DESCRIPTION : This method reads the project.cfg to find whether the project + * is dynamic or not + * ARGUMENTS : configFilePath : string : Holds the path of the project.cfg + * numShapes : unsigned short : Holds the NumShapes value from config file + * returnStauts : int : Holds SUCCESS or ErrorValues + * strNumShapes : string : Holds the NumShapes value from config file + * RETURNS : true : if the project was dynamic + * false : if the project was dynamic + * NOTES : + * CHANGE HISTROY + * Author Date Description + *************************************************************************************/ +int LTKShapeRecoUtil::isProjectDynamic(const string& configFilePath, + unsigned short& numShapes, + string& strNumShapes, + bool& outIsDynamic ) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecoUtil::isProjectDynamic()" <<endl; + + //Specifies the project is dynamic or not + outIsDynamic = false; + + string numShapesCfgAttr = ""; + + //As numshapes was unsigned short we use this tempNumShapes as integer, + //it is used for checking whether it is less than 0 + int tempNumShapes = 0; + LTKConfigFileReader* projectCfgAttrs = NULL; + string valueFromCFG = "0"; + + int errorCode = SUCCESS; + + try + { + //Read the config entries + projectCfgAttrs = new LTKConfigFileReader(configFilePath); + errorCode = projectCfgAttrs->getConfigValue(PROJECT_CFG_ATTR_NUMSHAPES_STR, numShapesCfgAttr); + + //Checking whether the numshapes was dynamic + if(errorCode != SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: " << + "NumShapes should be set to dynamic or the number of training classes" << + " LTKShapeRecoUtil::isProjectDynamic()" <<endl; + + LTKReturnError(errorCode); + + } + else if( LTKSTRCMP(numShapesCfgAttr.c_str(), DYNAMIC) == 0 ) + { + //Numshapes was dynamic + outIsDynamic = true; + tempNumShapes = 0; + } + else + { + bool isPositiveInteger=true; + + valueFromCFG = numShapesCfgAttr; + + for(int charIndex=0 ; charIndex < valueFromCFG.size() ; ++charIndex) + { + if(!(valueFromCFG[charIndex]>='0' && valueFromCFG[charIndex]<='9')) + { + isPositiveInteger=false; + break; + } + } + + + + if(!isPositiveInteger) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error" << + "NumShapes should be set to dynamic or the number of training classes" << + " LTKShapeRecoUtil::isProjectDynamic()" <<endl; + + LTKReturnError(EINVALID_NUM_OF_SHAPES); + } + else + { + tempNumShapes = atoi(valueFromCFG.c_str()); + if(tempNumShapes==0) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error" << + "NumShapes should be set to dynamic or the number of training classes" << + " LTKShapeRecoUtil::isProjectDynamic()" <<endl; + + LTKReturnError(EINVALID_NUM_OF_SHAPES); + } + else + { + //Numshapes was not dynamic + outIsDynamic = false; + } + + } + + } + + numShapes = tempNumShapes; + strNumShapes = valueFromCFG; + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "NumShapes in the project is " << valueFromCFG <<endl; + + + } + catch(LTKException e) + { + delete projectCfgAttrs; + throw e; + } + + delete projectCfgAttrs; + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoUtil::isProjectDynamic()" <<endl; + + return SUCCESS; +} + + + +/********************************************************************************** + * AUTHOR : Saravanan. R + * DATE : 30-01-2007 + * NAME : readInkFromFile + * DESCRIPTION : This method reads the Ink file and check from empty traces + * ARGUMENTS : string : Holds the Path of the unipen ink file +string : Holds the Path of the lipi root + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description + *************************************************************************************/ +int LTKShapeRecoUtil::readInkFromFile(const string& path, const string& lipiRootPath, + LTKTraceGroup& inTraceGroup, + LTKCaptureDevice& captureDevice, + LTKScreenContext& screenContext) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecoUtil::readInkFromFile()" <<endl; + + //inTraceGroup.emptyAllTraces(); + + string tempPath = path; + + //Check and convert Relative path to Absolute path + string outPath = ""; + getAbsolutePath(tempPath, lipiRootPath, outPath); + + //Print the path name + cout << outPath << endl; + + //Read Ink file to inTraceGroup + // errorVal = LTKInkFileReader::readUnipenInkFile(tempPath,inTraceGroup,captureDevice,screenContext); + int errorCode = LTKInkFileReader::readUnipenInkFile(outPath,inTraceGroup,captureDevice,screenContext); + + if (errorCode != SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: " << + getErrorMessage(errorCode) << + " LTKShapeRecoUtil::readInkFromFile()" <<endl; + + LTKReturnError(errorCode); + } + + //Check for empty traces in inTraceGroup + + if (inTraceGroup.containsAnyEmptyTrace()) + { + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<"Error: " << + "TraceGroup has empty traces" << + " LTKShapeRecoUtil::readInkFromFile()" <<endl; + + LTKReturnError(EEMPTY_TRACE); + } + + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoUtil::readInkFromFile()" <<endl; + + return SUCCESS; +} + +/********************************************************************************** + * AUTHOR : Saravanan. R + * DATE : 30-01-2007 + * NAME : checkEmptyTraces + * DESCRIPTION : This method checks for empty traces + * ARGUMENTS : inTraceGroup : LTKTraceGroup : + * RETURNS : 1 if it contains empty trace group, 0 otherwise + * NOTES : + * CHANGE HISTROY + * Author Date Description + *************************************************************************************/ +/* +int LTKShapeRecoUtil::checkEmptyTraces(const LTKTraceGroup& inTraceGroup) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecoUtil::checkEmptyTraces()" <<endl; + + int returnVal = SUCCESS; + + vector<LTKTrace> tracesVec = inTraceGroup.getAllTraces(); //traces in trace group + + int numTraces = tracesVec.size(); + + int numTracePoints = 0; + + LTKTrace trace; // a trace of the trace group + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< "numTraces = " << numTraces <<endl; + + + for(int traceIndex=0; traceIndex < numTraces; ++traceIndex) + { + trace = tracesVec.at(traceIndex); + + numTracePoints=trace.getNumberOfPoints(); + + if(numTracePoints==0) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< + getError(EEMPTY_TRACE) << + "Exiting LTKShapeRecoUtil::checkEmptyTraces()" <<endl; + LTKReturnError(EEMPTY_TRACE); + } + + } + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoUtil::checkEmptyTraces()" <<endl; + return SUCCESS; +} +*/ +int LTKShapeRecoUtil::convertHeaderToStringStringMap(const string& header, stringStringMap& headerSequence) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecoUtil::convertHeaderToStringStringMap()" <<endl; + + vector<string> tokens; + vector<string> strList; + + int returnStatus = SUCCESS; + + LTKStringUtil::tokenizeString(header, "<>", tokens); + + for(int i=0 ; i < tokens.size(); ++i) + { + returnStatus = LTKStringUtil::tokenizeString(tokens[i], "=", strList); + if(returnStatus != SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: " << + getErrorMessage(returnStatus) << + " LTKShapeRecoUtil::convertHeaderToStringStringMap()" <<endl; + LTKReturnError(returnStatus); + } + if(strList.size() == 2) + { + headerSequence[strList[0]] = strList[1]; + } + } + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecoUtil::convertHeaderToStringStringMap()" <<endl; + + return SUCCESS; +} + + +/********************************************************************************** +* AUTHOR : Saravanan. R +* DATE : 14-03-2007 +* NAME : shapeFeatureVectorToFloatVector +* DESCRIPTION : This method converts the ShapeFeatureVector to float vector +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description +*************************************************************************************/ +int LTKShapeRecoUtil::shapeFeatureVectorToFloatVector(const vector<LTKShapeFeaturePtr>& shapeFeature, + floatVector& outFloatVector) +{ + int returnVal = SUCCESS; + + //Iterators for the LTKShapeFeature + vector<LTKShapeFeaturePtr>::const_iterator shapeFeatureIter = shapeFeature.begin(); + vector<LTKShapeFeaturePtr>::const_iterator shapeFeatureIterEnd = shapeFeature.end(); + + + vector<float> shapeFeatureFloatvector; + + for(; shapeFeatureIter != shapeFeatureIterEnd; ++shapeFeatureIter) + { + + //Convert the shapefeature to float vector + returnVal = (*shapeFeatureIter)->toFloatVector(shapeFeatureFloatvector); + + if ( returnVal != SUCCESS ) + { + break; + } + + outFloatVector.insert(outFloatVector.end(), + shapeFeatureFloatvector.begin(), + shapeFeatureFloatvector.end()); + + shapeFeatureFloatvector.clear(); + + } + + return returnVal; +}
\ No newline at end of file diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecognizer.cpp b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecognizer.cpp new file mode 100644 index 00000000..bed1ca48 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeRecognizer.cpp @@ -0,0 +1,250 @@ +/***************************************************************************************** +* 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-30 15:57:38 +0530 (Wed, 30 Jul 2008) $ + * $Revision: 576 $ + * $Author: kuanish $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Implementation of LTKShapeRecognizer which would be used as a place holder in LTKShapeRecognizer + * for anyone of the implemented shape recognizers like PCAShapeRecognizer which is derived from this class + * + * CONTENTS: + * + * AUTHOR: Balaji R. + * + * DATE: December 23, 2004 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#include "LTKShapeRecognizer.h" +#include "LTKLoggerUtil.h" +#include "LTKException.h" +#include "LTKErrorsList.h" +#include "LTKErrors.h" +#include "LTKInc.h" + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : LTKShapeRecognizer +* DESCRIPTION : Default Constructor +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +LTKShapeRecognizer::LTKShapeRecognizer() : m_cancelRecognition(false) +{ + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecognizer::LTKShapeRecognizer()" <<endl; + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecognizer::LTKShapeRecognizer()" <<endl; + +} + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : LTKShapeRecognizer +* DESCRIPTION : Initializes the member(s) of the class +* ARGUMENTS : shapeRecognzierName - name of the derived shape recognizer which is being held +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +LTKShapeRecognizer::LTKShapeRecognizer(const string& shapeRecognzierName) : m_shapeRecognizerName(shapeRecognzierName), m_cancelRecognition(false) +{ + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecognizer::LTKShapeRecognizer(const string&)" <<endl; + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecognizer::LTKShapeRecognizer(const string&)" <<endl; +} + +/********************************************************************************** +* AUTHOR : Tarun Madan +* DATE : 07-JUN-2007 +* NAME : AddCLass +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ +int LTKShapeRecognizer::addClass(const LTKTraceGroup& sampleTraceGroup,int& shapeID) +{ + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecognizer::addClass()" <<endl; + + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: " << + getErrorMessage(ESHAPE_RECOCLASS_NOIMPLEMENTATION) << + " LTKShapeRecognizer::addClass()" <<endl; + + LTKReturnError(ESHAPE_RECOCLASS_NOIMPLEMENTATION); + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecognizer::addClass()" <<endl; + + return SUCCESS; +} + +/********************************************************************************** +* AUTHOR : +* DATE : +* NAME : AddSample +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ +int LTKShapeRecognizer::addSample(const LTKTraceGroup& sampleTraceGroup,int shapeID) +{ + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecognizer::AddSample()" <<endl; + + LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: " << + getErrorMessage(ESHAPE_RECOCLASS_NOIMPLEMENTATION) << + " LTKShapeRecognizer::AddSample()" <<endl; + + LTKReturnError(ESHAPE_RECOCLASS_NOIMPLEMENTATION); + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecognizer::AddSample()" <<endl; + + return SUCCESS; +} +/********************************************************************************** +* AUTHOR : Tarun Madan +* DATE : 07-JUN-2007 +* NAME : Delete Class +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ +int LTKShapeRecognizer::deleteClass(int shapeID) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecognizer::deleteClass()" <<endl; + + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: " << + getErrorMessage(ESHAPE_RECOCLASS_NOIMPLEMENTATION) << + " LTKShapeRecognizer::deleteClass()" <<endl; + + LTKReturnError(ESHAPE_RECOCLASS_NOIMPLEMENTATION); + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecognizer::deleteClass()" <<endl; + + return SUCCESS; +} + +/********************************************************************************** +* AUTHOR : Tarun Madan +* DATE : 30-AUG-2007 +* NAME : Adapt +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ +int LTKShapeRecognizer::adapt(int shapeID ) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecognizer::adapt()" <<endl; + + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: " << + getErrorMessage(ESHAPE_RECOCLASS_NOIMPLEMENTATION) << + " LTKShapeRecognizer::adapt()" <<endl; + + LTKReturnError(ESHAPE_RECOCLASS_NOIMPLEMENTATION); + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecognizer::adapt()" <<endl; + + return SUCCESS; + +} + +/********************************************************************************** +* AUTHOR : Tarun Madan +* DATE : 30-AUG-2007 +* NAME : Adapt +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ +int LTKShapeRecognizer::adapt(const LTKTraceGroup& sampleTraceGroup, int shapeID) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeRecognizer::adapt(const LTKTraceGroup&, int)" <<endl; + + LOG( LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: " << + getErrorMessage(ESHAPE_RECOCLASS_NOIMPLEMENTATION) << + " LTKShapeRecognizer::adapt()" <<endl; + + LTKReturnError(ESHAPE_RECOCLASS_NOIMPLEMENTATION); + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeRecognizer::adapt(const LTKTraceGroup&, int)" <<endl; + + return SUCCESS; + +} + + +/********************************************************************************** +* AUTHOR : Balaji R. +* DATE : 23-DEC-2004 +* NAME : ~LTKShapeRecognizer +* DESCRIPTION : destructor +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +*************************************************************************************/ + +LTKShapeRecognizer::~LTKShapeRecognizer() +{ +} + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeSample.cpp b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeSample.cpp new file mode 100644 index 00000000..4044c86f --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeSample.cpp @@ -0,0 +1,288 @@ +/***************************************************************************************** +* 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 20:12:22 +0530 (Wed, 01 Jul 2009) $ + * $Revision: 784 $ + * $Author: mnab $ + * + ************************************************************************/ +#include "LTKShapeSample.h" + +#include "LTKShapeFeature.h" + +#include "LTKRefCountedPtr.h" + +#include "LTKLoggerUtil.h" + + +/********************************************************************************** + * AUTHOR : Saravanan R. + * DATE : 22-Mar-2007 + * NAME : LTKShapeSample + * DESCRIPTION : Default Constructor + * ARGUMENTS : + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ************************************************************************************/ + +LTKShapeSample::LTKShapeSample() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample::LTKShapeSample()" <<endl; + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeSample::LTKShapeSample()" <<endl; + +} + +/********************************************************************************** + * AUTHOR : Saravanan R. + * DATE : 22-Mar-2007 + * NAME : LTKShapeSample + * DESCRIPTION : Copy Constructor + * ARGUMENTS : sampleFeatures - LTKShapeSample to be copied + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ************************************************************************************/ + +LTKShapeSample::LTKShapeSample(const LTKShapeSample& sampleFeatures) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample::LTKShapeSample(const LTKShapeSample& )" <<endl; + + m_featureVector = sampleFeatures.m_featureVector; + m_classId = sampleFeatures.m_classId; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeSample::LTKShapeSample(const LTKShapeSample& )" <<endl; +} + +/********************************************************************************** + * AUTHOR : Saravanan R. + * DATE : 22-Mar-2007 + * NAME : operator= + * DESCRIPTION : Overloaded assignment operator + * ARGUMENTS : sampleFeatures - LTKShapeSample to be assigned to + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ************************************************************************************/ + +LTKShapeSample& LTKShapeSample::operator=(const LTKShapeSample& sampleFeatures) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample::operator=(const LTKShapeSample& )" <<endl; + + if ( this != &sampleFeatures ) + { + m_featureVector = sampleFeatures.m_featureVector; + m_classId = sampleFeatures.m_classId; + } + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample::operator=(const LTKShapeSample& )" <<endl; + return *this; +} + +/********************************************************************************** + * AUTHOR : Saravanan R. + * DATE : 22-Mar-2007 + * NAME : ~LTKShapeSample + * DESCRIPTION : destructor + * ARGUMENTS : + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ************************************************************************************/ + +LTKShapeSample::~LTKShapeSample() +{ +} + +/********************************************************************************** + * AUTHOR : Saravanan R. + * DATE : 22-Mar-2007 + * NAME : setFeatureVector + * DESCRIPTION : + * ARGUMENTS : + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ************************************************************************************/ +void LTKShapeSample::setFeatureVector(const vector<LTKShapeFeaturePtr>& inFeatureVec) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample:setFeatureVector()" <<endl; + + m_featureVector = inFeatureVec; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeSample:setFeatureVector()" <<endl; +} + +/********************************************************************************** + * AUTHOR : Saravanan R. + * DATE : 22-Mar-2007 + * NAME : setClassID + * DESCRIPTION : + * ARGUMENTS : + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ************************************************************************************/ +void LTKShapeSample::setClassID(int inClassId) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample:setClassID()" <<endl; + + m_classId = inClassId; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeSample:setClassID()" <<endl; +} + +/********************************************************************************** + * AUTHOR : Saravanan R. + * DATE : 22-Mar-2007 + * NAME : getFeatureVector + * DESCRIPTION : + * ARGUMENTS : + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ************************************************************************************/ +const vector<LTKShapeFeaturePtr>& LTKShapeSample::getFeatureVector() const +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample:getFeatureVector()" <<endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeSample:getFeatureVector()" <<endl; + + return m_featureVector; +} + +/********************************************************************************** + * AUTHOR : The Qt Company + * DATE : 17-Mar-2015 + * NAME : getFeatureVectorRef + * DESCRIPTION : + * ARGUMENTS : + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ************************************************************************************/ +vector<LTKShapeFeaturePtr>& LTKShapeSample::getFeatureVectorRef() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample:getFeatureVectorRef()" <<endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeSample:getFeatureVectorRef()" <<endl; + + return m_featureVector; +} + +/********************************************************************************** + * AUTHOR : Saravanan R. + * DATE : 22-Mar-2007 + * NAME : getClassID + * DESCRIPTION : + * ARGUMENTS : + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ************************************************************************************/ +int LTKShapeSample::getClassID() const +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample:getClassID()" <<endl; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeSample:getClassID()" <<endl; + + return m_classId; +} + +/************************************************************************** + * AUTHOR : Nidhi Sharma + * DATE : 28-Nov-2007 + * NAME : clearShapeSampleFeatures + * DESCRIPTION : + * ARGUMENTS : + * RETURNS : + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ****************************************************************************/ +void LTKShapeSample::clearShapeSampleFeatures() +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample:clearShapeSampleFeatures()" <<endl; + + m_featureVector.clear(); + m_classId = -1; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeSample:clearShapeSampleFeatures()" <<endl; +} +/************************************************************************** + * AUTHOR : Balaji MNA + * DATE : 30-June-2009 + * NAME : getCountStrokes + * DESCRIPTION : get strokes count + * ARGUMENTS : NONE + * RETURNS : return number of strokes + * NOTES : + * CHANGE HISTROY + * Author Date Description of change + * ****************************************************************************/ +int LTKShapeSample::getCountStrokes() const +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering LTKShapeSample::getCountStrokes()" <<endl; + + int countStrokes = 0; + + vector<LTKShapeFeaturePtr>::const_iterator featureIter = m_featureVector.begin(); + vector<LTKShapeFeaturePtr>::const_iterator featureEnd = m_featureVector.end(); + + for(; featureIter != featureEnd; ++featureIter) + { + if ((*featureIter)->isPenUp()) + ++countStrokes; + } + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting LTKShapeSample::getCountStrokes()" <<endl; + + return countStrokes; +} diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeSample.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeSample.h new file mode 100644 index 00000000..02ec1f7f --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/LTKShapeSample.h @@ -0,0 +1,142 @@ +/***************************************************************************************** +* 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 $ + * + ************************************************************************/ +#ifndef __LTKSHAPESAMPLE_H +#define __LTKSHAPESAMPLE_H + +#include "LTKInc.h" + +#include "LTKShapeFeatureMacros.h" + +class LTKShapeFeature; + + +class LTKShapeSample +{ + private: + vector<LTKShapeFeaturePtr> m_featureVector; + int m_classId; + + public: + /** @name Constructors and Destructor */ + //@{ + + /** + * Default Constructor. + */ + + LTKShapeSample(); + + /** + * Copy Constructor + */ + LTKShapeSample(const LTKShapeSample& shapeFeatures); + + /** + * Destructor + */ + ~LTKShapeSample(); + //@} + + /** + * @name Assignment operator + */ + //@{ + + /** + * Assignment operator + * @param shapeFeatures The object to be copied by assignment + * + * @return LTKShapeSample object + */ + + LTKShapeSample& operator=(const LTKShapeSample& shapeFeatures); + //@} + + /** + * @name Getter Functions + */ + //@{ + + + /** + * @brief getter method for feature vector + * @param none + * @return featureVec Type : LTKShapeFeaturePtrtor + */ + const vector<LTKShapeFeaturePtr>& getFeatureVector() const; + + + /** + * @brief getter method for feature vector + * @param none + * @return featureVec Type : LTKShapeFeaturePtrtor + */ + vector<LTKShapeFeaturePtr>& getFeatureVectorRef(); + + + /** + * @brief setter method for class ID + * @param none + * @return classID Type : int + */ + int getClassID() const; + //@} + + + /** + * @name Setter Functions + */ + //@{ + + /** + * @brief setter method for feature vector + * @param featureVec Type : LTKShapeFeaturePtrtor + */ + void setFeatureVector(const vector<LTKShapeFeaturePtr>& inFeatureVec); + + + /** + * @brief setter method for class ID + * @param classID Type : int + */ + void setClassID(int inClassId); + //@} + + /** + * @brief setter method for strokes count + * @param none + * @return strokes count Type : int + */ + int getCountStrokes() const; + + void clearShapeSampleFeatures(); + + //Since pointer is a member variable we should implement constructor, copy-constructor, assignment operator, virtual destructor +}; + +#endif + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/common.pro b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/common.pro new file mode 100644 index 00000000..a8b0756b --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/common/common.pro @@ -0,0 +1,13 @@ +TARGET = shaperecommon +include(../../../lipilib.pri) + +INCLUDEPATH += \ + ../../../util/lib \ + ../featureextractor/common \ + +SOURCES += \ + LTKShapeRecoConfig.cpp \ + LTKShapeRecognizer.cpp \ + LTKShapeRecoResult.cpp \ + LTKShapeRecoUtil.cpp \ + LTKShapeSample.cpp |