diff options
Diffstat (limited to 'src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke')
10 files changed, 0 insertions, 2375 deletions
diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/.prev_CMakeLists.txt b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/.prev_CMakeLists.txt deleted file mode 100644 index c553d43a..00000000 --- a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/.prev_CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Generated from substroke.pro. - -##################################################################### -## substroke Generic Library: -##################################################################### - -qt_add_cmake_library(substroke - MODULE - INSTALL_DIRECTORY "$$[QT_INSTALL_PLUGINS]/lipi_toolkit" - EXCEPTIONS - OUTPUT_DIRECTORY "${QT_BUILD_DIR}/plugins/lipi_toolkit" - SOURCES - SubStroke.cpp SubStroke.h - SubStrokeShapeFeature.cpp SubStrokeShapeFeature.h - SubStrokeShapeFeatureExtractor.cpp SubStrokeShapeFeatureExtractor.h - INCLUDE_DIRECTORIES - ../../../../include - ../../../../util/lib - ../common - PUBLIC_LIBRARIES - Qt::Core - Qt::Gui -) -qt_disable_warnings(substroke) - -#### Keys ignored in scope 1:.:.:substroke.pro:<TRUE>: -# LIPILIBS = "ltkcommon" "ltkutil" "featureextractorcommon" - -## Scopes: -##################################################################### - -qt_extend_target(substroke CONDITION WIN32 - DEFINES - SUBSTROKE_EXPORTS - PUBLIC_LIBRARIES - Advapi32.lib -) - -qt_extend_target(substroke CONDITION NOT LIPILIBS_ISEMPTY - PUBLIC_LIBRARIES - # Remove: L/lib -) - -qt_autogen_tools_initial_setup(substroke) diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/CMakeLists.txt b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/CMakeLists.txt deleted file mode 100644 index caf50828..00000000 --- a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Generated from substroke.pro. - -##################################################################### -## substroke Generic Library: -##################################################################### - -qt_add_cmake_library(substroke - MODULE - INSTALL_DIRECTORY "${INSTALL_PLUGINSDIR}/lipi_toolkit" # special case - EXCEPTIONS - OUTPUT_DIRECTORY "${QT_BUILD_DIR}/plugins/lipi_toolkit" - SOURCES - SubStroke.cpp SubStroke.h - SubStrokeShapeFeature.cpp SubStrokeShapeFeature.h - SubStrokeShapeFeatureExtractor.cpp SubStrokeShapeFeatureExtractor.h - INCLUDE_DIRECTORIES - ../../../../include - ../../../../util/lib - ../common - PUBLIC_LIBRARIES - Qt::Core - Qt::Gui -) -qt_disable_warnings(substroke) - -#### Keys ignored in scope 1:.:.:substroke.pro:<TRUE>: -# LIPILIBS = "ltkcommon" "ltkutil" "featureextractorcommon" - -## Scopes: -##################################################################### - -qt_extend_target(substroke CONDITION WIN32 - DEFINES - SUBSTROKE_EXPORTS - PUBLIC_LIBRARIES - Advapi32.lib -) - -qt_extend_target(substroke CONDITION NOT LIPILIBS_ISEMPTY - PUBLIC_LIBRARIES - # Remove: L/lib -) - -qt_autogen_tools_initial_setup(substroke) diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStroke.cpp b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStroke.cpp deleted file mode 100644 index 8484b39d..00000000 --- a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStroke.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/***************************************************************************************** -* 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: $ - * $Revision: $ - * $Author: $ - * - ************************************************************************/ -// SubStroke.cpp : Defines the entry point for the DLL application. - -#include "SubStroke.h" -#include "SubStrokeShapeFeatureExtractor.h" -#include "LTKShapeFeatureExtractor.h" -#include "SubStrokeShapeFeature.h" -#include "LTKErrors.h" - - -#ifdef _WIN32 -#include <windows.h> -BOOL APIENTRY DllMain(HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} -#endif - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : createShapeFeatureExtractor - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : int: - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -int createShapeFeatureExtractor(const LTKControlInfo& controlInfo, - LTKShapeFeatureExtractor** outFeatureExtractor) -{ - try - { - *outFeatureExtractor = new SubStrokeShapeFeatureExtractor(controlInfo); - } - catch(LTKException e) - { - *outFeatureExtractor = NULL; - - LTKReturnError(e.getErrorCode()); - } - - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : deleteShapeFeatureExtractor - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : int: - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -int deleteShapeFeatureExtractor(LTKShapeFeatureExtractor *obj) -{ - if ( obj != NULL ) - { - delete obj; - obj = NULL; - } - - return 0; -} diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStroke.def b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStroke.def deleted file mode 100644 index c35a826e..00000000 --- a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStroke.def +++ /dev/null @@ -1,3 +0,0 @@ -EXPORTS - createShapeFeatureExtractor @1 - deleteShapeFeatureExtractor @2
\ No newline at end of file diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStroke.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStroke.h deleted file mode 100644 index 125ab5ae..00000000 --- a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStroke.h +++ /dev/null @@ -1,98 +0,0 @@ -/***************************************************************************************** -* 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: $ - * $Revision: $ - * $Author: $ - * - ************************************************************************/ - -#ifndef __SUBSTROKE_H__ -#define __SUBSTROKE_H__ - -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the SUBSTROKE_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// SUBSTROKE_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -#ifdef _WIN32 -#ifdef SUBSTROKE_EXPORTS -#define SUBSTROKE_API __declspec(dllexport) -#else -#define SUBSTROKE_API __declspec(dllimport) -#endif //ifdef SUBSTROKE_EXPORTS -#else -#define SUBSTROKE_API -#endif //#ifdef _WIN32 - - -#include "LTKTypes.h" -#include "LTKLoggerUtil.h" - -class LTKShapeFeatureExtractor; -class LTKShapeFeature; - -/** @defgroup SubStrokeShapeFeatureExtractor -*@brief The SubStrokeShapeFeatureExtractor -*/ - -/** -* @ingroup SubStrokeShapeFeatureExtractor -* @file SubStroke.cpp -* <p> -* The functions exported by the DLL -* - ::createShapeFeatureExtractor -* - ::deleteShapeFeatureExtractor -*/ - -/** -* @brief Returns a pointer to the instance of SubStrokeShapeFeatureExtractor -* -* <p> -* This function is based on run-time polymorphism. It creates an instance of -* SubStrokeShapeFeatureExtractor at run-time and returns it as a pointer to the base class <i>LTKShapeFeatureExtractor</i> -* </p> -* -* @param none -* -* @return Pointer to LTKShapeFeatureExtractor -*/ -extern "C" SUBSTROKE_API int createShapeFeatureExtractor( - const LTKControlInfo& controlInfo, - LTKShapeFeatureExtractor** outFeatureExtractor); - -/** -* @brief Deletes the feature extractor instance. -* -* <p> -* This function cleans up all the memory allocations done by the feature extractor by calling it's destructor. -* </p> -* -* @param featureExtractorPtr - Pointer to LTKShapeFeatureExtractor. -* -* @return 0 on Success -*/ -extern "C" SUBSTROKE_API int deleteShapeFeatureExtractor(LTKShapeFeatureExtractor *featureExtractorPtr); - -#endif //#ifndef __SUBSTROKE_H__
\ No newline at end of file diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeature.cpp b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeature.cpp deleted file mode 100644 index fb282d31..00000000 --- a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeature.cpp +++ /dev/null @@ -1,675 +0,0 @@ -/***************************************************************************************** -* 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: $ - * $Revision: $ - * $Author: $ - * - ************************************************************************/ -/************************************************************************ - * FILE DESCR: Implementation for SubStrokeShapeFeature module - * - * CONTENTS: - * - * AUTHOR: Tanmay Mondal - * - * DATE: February 2009 - * CHANGE HISTORY: - * Author Date Description of change - ************************************************************************/ -#include "SubStrokeShapeFeature.h" -#include "LTKStringUtil.h" -#include <sstream> - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : Default Constructor - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -SubStrokeShapeFeature::SubStrokeShapeFeature(): -m_data_delimiter(",") -{ -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : Parameterized Constructor - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -SubStrokeShapeFeature::SubStrokeShapeFeature(vector<float>& inSlopeVector,float inCgX,float inCgY,float inLength): -m_slopeVector(inSlopeVector), -m_xComponentOfCenterOfGravity(inCgX), -m_yComponentOfCenterOfGravity(inCgY), -m_subStrokeLength(inLength), -m_data_delimiter(",") -{ -} - - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : Default Destructor - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -SubStrokeShapeFeature::~SubStrokeShapeFeature() -{ -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : clone - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -LTKShapeFeaturePtr SubStrokeShapeFeature::clone() const -{ - SubStrokeShapeFeature* pointInst = new SubStrokeShapeFeature(); - - //set the value of the tan theta - vector<float> tempSlopeVector; - - this->getSlopeVector(tempSlopeVector); - - pointInst->setSlopeVector(tempSlopeVector); - - //set the value of center of gravity - pointInst->setXcomponentOfCenterOfGravity(this->getXcomponentOfCenterOfGravity()); - pointInst->setYcomponentOfCenterOfGravity(this->getYcomponentOfCenterOfGravity()); - - //set the value of the length - pointInst->setSubStrokeLength(this->getSubStrokeLength()); - - return (LTKShapeFeaturePtr)pointInst; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : getDistance - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -void SubStrokeShapeFeature::getDistance(const LTKShapeFeaturePtr& shapeFeaturePtr, - float& outDistance) const -{ - - float xDiff = 0.0, yDiff =0.0; - - float sumSlopeDiff = 0.0; - - int slopeIndex = 0; - - int numSlope = 0; - - float slopeDiff = 0.0, tempSlopeDiff1 = 0.0, tempSlopeDiff2 = 0.0; - - float lengthDiff = 0.0; - - floatVector featureVector; - - SubStrokeShapeFeature *inSubStrokeFeature = (SubStrokeShapeFeature*)(shapeFeaturePtr.operator ->()); - - inSubStrokeFeature->getSlopeVector(featureVector); - - numSlope = featureVector.size(); - - // feature vector dimension for each substroke is 8 (NUMBER_OF_SLOPE + 3) - // The constant 3 in the above corresponds to x,y coordinates of center of gravity of the substroke and its length - - if(numSlope != (inSubStrokeFeature->getFeatureDimension()-3)) - { - //write log - return; // error - } - - // compute the distance between the slope vectors of two instances of SubStrokeShapeFeature - for(slopeIndex = 0; slopeIndex < numSlope; ++slopeIndex) - { - // difference between two slope components - tempSlopeDiff1 = fabs((m_slopeVector[slopeIndex]) - featureVector[slopeIndex]); - - tempSlopeDiff2 = fabs((360.0 - tempSlopeDiff1)); - - // take the minimum of the above two differences to take care of the circular nature of slope function - if(tempSlopeDiff1 > tempSlopeDiff2) - slopeDiff = tempSlopeDiff2; - else - slopeDiff = tempSlopeDiff1; - - sumSlopeDiff += slopeDiff; - - } - - // compute the distance between the center of gravity of two instances of SubStrokeShapeFeature - xDiff = fabs((m_xComponentOfCenterOfGravity) - inSubStrokeFeature->getXcomponentOfCenterOfGravity()); - - yDiff = fabs((m_yComponentOfCenterOfGravity) - inSubStrokeFeature->getYcomponentOfCenterOfGravity()); - - // compute the difference between the length of two instances of SubStrokeShapeFeature - lengthDiff = fabs((m_subStrokeLength) - inSubStrokeFeature->getSubStrokeLength()); - - outDistance = (sumSlopeDiff + (xDiff * xDiff) + (yDiff * yDiff) + lengthDiff); -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : initialize - * DESCRIPTION : initialize the feature instance from string - * ARGUMENTS : string: initString - * RETURNS : int: - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -int SubStrokeShapeFeature::initialize(const string& initString) -{ - - int index; - - stringVector tokens; - - LTKStringUtil::tokenizeString(initString, m_data_delimiter, tokens); - - int tokensSize = tokens.size(); - - //code for converting the string feature in to value and initialised the feature vector - if(tokensSize != getFeatureDimension()) - { - //write log - //invalide size of feature vector - return FAILURE; //returning an error - } - - for( index = 0; index < tokensSize - 3; ++index ) - { - m_slopeVector.push_back(LTKStringUtil::convertStringToFloat(tokens[index])); - } - - m_xComponentOfCenterOfGravity = LTKStringUtil::convertStringToFloat(tokens[index]); - - m_yComponentOfCenterOfGravity = LTKStringUtil::convertStringToFloat(tokens[index+1]); - - m_subStrokeLength = LTKStringUtil::convertStringToFloat(tokens[index+2]); - - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : initialize - * DESCRIPTION : initialize the feature instance - * ARGUMENTS : floatVector: initFloatVector - * RETURNS : int: - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -int SubStrokeShapeFeature::initialize(const floatVector& initFloatVector) -{ - - int index; - - int vectorSize = initFloatVector.size(); - - if(vectorSize != getFeatureDimension() ) - { - //write log - //invalide size of feature vector - return FAILURE; //returning an error - } - - for( index = 0; index < vectorSize - 3; ++index ) - { - m_slopeVector.push_back(initFloatVector[index]); - } - - m_xComponentOfCenterOfGravity = initFloatVector[index]; - - m_yComponentOfCenterOfGravity = initFloatVector[index+1]; - - m_subStrokeLength = initFloatVector[index+2]; - - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : toFloatVector - * DESCRIPTION : To convert feature to a float vector - * ARGUMENTS : vector<float>: holds the floating point value of feature - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -int SubStrokeShapeFeature::toFloatVector(vector<float>& outFloatVec) -{ - - int slopeIndex; - - int numSlope = m_slopeVector.size(); - - if(numSlope != (getFeatureDimension() - 3)) - { - //write log - //invalide size of angle vector - return FAILURE; //returning an error - } - - for( slopeIndex = 0; slopeIndex < numSlope; ++slopeIndex) - { - outFloatVec.push_back(m_slopeVector[slopeIndex]); - } - - outFloatVec.push_back(m_xComponentOfCenterOfGravity); - - outFloatVec.push_back(m_yComponentOfCenterOfGravity); - - outFloatVec.push_back(m_subStrokeLength); - - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : toString - * DESCRIPTION : To convert the feature to a string - * ARGUMENTS : string : holds the string value of feature - * RETURNS : NONE - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -void SubStrokeShapeFeature::toString(string& outStrFeat) const -{ - - ostringstream tempString; - - int slopeIndex; - - int numSlope = m_slopeVector.size(); - - if(numSlope != NUMBER_OF_SLOPE) - { - //write log - //invalide size of angle vector - return; //returning an error - } - - //convert the value of the feture vector to string - for( slopeIndex = 0; slopeIndex < numSlope; slopeIndex++) - { - tempString << m_slopeVector[slopeIndex] << m_data_delimiter; - } - - tempString << m_xComponentOfCenterOfGravity << m_data_delimiter - << m_yComponentOfCenterOfGravity << m_data_delimiter - << m_subStrokeLength; - - - outStrFeat = tempString.str(); - -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : getSlopeVector - * DESCRIPTION : - * ARGUMENTS : vector<float>: outSlopeVector - * RETURNS : none - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -void SubStrokeShapeFeature::getSlopeVector(vector<float>& outSlopeVector) const -{ - outSlopeVector = m_slopeVector; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : getSubStrokeLength - * DESCRIPTION : Ratio of the length and normalised height - * ARGUMENTS : none - * RETURNS : float: m_subStrokeLength - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -float SubStrokeShapeFeature::getSubStrokeLength() const -{ - return m_subStrokeLength; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : getXcomponentOfCenterOfGravity - * DESCRIPTION : X co-ordinate of CG - * ARGUMENTS : none - * RETURNS : float: m_xComponentOfCenterOfGravity - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -float SubStrokeShapeFeature::getXcomponentOfCenterOfGravity() const -{ - return m_xComponentOfCenterOfGravity; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : getYcomponentOfCenterOfGravity - * DESCRIPTION : Y co-ordinate of CG - * ARGUMENTS : none - * RETURNS : float: m_yComponentOfCenterOfGravity - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -float SubStrokeShapeFeature::getYcomponentOfCenterOfGravity() const -{ - return m_yComponentOfCenterOfGravity; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : setSlopeVector - * DESCRIPTION : set the slope vector of substroke - * ARGUMENTS : vector<float>: inSlopeVector - * RETURNS : none - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -void SubStrokeShapeFeature::setSlopeVector(const vector<float>& inSlopeVector) -{ - m_slopeVector = inSlopeVector; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : setSubStrokeLength - * DESCRIPTION : set the length of the substroke - * ARGUMENTS : float: length - * RETURNS : none - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -void SubStrokeShapeFeature::setSubStrokeLength(float inSubStrokeLength) -{ - m_subStrokeLength = inSubStrokeLength; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : setXcomponentOfCenterOfGravity - * DESCRIPTION : - * ARGUMENTS : float: x value - * RETURNS : none - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -void SubStrokeShapeFeature::setXcomponentOfCenterOfGravity(float inX) -{ - m_xComponentOfCenterOfGravity = inX; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : setYcomponentOfCenterOfGravity - * DESCRIPTION : - * ARGUMENTS : float: y value - * RETURNS : none - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -void SubStrokeShapeFeature::setYcomponentOfCenterOfGravity(float inY) -{ - m_yComponentOfCenterOfGravity = inY; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : addFeature - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ -int SubStrokeShapeFeature::addFeature(const LTKShapeFeaturePtr& secondFeature, - LTKShapeFeaturePtr& outResult ) const -{ - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : subtractFeature - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ -int SubStrokeShapeFeature::subtractFeature(const LTKShapeFeaturePtr& secondFeature, - LTKShapeFeaturePtr& outResult ) const -{ - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : scaleFeature - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ -int SubStrokeShapeFeature::scaleFeature(float alpha, LTKShapeFeaturePtr& outResult) const -{ - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : getFeatureDimension - * DESCRIPTION : - * ARGUMENTS : none - * RETURNS : int: dimension of the feature - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ -int SubStrokeShapeFeature::getFeatureDimension() -{ - // The constant 3 in the above corresponds to x,y coordinates of center of gravity of the substroke and its length - return (NUMBER_OF_SLOPE + 3); -} -/********************************************************************************** -* AUTHOR : Balaji MNA. -* DATE : 01-July-2009 -* NAME : isPenUp -* DESCRIPTION : Get method for the penUp -* ARGUMENTS : none -* RETURNS : The PenUp value -* NOTES : -* CHANGE HISTROY -* Author Date Description of change -*************************************************************************************/ -bool SubStrokeShapeFeature::isPenUp() const -{ - return 0; - -} diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeature.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeature.h deleted file mode 100644 index 791ed9a7..00000000 --- a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeature.h +++ /dev/null @@ -1,200 +0,0 @@ -/***************************************************************************************** -* 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: $ - * $Revision: $ - * $Author: $ - * - ************************************************************************/ -/************************************************************************ - * FILE DESCR: Definitions for SubStrokeShapeFeature module - * - * CONTENTS: - * - * AUTHOR: Tanmay Mondal - * - * DATE: February 2009 - * CHANGE HISTORY: - * Author Date Description of change - ************************************************************************/ -#ifndef __SUBSTROKESHAPEFEATURE_H -#define __SUBSTROKESHAPEFEATURE_H - -#include "LTKShapeFeature.h" - -#define NUMBER_OF_SLOPE 5 - - -class SubStrokeShapeFeature : public LTKShapeFeature -{ - /** @name private data members */ - //@{ - -private: - - /** @brief slope value - m_slopeVector slop(five angle) extracted from one substrokes*/ - vector<float> m_slopeVector; - - /** @brief x value - m_xComponentOfCenterOfGravity, normalised x - value (by width) of the center of gravity of substrokes*/ - float m_xComponentOfCenterOfGravity; - - /**@brief y value - m_yComponentOfCenterOfGravity, normalised y - value (by height) of the center of gravity of substrokes*/ - float m_yComponentOfCenterOfGravity; - - /** @brief length value - m_subStrokeLength, this is the ratio of the total length of the substrokes and the normalised height of the character*/ - float m_subStrokeLength; - - /** @brief Delimiter character */ - string m_data_delimiter; - //@} - -public: - - /** @name Constructors and Destructor */ - //@{ - - /** - * Default Constructor. - */ - SubStrokeShapeFeature(); - - /** Parameterized Constructor */ - SubStrokeShapeFeature(vector<float>& inSlopeVector,float inCgX,float inCgY,float inLength); - - /** - * Default destructor. - */ - ~SubStrokeShapeFeature(); - - /** - * Returns the value of SubStrokeShapeFeature:: m_slopeVector - */ - void getSlopeVector(vector<float>& outSlopeVector) const; - - /** - * Returns the value of SubStrokeShapeFeature::m_subStrokeLength - */ - float getSubStrokeLength() const; - - /** - * Returns the value of SubStrokeShapeFeature::m_xComponentOfCenterOfGravity - */ - float getXcomponentOfCenterOfGravity() const; - - /** - * Returns the value of SubStrokeShapeFeature::m_yComponentOfCenterOfGravity - */ - float getYcomponentOfCenterOfGravity() const; - - /** - * Sets the value of SubStrokeShapeFeature::m_slopeVector - */ - void setSlopeVector(const vector<float>& inSlopeVector); - - /** - * Set the value of SubStrokeShapeFeature::m_subStrokeLength - */ - void setSubStrokeLength(float inSubStrokeLength); - - /** - * Set the value of SubStrokeShapeFeature::m_xComponentOfCenterOfGravity - */ - void setXcomponentOfCenterOfGravity(float inX); - - /** - * Set the value of SubStrokeShapeFeature::m_yComponentOfCenterOfGravity - */ - void setYcomponentOfCenterOfGravity(float inY); - - - /** - * @brief Initializes the SubStrokeShapeFeature from the string passed as parameter. - * - * <b>Semantics</b> - * - * - Tokenize the input string on SubStrokeShapeFeature::m_data_delimiter using StringTokenizer::tokenizeString - * - Initialize the data members of the class with the tokens returned. - * - * @param initString : string& : Reference to the initialization string. - * - * @return FAILURE : If the initalization string contains more than two tokens (after tokenizing on AngleShapeFeature::m_data_delimiter) - * @return SUCCESS : If initialization done without any errors. - * - */ - int initialize(const string& initString); - - int initialize(const floatVector& initFloatVector); - - /** - * @brief Gives the floating point representation of the SubStrokeShapeFeature instance - */ - int toFloatVector(vector<float>& outFloatVec); - - /** - * @brief Gives the string representation of the SubStrokeShapeFeature instance - */ - void toString(string& outStrFeat) const; - - - LTKShapeFeaturePtr clone() const; - - /** - * @brief Gives the distance between two SubStrokeShapeFeature instance - */ - void getDistance(const LTKShapeFeaturePtr& shapeFeaturePtr, float& outDistance) const; - - /** - * @brief Adds two SubStrokeShapeFeature instances. - * - * @param secondFeature : LTKShapeFeature* : Base class pointer holding pointer to SubStrokeShapeFeature instance - * - * @return LTKShapeFeature* : Pointer to SubStrokeShapeFeature instance holding the result of addition. - * - */ - int addFeature(const LTKShapeFeaturePtr& secondFeature, LTKShapeFeaturePtr& outResult ) const ; - - /** - * @brief Subtracts two SubStrokeShapeFeature instances. - * - * @param secondFeature : LTKShapeFeature* : Base class pointer holding pointer to SubStrokeShapeFeature instance - * - * @return LTKShapeFeature* : Pointer to SubStrokeShapeFeature instance holding the result of subtraction. - * - */ - int subtractFeature(const LTKShapeFeaturePtr& secondFeature, LTKShapeFeaturePtr& outResult ) const ; - - int scaleFeature(float alpha, LTKShapeFeaturePtr& outResult) const ; - - int getFeatureDimension(); - - /** - * Returns the value of the class data member SubStrokeShapeFeature::m_penUp - */ - bool isPenUp() const; -}; - -#endif //#ifndef __SUBSTROKESHAPEFEATURE_H diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeatureExtractor.cpp b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeatureExtractor.cpp deleted file mode 100644 index 87e0cd05..00000000 --- a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeatureExtractor.cpp +++ /dev/null @@ -1,1035 +0,0 @@ -/***************************************************************************************** -* 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: $ - * $Revision: $ - * $Author: $ - * - ************************************************************************/ -/************************************************************************ - * FILE DESCR: Implementation for SubStroke feature extractor module - * - * CONTENTS: - * - * AUTHOR: Tanmay Mondal - * - * DATE: February 2009 - * CHANGE HISTORY: - * Author Date Description of change - ************************************************************************/ - -#include "SubStrokeShapeFeatureExtractor.h" -#include "SubStrokeShapeFeature.h" -#include "LTKTraceGroup.h" -#include "LTKTrace.h" -#include "LTKChannel.h" -#include "LTKTraceFormat.h" -#include "LTKConfigFileReader.h" -#include "LTKMacros.h" -#include "LTKPreprocDefaults.h" -#include "LTKException.h" -#include "LTKErrors.h" -#include "LTKLoggerUtil.h" - - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : SubStrokeShapeFeatureExtractor - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -SubStrokeShapeFeatureExtractor::SubStrokeShapeFeatureExtractor(const LTKControlInfo& controlInfo) -{ - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " << - "SubStrokeShapeFeatureExtractor::SubStrokeShapeFeatureExtractor()" << endl; - - string cfgFilePath = ""; - - // Config file - if ( ! ((controlInfo.lipiRoot).empty()) && - ! ((controlInfo.projectName).empty()) && - ! ((controlInfo.profileName).empty()) && - ! ((controlInfo.cfgFileName).empty())) - { - cfgFilePath = (controlInfo.lipiRoot) + PROJECTS_PATH_STRING + - (controlInfo.projectName) + PROFILE_PATH_STRING + - (controlInfo.profileName) + SEPARATOR + - (controlInfo.cfgFileName) + CONFIGFILEEXT; - } - else if ( ! ((controlInfo.cfgFilePath).empty() )) - { - cfgFilePath = controlInfo.cfgFilePath; - } - else - { - throw LTKException(EINVALID_PROJECT_NAME); - } - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " << - "SubStrokeShapeFeatureExtractor::SubStrokeShapeFeatureExtractor()" << endl; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : getShapeFeatureInstance - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -LTKShapeFeaturePtr SubStrokeShapeFeatureExtractor::getShapeFeatureInstance() -{ - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " << - "SubStrokeShapeFeatureExtractor::getShapeFeatureInstance()" << endl; - - LTKShapeFeaturePtr tempPtr(new SubStrokeShapeFeature); - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " << - "SubStrokeShapeFeatureExtractor::getShapeFeatureInstance()" << endl; - - return tempPtr; -} - - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : extractFeatures - * DESCRIPTION : calculate the feature of the Ink file - * ARGUMENTS : - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -int SubStrokeShapeFeatureExtractor::extractFeatures(const LTKTraceGroup& inTraceGroup, - vector<LTKShapeFeaturePtr>& outFeatureVec) -{ - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " << - "SubStrokeShapeFeatureExtractor::extractFeatures()" << endl; - - int numberOfTraces = inTraceGroup.getNumTraces(); - - //validating inTraceGroup - if (numberOfTraces == 0 ) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - EEMPTY_TRACE_GROUP << " : " << getErrorMessage(EEMPTY_TRACE_GROUP)<< - " SubStrokeShapeFeatureExtractor::extractFeatures" <<endl; - - LTKReturnError(EEMPTY_TRACE_GROUP); - } - - SubStrokeShapeFeature *featurePtr = NULL; - - int numberOfSubstrokes = 0; // number of substrokes from a trace group - - int slopeIndex = 0; // index of the point - - int totalNumberOfSlopeValues = 0; // total number of slope values for input tracegroup - - int lengthIndex=0; // index of the substroke length vector - - int cgIndex = 0; // index of the center of gravity vector - - float maxX=0.0,maxY=0.0,minX=0.0,minY=0.0; - - float subStokeLength = 0.0; // length of one substroke - - float centerOfGravityX = 0.0; // x component of center of gravity of one substroke - - float centerOfGravityY = 0.0; // y component of center of gravity of one substroke - - vector<float> subStrokeSlopeVector; // slope values obtained from all the substrokes - - vector<float> subStrokeLengthVector; // lengths of all substrokes - - vector<float> subStrokeCenterOfGravityVector; // center of gravity of all substrokes - - vector<float> tempSlope; // slope values of one substroke - - vector<struct subStrokePoint> subStrokeVec; // store all the sub-strokes - - // extract the substrokes from input trace group, and populate subStrokeVec - int errorCode = extractSubStrokesFromInk(inTraceGroup, subStrokeVec); - - if( errorCode != SUCCESS) - { - LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< errorCode << " " << - " SubStrokeShapeFeatureExtractor::extractFeatures" <<endl; - - LTKReturnError(errorCode); - } - - // compute the features from each substroke in subStrokeVec - errorCode = extractFeaturesFromSubStroke(subStrokeVec,subStrokeSlopeVector,subStrokeLengthVector,subStrokeCenterOfGravityVector); - - if(errorCode != SUCCESS) - { - LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< errorCode << " " << - " SubStrokeShapeFeatureExtractor::extractFeatures" <<endl; - - LTKReturnError(errorCode); - } - - inTraceGroup.getBoundingBox(minX,minY,maxX,maxY); - - //computing size of subStrokeSlopeVector - totalNumberOfSlopeValues = subStrokeSlopeVector.size(); - - if(totalNumberOfSlopeValues == 0) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - EEMPTY_SLOPE_VECTOR << " : " << getErrorMessage(EEMPTY_SLOPE_VECTOR)<< - " SubStrokeShapeFeatureExtractor::extractFeatures" <<endl; - - LTKReturnError(EEMPTY_SLOPE_VECTOR); - } - - - //populating outFeatureVec with the features computed - for(slopeIndex=0; slopeIndex < totalNumberOfSlopeValues; ++slopeIndex) - { - if(subStrokeSlopeVector.at(slopeIndex) == SUBSTROKES_ANGLE_DELIMITER) - { - if(tempSlope.size() != NUMBER_OF_SLOPE) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - EINVALID_SLOPE_VECTOR_DIMENSION << " : " << getErrorMessage(EINVALID_SLOPE_VECTOR_DIMENSION)<< - " SubStrokeShapeFeatureExtractor::extractFeatures" <<endl; - - return FAILURE; - } - - centerOfGravityX = ((subStrokeCenterOfGravityVector.at(cgIndex) / (maxX - minX)) * 100.0); - - centerOfGravityY = ((subStrokeCenterOfGravityVector.at((cgIndex + 1)) / (maxY - minY)) * 100.0); - - subStokeLength = ((subStrokeLengthVector.at(lengthIndex) / (maxY - minY)) * 100.0); - - featurePtr = new SubStrokeShapeFeature(tempSlope,centerOfGravityX ,centerOfGravityY,subStokeLength); - - //***FEATURE VECTOR*** - - outFeatureVec.push_back(LTKShapeFeaturePtr(featurePtr)); - - featurePtr = NULL; - - ++numberOfSubstrokes; - - tempSlope.clear(); - - ++lengthIndex; - - cgIndex += 2; - - continue; - } - tempSlope.push_back(subStrokeSlopeVector.at(slopeIndex)); - } - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " << - "SubStrokeShapeFeatureExtractor::extractFeatures()" << endl; - - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : computeSlope - * DESCRIPTION : calculate slope of the line joining given two points - * ARGUMENTS : - * RETURNS : float - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -int SubStrokeShapeFeatureExtractor::computeSlope(const float inDeltaX, const float inDeltaY, float& outSlope) -{ - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " << - "SubStrokeShapeFeatureExtractor::computeSlope()" << endl; - - outSlope = -1.0; - - if(inDeltaX == 0.0) - { - if(inDeltaY > 0.0) - { - outSlope = 90.0; - } - if(inDeltaY < 0.0) - { - outSlope = 270.0; - } - if(inDeltaY == 0.0) - { - outSlope = 0.0; - } - } - - if(inDeltaX > 0.0) - { - outSlope = (((atan(inDeltaY/inDeltaX)) * PI_DEGREE) / PI); - - if(outSlope < 0.0) - { - outSlope += (2 * PI_DEGREE); - } - } - - if(inDeltaX < 0.0) - { - outSlope = (((atan(inDeltaY/inDeltaX)) * PI_DEGREE) / PI); - - outSlope += PI_DEGREE; - } - - if(outSlope < 0.0) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - EINVALID_SLOPE << " : " << getErrorMessage(EINVALID_SLOPE)<< - " SubStrokeShapeFeatureExtractor::computeSlope" <<endl; - - LTKReturnError(EINVALID_SLOPE); - } - - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " << - "SubStrokeShapeFeatureExtractor::computeSlope()" << endl; - - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : extractSubStrokesFromInk - * DESCRIPTION : extract substroke from the Ink - * ARGUMENTS : - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - -int SubStrokeShapeFeatureExtractor::extractSubStrokesFromInk(const LTKTraceGroup& inTraceGroup, vector<struct subStrokePoint>& outSubStrokeVector) -{ - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " << - "SubStrokeShapeFeatureExtractor::extractSubStrokesFromInk()" << endl; - - int numberOfTraces = inTraceGroup.getNumTraces(); - - if (numberOfTraces == 0 ) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - EEMPTY_TRACE_GROUP << " : " << getErrorMessage(EEMPTY_TRACE_GROUP)<< - " SubStrokeShapeFeatureExtractor::extractSubStrokesFromInk" <<endl; - - LTKReturnError(EEMPTY_TRACE_GROUP); - } - - int errorCode = -1; - - int dimension = 0; // stores the number of points in each trace of the inTraceGroup - - int landMarkPoint = 0; // first point of each sub-stroke - - float landMarkSlope = 0.0; // slope of the line joining the land mark point and the following point - - float nextSlope = 0.0; // slope of the line joining the consicutive two points - - struct subStrokePoint tempSubStroke; // stores sub-stroke - - vector<struct subStrokePoint> subStrokeVec; // stores all the sub-strokes - - vector<float> slopeVector; // stores the angle made with x-axis for each point of trace - - bool segment; // true if stroke segment into substroke - - LTKTraceVector allTraces = inTraceGroup.getAllTraces(); - - LTKTraceVector::iterator traceIter = allTraces.begin(); - LTKTraceVector::iterator traceEnd = allTraces.end(); - - // Segmenting inTraceGroup into substrokes - for (; traceIter != traceEnd ; ++traceIter) - { - floatVector tempxVec, tempyVec; - - //compute all the slope values from points on the trace - if( (errorCode = getSlopeFromTrace(*traceIter,slopeVector)) != SUCCESS) - { - LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< errorCode << " " << - " SubStrokeShapeFeatureExtractor::extractSubStrokesFromInk" <<endl; - - LTKReturnError(errorCode); - } - - // computing total number of points present in a trace - dimension = (*traceIter).getNumberOfPoints(); - - // Validating the slopeVector, its size should be equal to one less than number of points in trace - if((dimension-1) != slopeVector.size()) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - EINVALID_SLOPE_VECTOR_DIMENSION << " : " << getErrorMessage(EINVALID_SLOPE_VECTOR_DIMENSION)<< - " SubStrokeShapeFeatureExtractor::extractSubStrokesFromInk" <<endl; - - LTKReturnError(EINVALID_SLOPE_VECTOR_DIMENSION); - } - - (*traceIter).getChannelValues("X", tempxVec); - - (*traceIter).getChannelValues("Y", tempyVec); - - // initialised landmark point for next stroke, assume that the first point is - // landmark point for every stroke - landMarkPoint = 0; - - - int pointIndex = 0; - for( pointIndex = 0; pointIndex < (dimension - 1); ++pointIndex) - { - - //for the first point in the trace, landMarkSlope and - //nextSlope will be the same - landMarkSlope = slopeVector[landMarkPoint]; - - nextSlope = slopeVector[pointIndex]; - - //check of the trace can be segmented at the current point - if( (errorCode = canSegmentStrokes(landMarkSlope,nextSlope, segment)) != SUCCESS) - { - LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< errorCode << " " << - " SubStrokeShapeFeatureExtractor::extractSubStrokesFromInk" <<endl; - - LTKReturnError(errorCode); - } - - if( segment ) - { - // Segment the stroke into substroke - outSubStrokeVector[outSubStrokeVector.size() - 1].penUp = true; - - // set new landmark point for next substrokes of stroke - landMarkPoint = pointIndex; - - } // end if ( segment ) - - //substrokes continue - tempSubStroke.X = tempxVec[pointIndex]; - tempSubStroke.Y = tempyVec[pointIndex]; - tempSubStroke.penUp = false; - - outSubStrokeVector.push_back(tempSubStroke); - - - } // end for - - // terminal point of a stroke - tempSubStroke.X = tempxVec[pointIndex]; - tempSubStroke.Y = tempyVec[pointIndex]; - tempSubStroke.penUp = true; - - outSubStrokeVector.push_back(tempSubStroke); - - } // end traceItr - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " << - "SubStrokeShapeFeatureExtractor::extractSubStrokesFromInk()" << endl; - - - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : extractFeatureFromSubStroke - * DESCRIPTION : - * ARGUMENTS : extract feature vector of dimension (NUMBER_OF_THETA+3) from a given substroke - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - - int SubStrokeShapeFeatureExtractor::extractFeaturesFromSubStroke(const vector<struct subStrokePoint>& inSubStrokeVector, vector<float>& outSlope, vector<float>& outLength, vector<float>& outCenterOfGravity) -{ - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " << - "SubStrokeShapeFeatureExtractor::extractFeatureFromSubStroke()" << endl; - - int numSubStrokesPoints = 0; - - //total number of points present in all substrokes - numSubStrokesPoints = inSubStrokeVector.size(); - - //validating inSubStrokeVector - if( numSubStrokesPoints <= 0 ) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - ENO_SUBSTROKE << " : " << getErrorMessage(ENO_SUBSTROKE)<< - " SubStrokeShapeFeatureExtractor::extractFeaturesFromSubStroke" <<endl; - - LTKReturnError(ENO_SUBSTROKE); - } - - int ptIndex = 0; // index of point in a trace - - int pointIndex = 0; // counter variable to loop over the points in a trace - - int currentPointIndex =0; // index of the current point - - int startIndxOfSubStrokes = 0; // starting index of the substroke - - float x = 0.0; // value of x-coordinate - - float y = 0.0; // value of y-coordinate - - float slope = 0.0; // store slope value - - float xDiff = 0.0; // difference in x-direction - - float yDiff = 0.0; // difference in y-direction - - float xTemp = 0.0; // temporary variable for x-coordinate - - float yTemp = 0.0; // temporary variable for y-coordinate - - float unitLength = 0.0; // length of each substroke after resampling - - float pointDistance = 0.0; // distance detween two consecutive point - - float residualDistance = 0.0; // distance between the last resampled point and the next original sample point - - float cumulativeDistance = 0.0; // sum of distances between consecutive points - - float segmentRatioLeft = 0.0, segmentRatioRight = 0.0; // ratio for segmenting the line joining two points - - float dx = 0.0, dy = 0.0; - - floatVector distanceVec; // vector to store distances between points - - struct subStrokePoint tempStroke; - - //vector to store all the substrokes - vector<struct subStrokePoint> subStrokeVec; - - //*************************************************************************// - // represent each extracted substroke from ink by six equidistant points - //*************************************************************************// - for(int ptIdx = 0; ptIdx < numSubStrokesPoints; ++ptIdx) - { - if(inSubStrokeVector[ptIdx].penUp) - { - // ignore substrokes whose length are less than thresold value - if(unitLength < SUBSTROKES_LENGTH_REJECT_THRESHOLD) - { - // initialised for next substroke - unitLength = 0.0; - - residualDistance = 0.0; - - ptIndex = 0; - - distanceVec.clear(); - - //starting index of the next substroke - startIndxOfSubStrokes = ptIdx+1; - - continue; - } - - // length of the extracted sub-strokes(curve length) - outLength.push_back(unitLength); - - // dividing to get NUMBER_OF_SLOPE number of points on each substroke - unitLength /= (NUMBER_OF_SLOPE); - - // adding x of first point - x = inSubStrokeVector[startIndxOfSubStrokes].X; - - // adding y of first point - y = inSubStrokeVector[startIndxOfSubStrokes].Y; - - tempStroke.X = x; - tempStroke.Y = y; - tempStroke.penUp = false; - - // pushing back the first point to subStrokeVec - subStrokeVec.push_back(tempStroke); - - // Genareting four equidistant points - for(pointIndex = 1; pointIndex < (NUMBER_OF_SLOPE); ++pointIndex) - { - cumulativeDistance = residualDistance; - - while(cumulativeDistance < unitLength) - { - cumulativeDistance += distanceVec.at(ptIndex++); - - if(ptIndex == 1) - { - currentPointIndex = (startIndxOfSubStrokes + ptIndex); - } - else - { - currentPointIndex++; - } - } - - if(ptIndex < 1) ptIndex = 1; - - segmentRatioRight = cumulativeDistance - unitLength; - - segmentRatioLeft = distanceVec.at(ptIndex -1) - segmentRatioRight; - - //interpolating to get equidistant points - if( fabs(segmentRatioLeft+segmentRatioRight) > EPS) - { - xTemp = (segmentRatioLeft* inSubStrokeVector[currentPointIndex].X + segmentRatioRight* inSubStrokeVector[currentPointIndex - 1].X)/(segmentRatioLeft+segmentRatioRight); - - yTemp = (segmentRatioLeft* inSubStrokeVector[currentPointIndex].Y + segmentRatioRight* inSubStrokeVector[currentPointIndex - 1].Y)/(segmentRatioLeft+segmentRatioRight); - } - else - { - xTemp = inSubStrokeVector[currentPointIndex].X; - - yTemp = inSubStrokeVector[currentPointIndex].Y; - } - - tempStroke.X = xTemp; - tempStroke.Y = yTemp; - tempStroke.penUp = false; - - subStrokeVec.push_back(tempStroke); - - residualDistance = segmentRatioRight; - } - - // adding x of the last point of the substroke - x = inSubStrokeVector[ptIdx].X; - - // adding y of the last point of the substroke - y = inSubStrokeVector[ptIdx].Y; - - tempStroke.X = x; - tempStroke.Y = y; - tempStroke.penUp = true; - - subStrokeVec.push_back(tempStroke); - - // initialised for next substroke - unitLength = 0.0; - - residualDistance = 0.0; - - ptIndex = 0; - - distanceVec.clear(); - - //starting index of the next substroke - startIndxOfSubStrokes = ptIdx+1; - } - else - { - - xDiff = (inSubStrokeVector[ptIdx].X - inSubStrokeVector[ptIdx + 1].X); - - yDiff = (inSubStrokeVector[ptIdx].Y - inSubStrokeVector[ptIdx + 1].Y); - - //distance between points. - pointDistance = (float) (sqrt(xDiff*xDiff + yDiff*yDiff)); - - // finding the length of a substroke. - unitLength += pointDistance; - - //storing distances between every two consecutive points in a substroke. - distanceVec.push_back(pointDistance); - } - } - - - //************************************************************************************************// - // compute the feature vector for each substroke after representing them by six equidistant points - //************************************************************************************************// - - // total number of points in all substrokes after genarating equidistant points - numSubStrokesPoints = 0; - - numSubStrokesPoints = subStrokeVec.size(); - - if( numSubStrokesPoints <= 0 ) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - ENO_SUBSTROKE << " : " << getErrorMessage(ENO_SUBSTROKE)<< - " SubStrokeShapeFeatureExtractor::extractFeaturesFromSubStroke" <<endl; - - LTKReturnError(ENO_SUBSTROKE); - } - - - int errorCode = -1; - - float sumOfX = 0.0; - float sumOfY = 0.0; - - //computing slopes and center of gravity values from the equidistant points extracted from each substroke - for(pointIndex = 0; pointIndex < numSubStrokesPoints; ++pointIndex) - { - if(!subStrokeVec[pointIndex].penUp) - { - - // Compute slope of line joining consecutive points in a substrokes - dx = (subStrokeVec[pointIndex + 1].X - subStrokeVec[pointIndex].X); - dy = (subStrokeVec[pointIndex + 1].Y - subStrokeVec[pointIndex].Y); - - if( (errorCode = computeSlope(dx,dy,slope)) != SUCCESS) - { - LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< errorCode << " " << - " SubStrokeShapeFeatureExtractor::extractFeaturesFromSubStroke" <<endl; - - LTKReturnError(errorCode); - } - - - outSlope.push_back(slope); - - sumOfX += subStrokeVec[pointIndex].X; - - sumOfY += subStrokeVec[pointIndex].Y; - - } - else - { - int div = (NUMBER_OF_SLOPE + 1); - - sumOfX += subStrokeVec[pointIndex].X; - - sumOfY += subStrokeVec[pointIndex].Y; - - sumOfX = sumOfX / (float)div; - - sumOfY = sumOfY / (float)div; - - outCenterOfGravity.push_back(sumOfX); - - outCenterOfGravity.push_back(sumOfY); - - outSlope.push_back(SUBSTROKES_ANGLE_DELIMITER); - - sumOfX = 0.0; - - sumOfY = 0.0; - - } - } - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " << - "SubStrokeShapeFeatureExtractor::extractFeatureFromSubStroke()" << endl; - - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : getDirectionCode - * DESCRIPTION : quantize the slope - * ARGUMENTS : - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ - int SubStrokeShapeFeatureExtractor::getDirectionCode(const float inSlope, int& outDirectionCode) -{ - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " << - "SubStrokeShapeFeatureExtractor::getDirectionCode()" << endl; - - //Validating inSlope - if(inSlope < 0.0) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - EINVALID_SLOPE << " : " << getErrorMessage(EINVALID_SLOPE)<< - " SubStrokeShapeFeatureExtractor::getDirectionCode" <<endl; - - LTKReturnError(EINVALID_SLOPE); - } - - outDirectionCode = 0; - - // return the octant value as slope value - - if((inSlope< ANGLE_HIGHER_LIMIT_1) || (inSlope >= ANGLE_HIGHER_LIMIT_8)) - { - outDirectionCode = DIRECTION_CODE_EAST; - } - - else if((inSlope < ANGLE_HIGHER_LIMIT_2) && (inSlope >=ANGLE_HIGHER_LIMIT_1)) - { - outDirectionCode = DIRECTION_CODE_NORTH_EAST; - } - - else if(((inSlope >= ANGLE_HIGHER_LIMIT_2) && (inSlope < ANGLE_HIGHER_LIMIT_3)) ) - { - outDirectionCode = DIRECTION_CODE_NORTH; - } - - else if( (inSlope < ANGLE_HIGHER_LIMIT_4 ) && (inSlope >= ANGLE_HIGHER_LIMIT_3)) - { - outDirectionCode = DIRECTION_CODE_NORTH_WEST; - } - - else if((inSlope >= ANGLE_HIGHER_LIMIT_4) && (inSlope < ANGLE_HIGHER_LIMIT_5)) - { - outDirectionCode = DIRECTION_CODE_WEST; - } - - else if((inSlope >= ANGLE_HIGHER_LIMIT_5) && (inSlope < ANGLE_HIGHER_LIMIT_6)) - { - outDirectionCode = DIRECTION_CODE_SOUTH_WEST; - } - - else if(((inSlope >= ANGLE_HIGHER_LIMIT_6) && (inSlope < ANGLE_HIGHER_LIMIT_7))) - { - outDirectionCode = DIRECTION_CODE_SOUTH; - } - - else if((inSlope >= ANGLE_HIGHER_LIMIT_7) && (inSlope < ANGLE_HIGHER_LIMIT_8)) - { - outDirectionCode = DIRECTION_CODE_SOUTH_EAST; - } - - if(outDirectionCode == 0) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - EINVALID_DIRECTION_CODE << " : " << - getErrorMessage(EINVALID_DIRECTION_CODE)<< - " SubStrokeShapeFeatureExtractor::getDirectionCode" <<endl; - - LTKReturnError(EINVALID_DIRECTION_CODE);; - } - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " << - "SubStrokeShapeFeatureExtractor::getDirectionCode()" << endl; - - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : canSegmentStrokes - * DESCRIPTION : decision is taken towards dividing a stroke into substroke - * ARGUMENTS : - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ -int SubStrokeShapeFeatureExtractor::canSegmentStrokes(const float inFirstSlope, const float inSecondSlope, bool& outSegment) -{ - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " << - "SubStrokeShapeFeatureExtractor::canSegmentStrokes()" << endl; - - //Validating slope values - if(inFirstSlope < 0.0 || inSecondSlope < 0.0) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - EINVALID_SLOPE << " : " << getErrorMessage(EINVALID_SLOPE)<< - " SubStrokeShapeFeatureExtractor::canSegmentStrokes" <<endl; - - LTKReturnError(EINVALID_SLOPE); - } - - int directionCodeOfFirstSlope = 0; - int directionCodeOfSecondSlope = 0; - - outSegment = false; - - int errorCode = -1; - - // Computing octants of hte inFirstSlope and inSecondSlope - if( (errorCode = getDirectionCode(inFirstSlope, directionCodeOfFirstSlope)) != SUCCESS) - { - LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< errorCode << " " << - " SubStrokeShapeFeatureExtractor::canSegmentStrokes" <<endl; - - LTKReturnError(errorCode); - } - - if( (errorCode = getDirectionCode(inSecondSlope, directionCodeOfSecondSlope)) != SUCCESS) - { - LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< errorCode << " " << - " SubStrokeShapeFeatureExtractor::canSegmentStrokes" <<endl; - - LTKReturnError(errorCode); - } - - if(abs(directionCodeOfSecondSlope - directionCodeOfFirstSlope) <= STROKE_SEGMENT_VALUE ) - outSegment = false; - else - outSegment = true; - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " << - "SubStrokeShapeFeatureExtractor::canSegmentStrokes()" << endl; - - return SUCCESS; -} - -/****************************************************************************** - * AUTHOR : Tanmay Mondal - * SUPERVISOR : Ujjwal Bhattacharya - * OTHER PLP : Kalikinkar Das - * ORGANIZATION : Indian Statistical Institute, Kolkata, India - * DEPARTMENT : Computer Vision and Pattern Recognition Unit - * DATE : Feb-2009 - * NAME : getSlopeFromTrace - * DESCRIPTION : - * ARGUMENTS : - * RETURNS : int - * NOTES : - * CHANGE HISTROY - * Author Date Description - ******************************************************************************/ -int SubStrokeShapeFeatureExtractor::getSlopeFromTrace(const LTKTrace& inTrace, vector<float>& outSlopeVector) -{ - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " << - "SubStrokeShapeFeatureExtractor::getSlopeFromTrace()" << endl; - - int dimension = 0; //Stores the number of points in a trace - - dimension = inTrace.getNumberOfPoints(); - - if(dimension == 0) - { - LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << - EEMPTY_TRACE << " : " << getErrorMessage(EEMPTY_TRACE)<< - " SubStrokeShapeFeatureExtractor::getSlopeFromTrace" <<endl; - - LTKReturnError(EEMPTY_TRACE); - } - - int pointIndex = 0; - - float dx = 0.0, dy = 0.0; //Variables to store differences in x and y-directions to compute slope - - float slope = 0.0; - - floatVector xVec, yVec; - - int errorCode = -1; - - if( (errorCode = inTrace.getChannelValues(X_CHANNEL_NAME, xVec))!= SUCCESS) - { - LOG(LTKLogger::LTK_LOGLEVEL_ERR) - <<"Error: SubStrokeShapeFeatureExtractor::getSlopeFromTrace"<<endl; - - LTKReturnError(errorCode); - } - - if( (errorCode = inTrace.getChannelValues(Y_CHANNEL_NAME, yVec)) != SUCCESS) - { - LOG(LTKLogger::LTK_LOGLEVEL_ERR) - <<"Error: SubStrokeShapeFeatureExtractor::getSlopeFromTrace"<<endl; - - LTKReturnError(errorCode); - } - - outSlopeVector.clear(); - - for(pointIndex=0; pointIndex < dimension-1; ++pointIndex) - { - dx = xVec[pointIndex+1] - xVec[pointIndex]; - - dy = yVec[pointIndex+1] - yVec[pointIndex]; - - if( (errorCode = computeSlope(dx, dy, slope)) != SUCCESS) - { - LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< errorCode << " " << - " SubStrokeShapeFeatureExtractor::getSlopeFromTrace" <<endl; - - LTKReturnError(errorCode); - } - - outSlopeVector.push_back(slope); - } - - LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " << - "SubStrokeShapeFeatureExtractor::getSlopeFromTrace()" << endl; - - return SUCCESS; -} diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeatureExtractor.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeatureExtractor.h deleted file mode 100644 index 7d803727..00000000 --- a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/SubStrokeShapeFeatureExtractor.h +++ /dev/null @@ -1,139 +0,0 @@ -/***************************************************************************************** -* 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: $ - * $Revision: $ - * $Author: $ - * - ************************************************************************/ -/************************************************************************ - * FILE DESCR: Definitions for SubStroke feature extractor module - * - * CONTENTS: - * - * AUTHOR: Tanmay Mondal - * - * DATE: February 2009 - * CHANGE HISTORY: - * Author Date Description of change - ************************************************************************/ -#ifndef __SUBSTROKESHAPEFEATUREEXTRACTOR_H -#define __SUBSTROKESHAPEFEATUREEXTRACTOR_H - -#define SUPPORTED_MIN_VERSION "3.0.0" - -// delimiter of the slope of extracted substroke -#define SUBSTROKES_ANGLE_DELIMITER -999.0 - -#define SUBSTROKES_LENGTH_REJECT_THRESHOLD 0.001 - -#define STROKE_SEGMENT_VALUE 0 - -#define SINGLE_SUBSTROKES 1 - -#define ANGLE_HIGHER_LIMIT_1 22.5 - -#define ANGLE_HIGHER_LIMIT_2 67.5 - -#define ANGLE_HIGHER_LIMIT_3 112.5 - -#define ANGLE_HIGHER_LIMIT_4 157.5 - -#define ANGLE_HIGHER_LIMIT_5 202.5 - -#define ANGLE_HIGHER_LIMIT_6 247.5 - -#define ANGLE_HIGHER_LIMIT_7 292.5 - -#define ANGLE_HIGHER_LIMIT_8 337.5 - -#define PI_DEGREE 180.0 - -#include "LTKShapeFeatureExtractor.h" - -class SubStrokeShapeFeatureExtractor : public LTKShapeFeatureExtractor -{ - -public: - /** @brief Constructor for the SubStroke feature extractor - * Gets the cfg file path from the contorInfo - * Reads the cfg variables and poputlates the member variables - * @param controlInfo: LTKControlInfo : The control information - * @return no return value as it is a constructor - */ - - SubStrokeShapeFeatureExtractor(const LTKControlInfo& controlInfo); - - int extractFeatures(const LTKTraceGroup& inTraceGroup, - vector<LTKShapeFeaturePtr>& outFeatureVec); - - LTKShapeFeaturePtr getShapeFeatureInstance(); - -private: - - //store extracted sub-strokes - struct subStrokePoint - { - float X; // x point - float Y; // y point - bool penUp; // If point is penup then penUp = 1 else penUp =0 - }; - - /** extract feature from sub strokes - */ - int extractFeaturesFromSubStroke(const vector<struct subStrokePoint>& inSubStrokeVector, - vector<float>& outSlope, - vector<float>& outLength, - vector<float>& outCenterOfGravity); - - /** extract the sub strokes from the preprocessed trace group - */ - int extractSubStrokesFromInk(const LTKTraceGroup& inTraceGroup, vector<struct subStrokePoint>& outSubStrokeVector); - - /** @brief claculate the angle - * inDeltaX,inDeltaY : float : the difference of x[i] and x[i+1] and difference of y[i] and y[i+1] of ink point - * float : the angle made with x axis and the point - */ - int computeSlope(const float inDeltaX, const float inDeltaY, float& outSlope); - - /** decide the octant of the point along the ink - * slope : float : value of the angle - * int : the octant code - */ - int getDirectionCode(const float inSlope, int& outDirectionCode); - - /** break the stroke into substrokes - * infirstSlope, insecondSlope : float : value of the slope - * int : SUCCESS : FAILURE - */ - int canSegmentStrokes(const float inFirstSlope, const float inSecondSlope, bool& outSegment); - - /** compute the slope of each point present in the tace - * inTrace : LTKTrace : value of a trace - * int : SUCCESS : FAILURE : errorcode - */ - int getSlopeFromTrace(const LTKTrace& inTrace, vector<float>& outSlopeVector); - -}; - -#endif //#ifndef __SUBSTROKESHAPEFEATUREEXTRACTOR_H diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/substroke.pro b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/substroke.pro deleted file mode 100644 index 804d1f42..00000000 --- a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/reco/shaperec/featureextractor/substroke/substroke.pro +++ /dev/null @@ -1,22 +0,0 @@ -LIPILIBS = ltkcommon ltkutil featureextractorcommon -include(../../../../lipiplugin.pri) - -INCLUDEPATH += \ - ../../../../util/lib \ - ../common \ - -HEADERS += \ - SubStroke.h \ - SubStrokeShapeFeature.h \ - SubStrokeShapeFeatureExtractor.h \ - -SOURCES += \ - SubStroke.cpp \ - SubStrokeShapeFeature.cpp \ - SubStrokeShapeFeatureExtractor.cpp \ - -win32 { - DEFINES += SUBSTROKE_EXPORTS - LIBS += Advapi32.lib - #DEF_FILE = SubStroke.def -} |