📄 ltkrecognitioncontext.cpp
字号:
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error: LTKRecognitionContext::clearRecognitionResult()"<<endl;
LTKReturnError(errorCode);
}
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::clearRecognitionResult()" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : endRecoUnit
* DESCRIPTION : This function marks the ending of a recognition unit of Ink.
* ARGUMENTS : none
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKRecognitionContext::endRecoUnit ( )
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::endRecoUnit()" << endl;
//pushing a "marker" into the stream
m_fieldInk.push_back(LTKTrace());
//calling the marker of the recognizer
m_wordRecPtr->endRecoUnit();
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::endRecoUnit()" << endl;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : getAllInk
* DESCRIPTION : Access function for the internal Ink data.
* ARGUMENTS : none
* RETURNS : reference to internal Ink data
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
const LTKTraceVector& LTKRecognitionContext::getAllInk () const
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::getAllInk()" << endl;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::getAllInk()" << endl;
return m_fieldInk;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : getConfidThreshold
* DESCRIPTION : Access function for internal confidence threshold
* ARGUMENTS : none
* RETURNS : confidence threshold
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
float LTKRecognitionContext::getConfidThreshold () const
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::getConfidThreshold()" << endl;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::getConfidThreshold()" << endl;
return m_confidThreshold;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : getDeviceContext
* DESCRIPTION : Access function for device context
* ARGUMENTS : none
* RETURNS : reference to LTKCapture device
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
const LTKCaptureDevice& LTKRecognitionContext::getDeviceContext ( ) const
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::getDeviceContext()" << endl;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::getDeviceContext()" << endl;
return m_deviceContext;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : getFlag
* DESCRIPTION : Returns the value of the flag
* ARGUMENTS : key - index of map
* RETURNS : value of queried flag (int)
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKRecognitionContext::getFlag (const string& key,int& outValue) const
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::getFlag()" << endl;
if(key=="")
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EEMPTY_STRING <<":"<< getErrorMessage(EEMPTY_STRING)
<<" LTKRecognitionContext::getFlag()" <<endl;
LTKReturnError(EEMPTY_STRING);
}
vector<pair<string,int> >::const_iterator iter,iterEnd;
iterEnd = m_recognitionFlags.end();
//Iterating through the vector to find the key
for(iter = m_recognitionFlags.begin(); iter != iterEnd; ++iter)
{
if( (*iter).first == key )
{
outValue = (*iter).second;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::getFlag()" << endl;
return SUCCESS;
}
}
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EKEY_NOT_FOUND <<":"<< getErrorMessage(EKEY_NOT_FOUND)
<<" LTKRecognitionContext::getFlag()" <<endl;
LTKReturnError(EKEY_NOT_FOUND);
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : getLanguageModel
* DESCRIPTION : returns the current language model indexed by the key
* ARGUMENTS : key - index of map
* RETURNS : value of the queried language model (string)
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKRecognitionContext::getLanguageModel (const string& key,
string& outValue) const
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::getLanguageModel()" << endl;
if(key=="")
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EEMPTY_STRING <<":"<< getErrorMessage(EEMPTY_STRING)
<<" LTKRecognitionContext::getLanguageModel()" <<endl;
LTKReturnError(EEMPTY_STRING);
}
stringStringMap::const_iterator iterMap;
iterMap = this->m_languageModels.find(key);
if(iterMap != m_languageModels.end() )
{
outValue = iterMap->second;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::getLanguageModel()" << endl;
return SUCCESS;
}
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EKEY_NOT_FOUND <<":"<< getErrorMessage(EKEY_NOT_FOUND)
<<" LTKRecognitionContext::getLanguageModel()" <<endl;
LTKReturnError(EKEY_NOT_FOUND);
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : getNextBestResults
* DESCRIPTION : returns the next N best results
* ARGUMENTS : numResults - number of results required
* : results - This will be populated with results
* RETURNS : SUCCESS/FAILURE
* NOTES : Maximum number of results added is limited by number of results
* : available.
* : vector is not cleared inside the function
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKRecognitionContext::getNextBestResults (int numResults,
LTKWordRecoResultVector& outWordRecResults)
{
int lastIndex = 0;//Last index
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::getNextBestResults()" << endl;
if(numResults<=0)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< ENON_POSITIVE_NUM <<":"<< getErrorMessage(ENON_POSITIVE_NUM)
<<" LTKRecognitionContext::getNextBestResults()" <<endl;
LTKReturnError(ENON_POSITIVE_NUM);
}
vector<LTKWordRecoResult>::const_iterator resultBegin, resultEnd, resultIter;
//Finding index of requested results
resultBegin = m_results.begin() + m_nextBestResultIndex;
//Finding index of requested results
resultEnd = m_results.begin() + m_nextBestResultIndex + numResults;
if(resultBegin > resultEnd)
{
LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) <<
"Exiting LTKRecognitionContext::getNextBestResults" <<endl;
return SUCCESS;
}
//limiting the end to the limits of available results
if(resultEnd > m_results.end() )
resultEnd = m_results.end();
//pushing back the results
for(resultIter = resultBegin; resultIter< resultEnd; ++resultIter)
{
outWordRecResults.push_back(*resultIter);
}
//updating next best result index
m_nextBestResultIndex += numResults;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::getNextBestResults()" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : getNumResults
* DESCRIPTION : parameter number of results
* ARGUMENTS : none
* RETURNS : number of results (int)
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKRecognitionContext::getNumResults () const
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::getNumResults()" << endl;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::getNumResults()" << endl;
return m_numResults;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : getScreenContext
* DESCRIPTION : access function for the screen context
* ARGUMENTS : none
* RETURNS : reference to screencontext object
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
const LTKScreenContext& LTKRecognitionContext::getScreenContext ( ) const
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::getScreenContext()" << endl;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::getScreenContext()" << endl;
return m_screenContext;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : getTopResult
* DESCRIPTION : get the top result from the recognition context
* ARGUMENTS : result - will be assigned to the top recognition result
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKRecognitionContext::getTopResult (LTKWordRecoResult& outTopResult)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::getTopResult()" << endl;
if(m_results.size() == 0)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EEMPTY_WORDREC_RESULTS <<":"<< getErrorMessage(EEMPTY_WORDREC_RESULTS)
<<" LTKRecognitionContext::getTopResult()" <<endl;
LTKReturnError(EEMPTY_WORDREC_RESULTS);
}
m_nextBestResultIndex = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -