📄 ltkrecognitioncontext.cpp
字号:
//assigning the value to output
outTopResult = m_results[0];
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::getTopResult()" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : setConfidThreshold
* DESCRIPTION : set the confidence threshold
* ARGUMENTS : thresh - the threshold value to be set
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKRecognitionContext::setConfidThreshold (float thresh)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::setConfidThreshold()" << endl;
if(thresh < 0)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< ENEGATIVE_NUM <<":"
<< getErrorMessage(ENEGATIVE_NUM)
<<" LTKRecognitionContext::setConfidThreshold()" <<endl;
LTKReturnError(ENEGATIVE_NUM);
}
m_confidThreshold = thresh;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::setConfidThreshold()" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : setDeviceContext
* DESCRIPTION : set the device context
* ARGUMENTS : dc - reference to device context object to be set
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKRecognitionContext::setDeviceContext (const LTKCaptureDevice& dc)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::setDeviceContext()" << endl;
m_deviceContext = dc;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::setDeviceContext()" << endl;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : setFlag
* DESCRIPTION : sets the flag
* ARGUMENTS : key - index of the flag to be set
* : value - value of the flag to be set
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKRecognitionContext::setFlag (const string& key, int value)
{
vector<pair<string,int> >::iterator iter,iterEnd;//iterators for iterating through all flags
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::setFlag()" << endl;
if(key=="")
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EEMPTY_STRING <<":"<< getErrorMessage(EEMPTY_STRING)
<<" LTKRecognitionContext::setFlag()" <<endl;
LTKReturnError(EEMPTY_STRING);
}
iterEnd = m_recognitionFlags.end();
//looping through the map to check whether the flag exists
for(iter = m_recognitionFlags.begin(); iter != iterEnd; ++iter)
{
if((*iter).first == key)
{
(*iter).second = value;
break;
}
}
//if the flag is not there in the map add a new flag
if((iter == iterEnd)||(m_recognitionFlags.empty()) )
{
m_recognitionFlags.push_back(pair<string,int>(key,value));
}
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::setFlag()" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : setLanguageModel
* DESCRIPTION : sets the language model
* ARGUMENTS : property - name of ppty to be set (DICTIONARY, GRAMMAR)
* : value - value to be set
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKRecognitionContext::setLanguageModel (const string& property, const string& value)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::setLanguageModel()" << endl;
if(property=="" || value=="")
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<
"Either property or value is empty"<<endl;
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< EEMPTY_STRING <<":"<< getErrorMessage(EEMPTY_STRING)
<<" LTKRecognitionContext::setLanguageModel()" <<endl;
LTKReturnError(EEMPTY_STRING);
}
m_languageModels [property] = value;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::setLanguageModel()" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : setNumResults
* DESCRIPTION : sets parameter number of results to be buffered from recognizer
* ARGUMENTS : numResults - the value to be set
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKRecognitionContext::setNumResults (int numResults)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::setNumResults()" << endl;
if(numResults <= 0)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< ENON_POSITIVE_NUM <<":"
<< getErrorMessage(ENON_POSITIVE_NUM)
<<" LTKRecognitionContext::setNumResults()" <<endl;
LTKReturnError(ENON_POSITIVE_NUM);
}
m_numResults = numResults;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::setNumResults()" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : setScreenContext
* DESCRIPTION : sc - reference to the screencontext object to be set
* ARGUMENTS : numResults - the value to be set
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKRecognitionContext::setScreenContext (const LTKScreenContext& sc)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::setScreenContext()" << endl;
m_screenContext = sc;
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::setScreenContext()" << endl;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 11-MAR-2005
* NAME : addRecognitionResult
* DESCRIPTION : used by the recognizer to set the results back in the recognition context
* ARGUMENTS : result - the value to be added
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
void LTKRecognitionContext::addRecognitionResult (const LTKWordRecoResult& result)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::addRecognitionResult()" << endl;
//adding the result to the internal data structure
m_results.push_back(result);
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::addRecognitionResult()" << endl;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 11-MAR-2005
* NAME : recognize
* DESCRIPTION : the recognize call from the application.
* : calls the recognize emthod of the recognizer
* ARGUMENTS : numResults - the value to be set
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
int LTKRecognitionContext::recognize ()
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::recognize()" << endl;
int errorCode;
//calling recognize method of the recognizer
if(m_wordRecPtr!=NULL)
{
if( (errorCode = m_wordRecPtr->recognize(*this)) != SUCCESS)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error: LTKRecognitionContext::recognize()"<<endl;
LTKReturnError(errorCode);
}
}
else
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR) << "Recognizer is not initialized" <<endl;
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error : "<< ENULL_POINTER <<":"<< getErrorMessage(ENULL_POINTER)
<<" LTKRecognitionContext::recognize()" <<endl;
LTKReturnError(ENULL_POINTER);
}
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::recognize()" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 28-FEB-2005
* NAME : reset
* DESCRIPTION : Reset various parameters.
* ARGUMENTS : resetParam - specifies data to be rest
* RETURNS : SUCCESS/FAILURE
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
/**
* This function is used to reset the different components of recognition context
* @param resetParam : parameter that identifies the component to be reset
* @return SUCCESS/FAILURE
*/
int LTKRecognitionContext::reset (int resetParam)
{
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Entering: LTKRecognitionContext::reset()" << endl;
if(resetParam & LTK_RST_INK)
{
m_fieldInk.clear();
}
if(resetParam & LTK_RST_RECOGNIZER)
{
int errorCode=0;
if((errorCode=m_wordRecPtr->reset(resetParam))!=SUCCESS)
{
LOG(LTKLogger::LTK_LOGLEVEL_ERR)
<<"Error: LTKRecognitionContext::reset()"<<endl;
LTKReturnError(errorCode);
}
}
LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
" Exiting: LTKRecognitionContext::reset()" << endl;
return SUCCESS;
}
/**********************************************************************************
* AUTHOR : Deepu V.
* DATE : 22-FEB-2005
* NAME : LTKRecognitionContext
* DESCRIPTION : Destructor
* ARGUMENTS :
* RETURNS :
* NOTES :
* CHANGE HISTROY
* Author Date Description of change
*************************************************************************************/
LTKRecognitionContext::~LTKRecognitionContext()
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -