/******************************************************************************
* AUTHOR		: Nidhi sharma
* DATE			: 08-Feb-2007
* NAME			: LTKLipiEngineModule::validateProfile
* DESCRIPTION	: 
* ARGUMENTS		: 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
* 
******************************************************************************/
int LTKLipiEngineModule::validateProfile(const string& strProjectName, 
										 const string& strProfileName, 
	 									 const string& projectType, 
										 string& outRecognizerString)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
        "Entering: LTKLipiEngineModule::validateProfile()"<<endl;
	
	int errorCode; 
	string profileCfgPath = m_strLipiRootPath + PROJECTS_PATH_STRING + 
						strProjectName + PROFILE_PATH_STRING + strProfileName 
						+ SEPARATOR + PROFILE_CFG_STRING;

	LTKConfigFileReader* profileConfigReader = NULL;
	
	try
	{
		profileConfigReader = new LTKConfigFileReader(profileCfgPath);
	}
	catch(LTKException e)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
            "Error: "<< getErrorMessage(e.getErrorCode()) << profileCfgPath <<
    		" LTKLipiEngineModule::validateProfile()"<<endl;

		LTKReturnError(e.getErrorCode());
	}

	errorCode = profileConfigReader->getConfigValue(projectType, 
													outRecognizerString);
	
	if(errorCode != SUCCESS)
	{
		/* No recognizer specified. */
		if (projectType == SHAPE_RECOGNIZER_STRING )
		{
			errorCode = ENO_SHAPE_RECOGNIZER;
		}
		else
		{
			errorCode = ENO_WORD_RECOGNIZER;
		}

		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
            "Error: "<< getErrorMessage(errorCode) << profileCfgPath <<
    		" LTKLipiEngineModule::validateProfile()"<<endl;
	
		delete profileConfigReader;		

		LTKReturnError(errorCode); 
	}

	delete profileConfigReader;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
        "Exiting: LTKLipiEngineModule::validateProfile()"<<endl;
	
	return SUCCESS;
}
/******************************************************************************
* AUTHOR		: Nidhi sharma
* DATE			: 08-Feb-2007
* NAME			: LTKLipiEngineModule::validateProject
* DESCRIPTION	: 
* ARGUMENTS		: 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
* 
*******************************************************************************/
int LTKLipiEngineModule::validateProject(const string& strProjectName, 
										 const string& projectType)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
        "Enterng: LTKLipiEngineModule::validateProject()"<<endl;
	
	LTKConfigFileReader* projectConfigReader = NULL;
	
	string projectTypeCfgEntry = "";

	if(strProjectName == "")
	{
		/* invalid or no entry for project name */
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
        "Error: "<< getErrorMessage(EINVALID_PROJECT_NAME) <<
		"LTKLipiEngineModule::validateProject()"<<endl;

        LTKReturnError(EINVALID_PROJECT_NAME);
	}

	string projectCfgPath = m_strLipiRootPath + PROJECTS_PATH_STRING +  
					strProjectName + PROFILE_PATH_STRING + PROJECT_CFG_STRING;
	
	try
	{
		projectConfigReader = new LTKConfigFileReader(projectCfgPath);
	}
	catch(LTKException e)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
        "Error: "<< getErrorMessage(e.getErrorCode()) << projectCfgPath <<
		" LTKLipiEngineModule::validateProject()"<<endl;

		LTKReturnError(EINVALID_PROJECT_NAME);
	}
	
	int errorCode = projectConfigReader->getConfigValue(PROJECT_TYPE_STRING,
															projectTypeCfgEntry);
	
	if( errorCode != SUCCESS || projectTypeCfgEntry != projectType)
	{
		/* Invalid configuration entry for ProjectType */	
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
            "Error: "<< getErrorMessage(EINVALID_PROJECT_TYPE) <<
    		" LTKLipiEngineModule::validateProject()"<<endl;

		delete projectConfigReader;
		//Project type in CFG is missing or an invalid value
		LTKReturnError(EINVALID_PROJECT_TYPE); 
	}

	delete projectConfigReader;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
        "Exiting: LTKLipiEngineModule::validateProject()"<<endl;
		
	return SUCCESS;
}
/******************************************************************************
* AUTHOR        : Thanigai 
* DATE          : 29-JUL-2005
* NAME          : mapShapeAlgoModuleFunctions
* DESCRIPTION   : To map function addresses of the methods exposed by 
*				  the shape recognition modules
* ARGUMENTS     : None
* RETURNS       : 0 on success and other values on error 
* NOTES         :
* CHANGE HISTROY
* Author            Date                Description of change
******************************************************************************/
int LTKLipiEngineModule::mapShapeAlgoModuleFunctions(void *dllHandle)
{
	LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<
    "Entering: LTKLipiEngineModule::mapShapeAlgoModuleFunctions()"<<endl;
	

	module_createShapeRecognizer = NULL;
	module_deleteShapeRecognizer = NULL;

    void* functionHandle = NULL;

    int returnVal = m_OSUtilPtr->getFunctionAddress(dllHandle, 
                                            CREATESHAPERECOGNIZER_FUNC_NAME, 
                                            &functionHandle);
    
    // Could not map the  function from the DLL
	if(returnVal != SUCCESS)
	{
	    LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<
        "Error: "<<
		getErrorMessage(EDLL_FUNC_ADDRESS) <<" "<<CREATESHAPERECOGNIZER_FUNC_NAME
		<<" "<<"LTKLipiEngineModule::mapShapeAlgoModuleFunctions()"<<endl;


        m_OSUtilPtr->unloadSharedLib(dllHandle);

		LTKReturnError(EDLL_FUNC_ADDRESS);
	}

    module_createShapeRecognizer = (FN_PTR_CREATESHAPERECOGNIZER)functionHandle;

	functionHandle = NULL;

    returnVal = m_OSUtilPtr->getFunctionAddress(dllHandle, 
                                            DELETESHAPERECOGNIZER_FUNC_NAME, 
                                            &functionHandle);
    
    // Could not map the  function from the DLL
	if(returnVal != SUCCESS)
	{
	    LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<
        "Error: "<<
		getErrorMessage(EDLL_FUNC_ADDRESS) <<" "<<DELETESHAPERECOGNIZER_FUNC_NAME
		<<" "<<"LTKLipiEngineModule::mapShapeAlgoModuleFunctions()"<<endl;

        m_OSUtilPtr->unloadSharedLib(dllHandle);

		LTKReturnError(EDLL_FUNC_ADDRESS);
	}

    module_deleteShapeRecognizer = (FN_PTR_DELETESHAPERECOGNIZER)functionHandle;

	LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<
    "Exiting: LTKLipiEngineModule::mapShapeAlgoModuleFunctions()"<<endl;
	
	return SUCCESS;
}
/******************************************************************************
 * AUTHOR		: Nidhi sharma
 * DATE			: 22-02-2007
 * NAME			: getShapeSampleFromInkFile
 * DESCRIPTION	: This method will get the ShapeSample by giving the ink
 *				  file path as input
 * ARGUMENTS	:
 * RETURNS		: SUCCESS
 * NOTES		:
 * CHANGE HISTROY
 * Author			Date				Description
 ******************************************************************************/
int featurefilewriter::getShapeFeatureFromInkFile(const string& inkFilePath,
        vector<LTKShapeFeaturePtr>& shapeFeatureVec)
{

    LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " <<
        "featurefilewriter::getShapeFeatureFromInkFile()" << endl;

    if ( inkFilePath.empty() )
        return FAILURE;

    LTKCaptureDevice captureDevice;
    LTKScreenContext screenContext;

    LTKTraceGroup inTraceGroup, preprocessedTraceGroup;
    inTraceGroup.emptyAllTraces();

    int returnVal = m_shapeRecUtil.readInkFromFile(inkFilePath,
            m_lipiRootPath, inTraceGroup,
            captureDevice, screenContext);

    if (returnVal!= SUCCESS)
    {
        LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<<returnVal<<
            " featurefilewriter::getShapeFeatureFromInkFile()" << endl;
        LTKReturnError(returnVal);
    }

    m_ptrPreproc->setCaptureDevice(captureDevice);
    m_ptrPreproc->setScreenContext(screenContext);

    preprocessedTraceGroup.emptyAllTraces();

    //Preprocessing to be done for the trace group that was read
	int errorCode = preprocess(inTraceGroup, preprocessedTraceGroup);
    if(  errorCode != SUCCESS )
    {
        LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< errorCode << " " <<
            " featurefilewriter::getShapeFeatureFromInkFile()" << endl;
		LTKReturnError(errorCode);
    }

    errorCode = m_ptrFeatureExtractor->extractFeatures(preprocessedTraceGroup,
            shapeFeatureVec);

    if (errorCode != SUCCESS)
    {
        LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< errorCode << " " <<
            " featurefilewriter::getShapeFeatureFromInkFile()" << endl;
        LTKReturnError(errorCode);
    }

    LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " <<
        "featurefilewriter::getShapeFeatureFromInkFile()" << endl;

    return SUCCESS;
}
/**********************************************************************************
* AUTHOR		: Deepu V.
* DATE			: 22-AUG-2005
* NAME			: recognize
* DESCRIPTION	: This method reset the recognizer
* ARGUMENTS		: resetParam - This parameter could specify what to reset
* RETURNS		: SUCCESS/FAILURE
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of
*************************************************************************************/
 int BoxedFieldRecognizer::unloadModelData()
{

	LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)
	    <<"Entering: BoxedFieldRecognizer::unloadModelData"
	    <<endl;

	 //clear the recognition state
	clearRecognizerState();

	int errorCode=FAILURE;

	//unload the model data and
	//delete the shape recognizer
	if( m_shapeRecognizer  && (m_module_deleteShapeRecognizer != NULL) )
	{

	   if((errorCode = m_shapeRecognizer->unloadModelData()) != SUCCESS)
	   {
			LOG(LTKLogger::LTK_LOGLEVEL_ERR)
            	<<"Error: BoxedFieldRecognizer::unloadModelData"<<endl;


		   LTKReturnError(errorCode);
	   }

	   if((errorCode = m_module_deleteShapeRecognizer(m_shapeRecognizer)) != SUCCESS)
	   {
			LOG(LTKLogger::LTK_LOGLEVEL_ERR)
            	<<"Error: BoxedFieldRecognizer::unloadModelData"<<endl;


		   LTKReturnError(errorCode);
	   }

	   m_shapeRecognizer = NULL;
	}

	//Freeing the shape recognition library
	if(m_hAlgoDLLHandle)
	{
		m_OSUtilPtr->unloadSharedLib(m_hAlgoDLLHandle);
		m_hAlgoDLLHandle = NULL;
	}

	LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)
		<<"Exiting: BoxedFieldRecognizer::unloadModelData"
		<<endl;

	return SUCCESS;
}
Example #6
0
int BCCShapeRecognizer::mapPCAAndHolisticModuleFunctions()
{
	module_createShapeRecognizerPCA = NULL;
	module_createShapeRecognizerPCA = (FN_PTR_CREATESHAPERECOGNIZER) LTKGetDLLFunc(m_hPCA, CREATESHAPERECOGNIZER_FUNC_NAME);
	if(module_createShapeRecognizerPCA == NULL)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
            "Exported function not found in module : createShapeRecognizer"  << endl;

		//LTKReturnError(EDLL_FUNC_ADDRESS_ERR);
		LTKReturnError(EDLL_FUNC_ADDRESS);
	}

	module_deleteShapeRecognizerPCA = (FN_PTR_DELETESHAPERECOGNIZER) LTKGetDLLFunc(m_hPCA, DELETESHAPERECOGNIZER_FUNC_NAME);
	if(module_deleteShapeRecognizerPCA == NULL)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Exported function not found in module: deleteShapeRecognizer" << endl;

	//LTKReturnError(EDLL_FUNC_ADDRESS_ERR);
		LTKReturnError(EDLL_FUNC_ADDRESS);
		// ERROR: Unable to link with deleteShapeRecognizer function in module */

	}

	module_createShapeRecognizerHolistic = NULL;
	module_createShapeRecognizerHolistic = (FN_PTR_CREATESHAPERECOGNIZER) LTKGetDLLFunc(m_hHolistic, CREATESHAPERECOGNIZER_FUNC_NAME);
	if(module_createShapeRecognizerHolistic == NULL)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
            "Exported function not found in module : createShapeRecognizer"  << endl;

		//LTKReturnError(EDLL_FUNC_ADDRESS_ERR);
		LTKReturnError(EDLL_FUNC_ADDRESS);
	}

	module_deleteShapeRecognizerHolistic = (FN_PTR_DELETESHAPERECOGNIZER) LTKGetDLLFunc(m_hHolistic, DELETESHAPERECOGNIZER_FUNC_NAME);
	if(module_deleteShapeRecognizerHolistic == NULL)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
            "Exported function not found in module : deleteShapeRecognizer"  << endl;

		//LTKReturnError(EDLL_FUNC_ADDRESS_ERR);
		LTKReturnError(EDLL_FUNC_ADDRESS);
		// ERROR: Unable to link with deleteShapeRecognizer function in module */

	}

	return SUCCESS;
}
/******************************************************************************
* AUTHOR			: Nidhi Sharma 
* DATE				: 07-May-2007
* NAME				: configureLogger
* DESCRIPTION		: Configures the logger
* ARGUMENTS			: None
* RETURNS			: Nothing
* NOTES 				:
* CHANGE HISTROY
* Author            Date                Description of change
******************************************************************************/
int LTKLipiEngineModule::configureLogger()
{
	// No log messages as this function is used to configure logger
    string valueFromCFG = "";
    int errorCode ;
    
	if ( m_LipiEngineConfigEntries != NULL )
	{
		// Read the log file name from lipiengine.cfg
		errorCode = m_LipiEngineConfigEntries->getConfigValue(LOG_FILE_NAME,
															  valueFromCFG);

		if(errorCode ==SUCCESS)
		{
			setLipiLogFileName(valueFromCFG);
		}
        else if (errorCode == EKEY_NOT_FOUND )
        {
			 // Set default log file
        }
		else
		{
			LTKReturnError(ECREATE_LOGGER);
		}

		// Read the log level
		valueFromCFG = "";
		
		errorCode = m_LipiEngineConfigEntries->getConfigValue(LOG_LEVEL, valueFromCFG);

		if(errorCode == SUCCESS)
		{
			setLipiLogLevel(valueFromCFG);
		}
		else if (errorCode == EKEY_NOT_FOUND )
        {
            // Set default log file
        }
		else
		{
			LTKReturnError(ECREATE_LOGGER);
		}
	}

    LTKLoggerUtil::createLogger(m_strLipiRootPath);
    LTKLoggerUtil::configureLogger(m_logFileName, m_logLevel);
    
	return SUCCESS;
}
/******************************************************************************
* AUTHOR			: Nidhi Sharma 
* DATE				: 07-May-2007
* NAME				: setLipiLogLevel
* DESCRIPTION		: To set the value of m_logLevel
* ARGUMENTS			: String
* RETURNS			: Nothing
* NOTES 				:
* CHANGE HISTROY
* Author            Date                Description of change
******************************************************************************/
int LTKLipiEngineModule::setLipiLogLevel(const string& appLogLevel)
{

	// No log messages as this function is used to configure logger
	string strLogLevel = "";
    
	if ( appLogLevel.length() != 0 )
	{
		strLogLevel= appLogLevel;
	}
	else
	{
		LTKReturnError(EINVALID_LOG_LEVEL); 
	}

	const char * strLogLevelPtr = strLogLevel.c_str();
	// mapping m_LogLevel to Logger log levels

	if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_DEBUG) == 0)
	{
		m_logLevel = LTKLogger::LTK_LOGLEVEL_DEBUG;
	}
	else if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_ALL) == 0)
	{
		m_logLevel = LTKLogger::LTK_LOGLEVEL_ALL;
	}
	else if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_VERBOSE) == 0)
	{
		m_logLevel = LTKLogger::LTK_LOGLEVEL_VERBOSE;
	}
	else if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_ERROR) == 0)
	{
		m_logLevel = LTKLogger::LTK_LOGLEVEL_ERR;
	}
	else if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_OFF) == 0)
	{
		m_logLevel = LTKLogger::LTK_LOGLEVEL_OFF;
	}
	else if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_INFO) == 0)
	{
		m_logLevel = LTKLogger::LTK_LOGLEVEL_INFO;
	}
	else
	{
		LTKReturnError(EINVALID_LOG_LEVEL); 
	}

	return SUCCESS;
}
/******************************************************************************
* AUTHOR		: Saravanan R.
* DATE			: 09-Feb-2007
* NAME			: LTKLipiEngineModule::validateProjectAndProfileNames
* DESCRIPTION	: 
* ARGUMENTS		: 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/
int LTKLipiEngineModule::validateProjectAndProfileNames(
												const string& strProjectName, 
												const string& strProfileName,
												const string& projectType,
												string& outRecognizerString)
{
	LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<
		"Entering: LTKLipiEngineModule::validateProjectAndProfileNames()"<<endl;

	int errorCode;
	string recognizerType = "";
	string profileName(strProfileName);

	// Validate Project
	errorCode = validateProject(strProjectName, projectType);
	if ( errorCode!= SUCCESS )
	{
		LTKReturnError(errorCode);
	}
	
	
	if(projectType == "SHAPEREC")
    {   
		recognizerType = SHAPE_RECOGNIZER_STRING;
    }
	else
    {   
		recognizerType = WORD_RECOGNIZER_STRING;
    }

	// Validate Profile
	if(strProfileName == "")
	{
		//Assume the "default" profile
		profileName = DEFAULT_PROFILE; 
	}

	errorCode = validateProfile(strProjectName, profileName, 
								recognizerType, outRecognizerString);
	if ( errorCode!= SUCCESS)
	{
		LTKReturnError(errorCode);
	}

	LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<
		"Exiting: LTKLipiEngineModule::validateProjectAndProfileNames()"<<endl;

	return SUCCESS;
}
/*****************************************************************************
* AUTHOR		: Nidhi Sharma
* DATE			: 
* NAME			: getAddressLoggerFunctions
* DESCRIPTION	: 
* ARGUMENTS		: 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
*****************************************************************************/
int LTKLoggerUtil::getAddressLoggerFunctions()
{
    void* functionHandle = NULL; 
    int returnVal = SUCCESS;


    //start log


    if (module_startLogger == NULL )
    {
        returnVal = m_ptrOSUtil->getFunctionAddress(m_libHandleLogger,
                                                    "startLogger", 
                                                    &functionHandle);

        if(returnVal != SUCCESS)
    	{
    	    LTKReturnError(returnVal);
    	}

        module_startLogger = (FN_PTR_STARTLOG)functionHandle;

    	functionHandle = NULL;
    }

    module_startLogger();

    // map Log message
    if (module_logMessage == NULL)
    {
        returnVal = m_ptrOSUtil->getFunctionAddress(m_libHandleLogger,
                                                    "logMessage", 
                                                    &functionHandle);

        if(returnVal != SUCCESS)
    	{
    	    LTKReturnError(returnVal);
    	}

        module_logMessage = (FN_PTR_LOGMESSAGE)functionHandle;

    	functionHandle = NULL;    
    
    }
    
	
	return SUCCESS;
	
}
int NPenShapeFeatureExtractor::readConfig(const string& cfgFilePath)
{
    LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " <<
        "NPenShapeFeatureExtractor::readConfig()" << endl;
    
	LTKConfigFileReader* configurableProperties = NULL;
    string tempStringVar = "";

	try
    {
        configurableProperties = new LTKConfigFileReader(cfgFilePath);
        
		int errorCode = configurableProperties->getConfigValue(NPEN_WINDOW_SIZE, tempStringVar);
		
		if( errorCode == SUCCESS)
        {
            if (setWindowSize(atoi((tempStringVar).c_str())) != SUCCESS)
            {
                LOG(LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << 
                    ECONFIG_FILE_RANGE << " : " << 
                    getErrorMessage(ECONFIG_FILE_RANGE) <<
                    " NPenShapeFeatureExtractor::readConfig" <<endl;
                
                throw LTKReturnError(ECONFIG_FILE_RANGE);
            }
        }
	}

	catch(LTKException e)
    {
        delete configurableProperties;

        int eCode = e.getErrorCode();
        
        LOG(LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << eCode << 
            " : " << getErrorMessage(eCode) <<
            " NPenShapeFeatureExtractor::readConfig" <<endl;
        
        LTKReturnError(eCode);
    }
	delete configurableProperties;

    LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " <<
        "NPenShapeFeatureExtractor::readConfig()" << endl;
    
	return SUCCESS;

}
int LTKStrEncoding::tamilCharToUnicode(const unsigned short& shapeID,  vector<unsigned short>& unicodeString)
{

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
	  " Entering: LTKStrEncoding::tamilCharToUnicode()" << endl;


		if(shapeID < 35)
		{
			if(shapeID == 34)
			{
				unicodeString.push_back(0x0b95);
				unicodeString.push_back(0x0bcd);
				unicodeString.push_back(0x0bb7);
			}
			else
			{
				unicodeString.push_back(tamilIsoCharMap[shapeID]);
			}
		}
		else
		{
			LOG(LTKLogger::LTK_LOGLEVEL_ERR)
                  <<"Error : "<< EINVALID_SHAPEID <<":"<< getErrorMessage(EINVALID_SHAPEID)
                  <<"LTKStrEncoding::tamilCharToUnicode()" <<endl;

			LTKReturnError(EINVALID_SHAPEID);
		}
		LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
		  " Exiting: LTKStrEncoding::tamilCharToUnicode()" << endl;

	return SUCCESS;
}
/******************************************************************************
* AUTHOR        : Thanigai 
* DATE          : 29-JUL-2005
* NAME          : deleteWordRecognizer
* DESCRIPTION   : To delete the recognizer object which is created 
*				  using "createWordRecognizer" call
* ARGUMENTS     : obj - handle the previously created recognizer object
* RETURNS       : 0 on success other values error
* NOTES         :
* CHANGE HISTROY
* Author            Date                Description of change
******************************************************************************/
int LTKLipiEngineModule::deleteWordRecognizer(LTKWordRecognizer* obj)
{
	LOG(LTKLogger::LTK_LOGLEVEL_INFO)<<
		"Entering: LTKLipiEngineModule::deleteWordRecognizer()"<<endl;

	int errorCode;

	//	Call recognition module's deleteWordRecognizer(obj) 
	if(obj)
	{
		deleteModule(obj);		
		errorCode = module_deleteWordRecognizer(obj);
		if(errorCode !=SUCCESS)
		{
			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
    			"Error: " << getErrorMessage(errorCode) << 
    			"LTKLipiEngineModule::deleteShapeRecognizer()"<<endl;
            
			LTKReturnError(errorCode);
		}	
		obj = NULL;
	}
	
	LOG(LTKLogger::LTK_LOGLEVEL_INFO)<<
		"Exiting: LTKLipiEngineModule::deleteWordRecognizer()"<<endl;
	
	return SUCCESS;

}
/******************************************************************************
* AUTHOR		: Saravanan R.
* DATE			: 09-Feb-2007
* NAME			: 
* DESCRIPTION	: 
* ARGUMENTS		: 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
* 
******************************************************************************/
int LTKLipiEngineModule::loadRecognizerDLL(const string& recognizerName,
										   void **dllHandler)
{
	LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<
		"Entering: LTKLipiEngineModule::loadRecognizerDLL()"<<endl;
	
	string recognizerDLLPath = "";
	int returnVal = SUCCESS;

    returnVal = m_OSUtilPtr->loadSharedLib(m_strLipiRootPath, recognizerName, dllHandler);

    
	if(returnVal != SUCCESS)
	{
		LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<
		"Error: "<< getErrorMessage(ELOAD_SHAPEREC_DLL) <<" "<<recognizerDLLPath <<
		"LTKLipiEngineModule::loadRecognizerDLL()"<<endl;

		LTKReturnError(ELOAD_SHAPEREC_DLL); 
	}
    
	LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<
		"Exiting: LTKLipiEngineModule::loadRecognizerDLL()"<<endl;
	
	return SUCCESS;
}
int PointFloatShapeFeatureExtractor::readConfig(const string& cfgFilePath)
{
    LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " <<
        "PointFloatShapeFeatureExtractor::readConfig()" << endl;
    
	LTKConfigFileReader* configurableProperties = NULL;
	string tempStringVar = "";

	try
	{
		configurableProperties = new LTKConfigFileReader(cfgFilePath);
	}

	catch(LTKException e)
	{
		delete configurableProperties;

        int eCode = e.getErrorCode();

        LOG( LTKLogger::LTK_LOGLEVEL_ERR) << "Error: " << eCode << 
            " : " << getErrorMessage(eCode) <<
            " PointFloatShapeFeatureExtractor::readConfig" <<endl;
        
		LTKReturnError(eCode);
	}
    
	delete configurableProperties;

    LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " <<
        "PointFloatShapeFeatureExtractor::readConfig()" << endl;
	return SUCCESS;

}
/**
* 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		: Saravanan R.
 * DATE			: 23-Jan-2007
 * NAME			: writeFeatureFile
 * DESCRIPTION	:
 * ARGUMENTS	:
 * RETURNS		: none
 * NOTES		:
 * CHANGE HISTROY
 * Author			Date				Description
 *************************************************************************************/
int featurefilewriter::writeFeatureFile(const LTKShapeSample& prototypeVec,
        ofstream & featurefileFileHandle)
{
    string strFeature = "";

    if(!featurefileFileHandle)
    {
        LOG(LTKLogger::LTK_LOGLEVEL_ERR)<<"Error: "<< EINVALID_FILE_HANDLE << " " <<
            "Invalid file handle for feature file"<<
            " featurefilewriter::writeFeatureFile()" << endl;
        LTKReturnError(EINVALID_FILE_HANDLE);
    }


    //Write the class Id
    int classId = prototypeVec.getClassID();
	featurefileFileHandle << classId << " ";

    const vector<LTKShapeFeaturePtr>& shapeFeatureVector = prototypeVec.getFeatureVector();

    vector<LTKShapeFeaturePtr>::const_iterator shapeFeatureIter = shapeFeatureVector.begin();
    vector<LTKShapeFeaturePtr>::const_iterator shapeFeatureIterEnd = shapeFeatureVector.end();

    for(; shapeFeatureIter != shapeFeatureIterEnd; ++shapeFeatureIter)
    {
        (*shapeFeatureIter)->toString(strFeature);
        featurefileFileHandle << strFeature << FEATURE_EXTRACTOR_DELIMITER;
    }

    featurefileFileHandle << "\n";

    return SUCCESS;
}
/**********************************************************************************
 * AUTHOR		: Saravanan. R
 * DATE			: 25-01-2007
 * NAME			: deletePreprocessor
 * DESCRIPTION	: This method is used to deletes the PreProcessor instance
 * ARGUMENTS		: ptrPreprocInstance : Holds the pointer to the LTKPreprocessorInterface
 * RETURNS		: none
 * NOTES			:
 * CHANGE HISTROY
 * Author			Date				Description
 *************************************************************************************/
int featurefilewriter::deletePreprocessor()
{

    LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " <<
        "featurefilewriter::deletePreprocessor()" << endl;

    //deleting the preprocessor instance
    if(m_ptrPreproc != NULL)
    {
        m_deleteLTKLipiPreProcessor(m_ptrPreproc);
        m_ptrPreproc = NULL;
    }

    //Unload the dll
    int returnStatus = unloadPreprocessorDLL();
    if(returnStatus != SUCCESS)
    {
        LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Error: " <<
            getErrorMessage(returnStatus) <<
            " featurefilewriter::deletePreprocessor()" << endl;
        LTKReturnError(returnStatus);
    }

    LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " <<
        "featurefilewriter::deletePreprocessor()" << endl;

    return SUCCESS;
}
/**********************************************************************************
* AUTHOR		: Deepu V.
* DATE			: 11-MAR-2005
* NAME			: clearRecognitionResult
* DESCRIPTION	: clears all the recognition results
* ARGUMENTS		: none
* RETURNS		: SUCCESS/FAILURE
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
*************************************************************************************/
int LTKRecognitionContext::clearRecognitionResult ( )
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
        " Entering: LTKRecognitionContext::clearRecognitionResult()" << endl;
	
	//clearing the results
	m_results.clear();

	//reset the index of next best result
	m_nextBestResultIndex = 0;

	m_fieldInk.clear();

	int errorCode;
	
	if((errorCode=m_wordRecPtr->reset())!=SUCCESS)
	{
		LOG(LTKLogger::LTK_LOGLEVEL_ERR)
        <<"Error: LTKRecognitionContext::clearRecognitionResult()"<<endl;

		LTKReturnError(errorCode);
	}

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
        " Exiting: LTKRecognitionContext::clearRecognitionResult()" << endl;

	return SUCCESS;	
}
/******************************************************************************
* AUTHOR        : Balaji MNA 
* DATE          : 14-JUN-2009
* NAME          : createShapeRecognizer
* DESCRIPTION   : resolves logical project name and call createWordRecognizer
*				  function.  
* ARGUMENTS     : strLogicalProjectName - logical project name; 
*                 outShapeRecognizerPtr - return shape recognizer object 
* RETURNS       : if success returns 0 or if fails returns error code 
* NOTES         :
* CHANGE HISTROY
* Author            Date                Description of change
******************************************************************************/
int LTKLipiEngineModule::createShapeRecognizer(string &strLogicalProjectName, LTKShapeRecognizer** outShapeRecognizerPtr) 
{
	int errorCode;
	LOG(LTKLogger::LTK_LOGLEVEL_INFO)<<
		"Entering: LTKLipiEngineModule::createShapeRecognizer()"<<endl;

	if(strLogicalProjectName.empty())
	{		
		return EINVALID_PROJECT_NAME;
	}

	string strProjectName = "";
    string strProfileName = "";

	// Resolve the logical name into project name and profile name
	errorCode = resolveLogicalNameToProjectProfile(strLogicalProjectName, 
		                                           strProjectName, 
		                                           strProfileName);

	if(errorCode !=SUCCESS)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: " << getErrorMessage(errorCode) << 
			"LTKLipiEngineModule::createShapeRecognizer()"<<endl;

		LTKReturnError(errorCode);
	}

	errorCode = createShapeRecognizer(strProjectName,strProfileName,outShapeRecognizerPtr);

	if(errorCode !=SUCCESS)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: " << getErrorMessage(errorCode) << 
			"LTKLipiEngineModule::createShapeRecognizer()"<<endl;

		LTKReturnError(errorCode);
	}

	LOG(LTKLogger::LTK_LOGLEVEL_INFO)<<
		"Exiting: LTKLipiEngineModule::createShapeRecognizer()"<<endl;

	return SUCCESS;

}
/**********************************************************************************
* AUTHOR		: Nidhi Sharma
* DATE			: 11-Dec-2007
* NAME			: getFeatureExtractorInst
* DESCRIPTION	: 
* ARGUMENTS		:
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of LTKFeatureExtractor
*************************************************************************************/
int LTKShapeFeatureExtractorFactory::getFeatureExtractorInst(
                                 const string& lipiRootPath,
                                 const string& feName,
                                 void** m_libHandlerFE,
                                 const LTKControlInfo& controlInfo,
                                 LTKShapeFeatureExtractor** outFeatureExtractor)
{
	FN_PTR_CREATE_SHAPE_FEATURE_EXTRACTOR createFeatureExtractorPtr;
    void *functionHandle = NULL;

    LTKOSUtil* utilPtr = LTKOSUtilFactory::getInstance();

    int returnVal = utilPtr->loadSharedLib(lipiRootPath, feName, m_libHandlerFE);

    
	if(returnVal != SUCCESS)
	{
	    LTKReturnError(ELOAD_FEATEXT_DLL);
	}

    returnVal = utilPtr->getFunctionAddress(*m_libHandlerFE, 
                                            CREATE_SHAPE_FEATURE_EXTRACTOR, 
                                            &functionHandle);

	if(returnVal != SUCCESS)
	{
	    utilPtr->unloadSharedLib(m_libHandlerFE);
        *m_libHandlerFE = NULL;

		LTKReturnError(EDLL_FUNC_ADDRESS_CREATE_FEATEXT);
	}

    createFeatureExtractorPtr = (FN_PTR_CREATE_SHAPE_FEATURE_EXTRACTOR)functionHandle;

    int errorCode = createFeatureExtractorPtr(controlInfo, outFeatureExtractor);

    if (errorCode != SUCCESS)
    {
		LTKReturnError(errorCode);
    }

    delete utilPtr;
	return SUCCESS;

}
Example #22
0
int HolisticRecognizer::initialize(string& strProjectName, string &strProfileName)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
        "Entered HolisticShapeRecognizer::Initialize" << endl;

	string LipiRootPath = string(getLipiPath());	
	string tempStr = "";
    string preprocDllPath = "";
	headerInfo[PROJNAME] = strProjectName;
	int returnStatus=0;
	string strNumShapes = "";

	ltkShapeRecPtr = NULL;	

	//path for holistic.cfg
	m_holisticCfgFile = LipiRootPath + PROJECTS_PATH_STRING + strProjectName + PROFILE_PATH_STRING + strProfileName + SEPARATOR + HOLISTIC + CONFIGFILEEXT;

	//path for holistic.mdt
	m_referenceModelFile = LipiRootPath + PROJECTS_PATH_STRING + strProjectName + PROFILE_PATH_STRING + strProfileName + SEPARATOR + HOLISTIC + DATFILEEXT;

	m_confMapFile = LipiRootPath + PROJECTS_PATH_STRING + strProjectName + PROFILE_PATH_STRING + strProfileName + SEPARATOR;
                
	// Read number of shapes from project.cfg
	tempStr = LipiRootPath + PROJECTS_PATH_STRING + strProjectName + PROFILE_PATH_STRING + PROJECT_CFG_STRING;
	try
	{
		//To find whether the project was dynamic or not
		//to read read number of shapes from project.cfg
		m_projectTypeDynamic = shaperecUtilInst->isProjectDynamic(tempStr, m_numShapes, returnStatus, strNumShapes);
		
		headerInfo[NUMSHAPES] = strNumShapes;
		
		preprocDllPath = LipiRootPath + SEPARATOR + "lib" + SEPARATOR + PREPROC + DLL_EXT;

		// initialize preprocessor
		returnStatus = 0;
		ltkShapeRecPtr = shaperecUtilInst->initializePreprocessor(preprocDllPath,
						returnStatus);

	}
	
	catch(LTKException e)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << e.getExceptionMessage() << endl;
		LTKReturnError(returnStatus);
	}
	
	//setPreprocMap(); // To add function name and the function address into the mapping variable.

	//Assigning Default Values
	assignDefaultValues();

	//Reading pca configuration file
	returnStatus = readClassifierConfig();

	return returnStatus;
}
/**********************************************************************************
* AUTHOR		: Deepu V.
* DATE			: 22-FEB-2005
* NAME			: addTraceGroup
* DESCRIPTION	: Adds a vector of tracegroup for recognition in the recognition context
* ARGUMENTS		: fieldInk -  the ink to be added.
* RETURNS		: SUCCESS/FAILURE
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
*************************************************************************************/
int LTKRecognitionContext::addTraceGroups (const LTKTraceGroupVector& fieldInk) 
{
	int numTraceGroups = fieldInk.size(); //number of trace groups
	int numTraces =0;  //number of traces in each trace group
	string tempStr;    //strokes temporary string for getFlag
	int recMode =0;      // the recognition mode

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
        " Entering: LTKRecognitionContext::addTraceGroups()" << endl;

	for(int i =0; i<numTraceGroups; ++i)
	{	
		//accessing each trace group
		const LTKTraceGroup& traceGp = fieldInk[i];

		//get all traces from tracegp
		 //const LTKTraceVector& allTraces = traceGp.getAllTraces();
		const LTKTraceVector& allTraces = traceGp.getAllTraces();
		
		//push each trace to local buffer
		numTraces = allTraces.size();
		
		for(int j = 0; j<numTraces; ++j)
		{
			m_fieldInk.push_back(allTraces[j]);
		}

		LOG(LTKLogger::LTK_LOGLEVEL_INFO) << "Pushed Trace Group:"<<i<<endl;

	}

	//if the recognition mode is set to streaming mode
	//the recognizer is called at this point
	tempStr = REC_MODE;

	int errorCode;
	
	if((errorCode = getFlag(tempStr,recMode))!=SUCCESS)
	{
		LOG(LTKLogger::LTK_LOGLEVEL_ERR)
        <<"Error: LTKRecognitionContext::addTraceGroups()"<<endl;

		LTKReturnError(errorCode);
	}
	
	if(recMode ==  REC_MODE_STREAMING) 
	{
 		m_wordRecPtr->processInk(*this);
	}

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << 
        " Exiting: LTKRecognitionContext::addTraceGroups()" << endl;



	return SUCCESS;
}
/******************************************************************************
* AUTHOR        : Thanigai 
* DATE          : 29-JUL-2005
* NAME          : initializeLipiEngine
* DESCRIPTION   : Reads the lipiengine.cfg and store the AVP map into 
*				  the map variable "m_LipiEngineConfigEntries"
* ARGUMENTS     : 
* RETURNS       : 0 on success other values error
* NOTES         :
* CHANGE HISTROY
* Author            Date                Description of change
******************************************************************************/
int LTKLipiEngineModule::initializeLipiEngine()
{
	//Log messages after call to configureLogger()	
	
	string temp;
	int errorCode;
	
	if(m_strLipiRootPath == "")
	{
		LTKReturnError(ELIPI_ROOT_PATH_NOT_SET);	// PATH not set
	}

	temp = m_strLipiRootPath + SEPARATOR + "projects" + SEPARATOR + 
		   LIPIENGINE_CFG_STRING;
	
	//Read the logical name mapping file from lipiengine.cfg file;
	try
	{
		m_LipiEngineConfigEntries = new LTKConfigFileReader(temp);

	}
	catch(LTKException e)
	{
		// display warning to the user and continue with default values
		cout << " Could not open file : " << temp << endl <<
		        "proceeding with defaults" << endl;
	}

    errorCode = configureLogger();	// Configure the logger

	if(errorCode !=SUCCESS)
	{
		LTKReturnError(errorCode);
	}
	else
	{
		LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< 
			"LTKLipiEngineModule::initializeLipiEngine()" << endl;
	}

	return SUCCESS;
}
/***********************************************************************
* AUTHOR		: Nidhi Sharma
* DATE			: 07-FEB-2007
* NAME			: createFeatureExtractor
* DESCRIPTION	: create method of a factory class
* ARGUMENTS		:
* RETURNS		: Pointer to the instance of LTKShapeFeatureExtractor
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of LTKFeatureExtractor
******************************************************************************/
int LTKShapeFeatureExtractorFactory::createFeatureExtractor(
                                const string& featureExtractorName,
                                const string& lipiRootPath,
                                void** m_libHandlerFE, 
                                const LTKControlInfo& controlInfo,
                                LTKShapeFeatureExtractor** outFeatureExtractor)
{
    LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " << 
        "LTKShapeFeatureExtractorFactory::createFeatureExtractor()" << endl;
    
    string feName = "";
    
	int errorCode = mapFeatureExtractor(featureExtractorName, feName);

    if (errorCode != SUCCESS)
    {
        LOG( LTKLogger::LTK_LOGLEVEL_ERR)
           << getErrorMessage(errorCode)  
           << "LTKShapeFeatureExtractorFactory::createFeatureExtractor:"
           << endl;
        
        LTKReturnError(errorCode);
    }
        
    errorCode = getFeatureExtractorInst(lipiRootPath, feName, m_libHandlerFE, 
			                            controlInfo, outFeatureExtractor);

    if ( errorCode != SUCCESS)
    {
        LOG( LTKLogger::LTK_LOGLEVEL_ERR)
           << getErrorMessage(errorCode) << ":" << feName 
           << "LTKShapeFeatureExtractorFactory::createFeatureExtractor:"
           << endl;
        
        LTKReturnError(errorCode);
    }

    LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " << 
        "LTKShapeFeatureExtractorFactory::createFeatureExtractor()" << endl;
    
    return SUCCESS;
}
/**********************************************************************************
* 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;

}
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        : Balaji MNA 
* DATE          : 14-JUN-2009
* NAME          : createWordRecognizer
* DESCRIPTION   : resolves logical project name and call createWordRecognizer
*				  function.  
* ARGUMENTS     : strLogicalProjectName - logical project name; 
*                 outShapeRecognizerPtr - return shape recognizer object 
* RETURNS       : if success returns 0 or if fails returns error code 
* NOTES         :
* CHANGE HISTROY
* Author            Date                Description of change
******************************************************************************/
int LTKLipiEngineModule::createWordRecognizer(const string& strlogicalProjectName, 
                              LTKWordRecognizer** outWordRecPtr)
{
	LOG(LTKLogger::LTK_LOGLEVEL_INFO)<<
		"Entering: LTKLipiEngineModule::createWordRecognizer()"<<endl;

	int errorCode;
	string strProjectName;
    string strProfileName;

	errorCode = resolveLogicalNameToProjectProfile(strlogicalProjectName, 
	                                               strProjectName, 
										           strProfileName);

	if(errorCode !=SUCCESS)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: " << getErrorMessage(errorCode) << 
			"LTKLipiEngineModule::createWordRecognizer()"<<endl;

		LTKReturnError(errorCode);
	}

	errorCode = createWordRecognizer(strProjectName,strProfileName, 
											    outWordRecPtr); 
	if (errorCode != SUCCESS)
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
    			"Error: " << getErrorMessage(errorCode) << 
    			"LTKLipiEngineModule::createWordRecognizer()"<<endl;

		LTKReturnError(errorCode);
	}

	LOG(LTKLogger::LTK_LOGLEVEL_INFO)<<
		"Exiting: LTKLipiEngineModule::createWordRecognizer()"<<endl;

	return SUCCESS;
}
int createShapeRecognizer(const LTKControlInfo& controlInfo,
						  LTKShapeRecognizer** ptrObj )
{
	try
	{
		*ptrObj = new ActiveDTWShapeRecognizer(controlInfo);
		return SUCCESS;
	}
	catch(LTKException e)
	{
		LTKReturnError(e.getErrorCode());
	}
}
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);
	
	

}