📄 nnshaperecognizer.h
字号:
/*****************************************************************************************
* 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-09-02 12:09:40 +0530 (Tue, 02 Sep 2008) $
* $Revision: 682 $
* $Author: sharmnid $
*
************************************************************************/
/************************************************************************
* FILE DESCR: Definitions for NN Shape Recognition module
*
* CONTENTS:
*
* AUTHOR: Saravanan R.
*
* DATE: January 23, 2007
* CHANGE HISTORY:
* Author Date Description of change
************************************************************************/
#ifndef __NNSHAPERECOGNIZER_H
#define __NNSHAPERECOGNIZER_H
/** Include files */
#include "LTKInc.h"
#include "LTKTypes.h"
#include "LTKMacros.h"
#include "LTKShapeRecognizer.h"
#include "LTKShapeRecoUtil.h"
#include "LTKShapeSample.h"
#include "LTKCheckSumGenerate.h"
#include "LTKDynamicTimeWarping.h"
/** Forward declaration of classes */
class LTKTraceGroup;
class LTKPreprocessorInterface;
class LTKShapeSample;
class LTKShapeFeatureExtractor;
class LTKShapeFeature;
#define SIMILARITY(distance) (1 / (distance + EPS ))
#define SUPPORTED_MIN_VERSION "2.1.0"
#ifdef _INTERNAL
class LTKAdapt;
#endif
typedef int (*FN_PTR_LOCAL_DISTANCE)(LTKShapeFeaturePtr, LTKShapeFeaturePtr,float&);
typedef int (*FN_PTR_CREATELTKLIPIPREPROCESSOR)(const LTKControlInfo& , LTKPreprocessorInterface** );
typedef int (*FN_PTR_DELETELTKLIPIPREPROCESSOR)(LTKPreprocessorInterface* );
/**
* @ingroup NNShapeRecognizer.h
* @brief The Header file for the NNShapeRecognizer
* @class NNShapeRecognizer
*<p> <p>
*/
class NNShapeRecognizer: public LTKShapeRecognizer
{
public:
#ifdef _INTERNAL
friend class LTKAdapt;
int adapt(int shapeID );
int adapt(const LTKTraceGroup& sampleTraceGroup, int shapeID );
private:
//int NNShapeRecognizer::readInternalClassifierConfig();
int readInternalClassifierConfig();
int deleteAdaptInstance();
/**
* This method trains the classifier from the feature file whose path is passed as paramater
*
* Semantics
*
*
* @param featureFilePath : string : Holds the path of Feature file
*
* @return none
*/
int trainFromFeatureFile(const string& featureFilePath,
vector<LTKShapeSample>* trainSet=NULL);
#endif
/** @name private data members */
//@{
private:
FN_PTR_DELETELTKLIPIPREPROCESSOR m_deleteLTKLipiPreProcessor;
//Function pointer for deleteLTKLipiPreProcessor
// preproc lin handle
void *m_libHandler;
// feature extractor lin handle
void *m_libHandlerFE;
unsigned short m_numShapes;
/**< @brief Number of shapes
* <p>
* It Defines the number of shapes to be recognized
*
* DEFAULT: 0
*
* Note: If the project is dynamic, then this numShapes was set to 0
* If the project is not dynamic, then the numShapes was read from project configuration file
* </p>
*/
string m_prototypeSelection;
/**< @brief The Prototype Selection
* <p>
* if Prototype Selection = clustering, the training method used was clustering
* = lvq, the training method used was LVQ
*
* DEFAULT: LTKPreprocDefaults::NN_DEF_PROTOTYPESELECTION
* Possible values are "clustering" and "lvq"
* </p>
*/
int m_prototypeReductionFactor;
/**< @brief The prototype Reduction factor
* <p>
* if PrototypeReductionFactor = 0 every training sample is cluster on its own
* = 100 all training samples are represented by one prototype
* = 80 then all samples are represented by 20% of the training samples
*
* DEFAULT: LTKPreprocDefaults::NN_DEF_PROTOTYPEREDUCTIONFACTOR
* RANGE: 0 TO 100
* </p>
*/
int m_numClusters;
/**< @brief The number of clusters
* <p>
* if NumClusters = k, then k clusters are found from the training samples
*
*
*
* DEFAULT: There is no default as this and prototype reduction factor are dependent
* RANGE:
* </p>
*/
string m_prototypeDistance;
/**< @brief The Prototype Distance
* <p>
* if PrototypeDistance = eu, then the distance between the samples can be calculated using the Euclidean distance method
* = dtw, then the distance between the samples can be calculated using the DTW method
*
* DEFAULT: LTKPreprocDefaults::NN_DEF_PROTOTYPEDISTANCE
* Possible values are LTKMacros::DTW_DISTANCE and LTKMacros::EUCLIDEAN_DISTANCE.
* </p>
*/
int m_nearestNeighbors;
/**< @brief Nearest Neighbors
* <p>
*
* DEFAULT: LTKPreprocDefaults::NN_DEF_NEARESTNEIGHBORS
* </p>
*/
// int m_dtwBanding;
float m_dtwBanding;
/**< @brief DTW Banding
* <p>
*
* DEFAULT: LTKPreprocDefaults::NN_DEF_BANDING
* </p>
*/
int m_dtwEuclideanFilter;
/**< @brief DTW Euclidean Filter
* <p>
*
* DEFAULT: LTKPreprocDefaults::NN_DEF_DTWEUCLIDEANFILTER
* </p>
*/
string m_featureExtractorName;
/**< @brief The Feature Extractor
* <p>
*
* DEFAULT:
*
* </p>
*/
bool m_projectTypeDynamic;
/**< @brief Project Dynamic
* <p>
* if projectTypeDynamic = true, then the project is dynamic ie, the numShapes can take any number of value
* = false, then the project is not dynamic ie, the numShape can take value specified in project.cfg file
*
* DEFAULT: false
* </p>
*/
LTKPreprocessorInterface *m_ptrPreproc;
/**< @brief Pointer to preprocessor instance
* <p>
* Instance which is used to call the preprocessing methods before recognition
*
* DEFAULT: NULL
* </p>
*/
string m_nnCfgFilePath;
/**< @brief Full path of NN configuration file
* <p>
* Assigned value in the NNShapeRecognizer::initialize function
* </p>
*/
string m_nnMDTFilePath;
/**< @brief Full path of Model data file
* <p>
* Assigned value in the NNShapeRecognizer::initialize function
* </p>
*/
stringStringMap m_headerInfo;
/**< @brief Header Information
* <p>
* </p>
*/
LTKShapeRecoUtil m_shapeRecUtil;
/**< @brief Pointer to LTKShapeRecoUtil class
* <p>
* Instance which used to call Shape Recognizer Utility functions
*
* DEFAULT: NULL
*/
string m_lipiRootPath;
/**< @brief Path of the Lipi Root
* <p>
* DEFAULT: LipiEngine::getLipiPath()
* </p>
*/
LTKShapeFeatureExtractor *m_ptrFeatureExtractor;
/**< @brief Pointer to LTKShapeFeatureExtractor class
* <p>
* DEFAULT: NULL
* </p>
*/
string m_preProcSeqn;
/**< @brief Preprocessor Sequence
* <p>
* This string will holds what sequence the preprocessor methods to be executed
* </p>
*/
vector<LTKShapeSample> m_prototypeSet;
/**< @brief Prototype Set for LVQ
* <p>
* It contains the Vector of Clustered ShapeSamples
* </p>
*/
LTKCaptureDevice m_captureDevice;
struct NeighborInfo
{
int classId;
float distance;
int prototypeSetIndex;
};
/*
struct MapModFunc
{
string moduleName;
string funcName;
};
*/
vector<stringStringPair> m_preprocSequence;
intIntMap m_shapeIDNumPrototypesMap;
/**< @brief Map of shapeID and Number of Samples per shape
* <p>
*
* </p>
*/
int m_prototypeSetModifyCount;
/**< @brief
* <p>
* Used to count number of modifications done to m_prototypeSet.
* Write to MDT after m_prototypeModifyCntCFG such modifications or at Exit.
* </p>
*/
int m_MDTUpdateFreq;
/**< @brief Update MDT after a specified number of modifications to m_prototypeSet
* <p>
* Specified in NN.cfg
*
* </p>
*/
//Cache Parameters used by Adapt
vector<LTKShapeRecoResult> m_vecRecoResult;
/**< @brief Store Recognize results
* used by subsequent call to Adapt
* <p>
*
*
* </p>
*/
vector <struct NeighborInfo> m_neighborInfoVec;
/**< @brief Vector to store the distances of test sample to each of the samples in prototypeSet,
* classIDs and indices within the prototypeset
* Used during subsequent call to Adapt
* <p>
*
*
* </p>
*/
LTKShapeSample m_cachedShapeSampleFeatures;
/**< @brief Store ShapeSampleFeatures of the last inTraceGroup to Recognize
* Used during subsequent call to Adapt
* <p>
*
*
* </p>
*/
float m_rejectThreshold;
/**< @brief Threshold on the confidence to reject a test sample
* <p>
*
* </p>
*/
bool m_adaptivekNN;
/**< @brief Adaptive kNN method to compute confidence
* <p>
* If m_adaptivekNN = true, the adaptive kNN method is used for confidence computation
* false, NN or kNN method is used, based on the value of m_nearestNeighbors
* </p>
*/
//@}
string m_currentVersion;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -