⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ltkshaperecoconfig.cpp

📁 An open source handwriting recongnition package!!!
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************************
* 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-07-18 15:00:39 +0530 (Fri, 18 Jul 2008) $
 * $Revision: 561 $
 * $Author: sharmnid $
 *
 ************************************************************************/
/************************************************************************
 * FILE DESCR: Implementation of LTKShapeRecoConfig which holds the configuration information read 
 *			   from the configuration files
 *
 * CONTENTS:   
 *	readConfigInfo
 *	getLipiRoot
 *	getShapeSet
 *	getProfile
 *	getShapeRecognizerName
 *	getNumberOfShapes
 *	setLipiRoot
 *	setShapeSet
 *	setProfile
 *	setShapeRecognizerName
 *	setNumShapes
 *
 * AUTHOR:     Balaji R.
 *
 * DATE:       December 23, 2004
 * CHANGE HISTORY:
 * Author		Date			Description of change
 ************************************************************************/

#include "LTKShapeRecoConfig.h"
#include "LTKErrorsList.h"
#include "LTKLoggerUtil.h"
#include "LTKErrors.h"
#include "LTKShapeRecoConfig.h"
#include "LTKException.h"
#include "LTKConfigFileReader.h"
#include "LTKMacros.h"

/**********************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: LTKShapeRecoConfig
* DESCRIPTION	: Default Constructor
* ARGUMENTS		: 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
*************************************************************************************/

LTKShapeRecoConfig::LTKShapeRecoConfig()
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "Entered default constructor of LTKShapeRecoConfig"  << endl;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "Exiting default constructor of LTKShapeRecoConfig"  << endl;
}

/**********************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: LTKShapeRecoConfig
* DESCRIPTION	: Constructor initializing the member variables
* ARGUMENTS		: lipiRoot - root directory of the Lipi Tool Kit
*				  shapeSet - shape set to be used for training/recognition
*				  profile - profile to be used for training/recognition
*				  shapeRecognizerName - name of the shape recognizer to be used for training/recognition
*				  numShapes - number of shapes in the recognition problem
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
* ************************************************************************************/

LTKShapeRecoConfig::LTKShapeRecoConfig(const  string& lipiRoot, const string& shapeSet,
					 const  string& profile, const string& shapeRecognizerName, int numShapes) :
					m_lipiRoot(lipiRoot), m_shapeSet(shapeSet), m_profile(profile),
					m_shapeRecognizerName(shapeRecognizerName), m_numShapes(numShapes)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "Entered initialization constructor of LTKShapeRecoConfig"  << endl;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "m_lipiRoot = " << m_lipiRoot  << endl;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "m_shapeSet = " << m_shapeSet  << endl;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "m_profile = " << m_profile  << endl;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "m_shapeRecognizerName = " << m_shapeRecognizerName  << endl;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "m_numShapes = " << m_numShapes  << endl;

	if(m_numShapes <= 0)
	{
		errorCode = EINVALID_NUM_OF_SHAPES;

		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
            "Invalid value for number of shapes :" << m_numShapes << endl;
		
		throw LTKException(errorCode);
	}

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "Exiting initialization constructor of LTKShapeRecoConfig"  << endl;
}

/**********************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: readConfig
* DESCRIPTION	: Reads the configuration files
* ARGUMENTS		: configFile - name of the main configuration file
* RETURNS		: SUCCESS on successful reading of the configuration file
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
* ************************************************************************************/

int LTKShapeRecoConfig::readConfigInfo(const string& configFile)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "Entered LTKShapeRecoConfig::readConfig"  << endl;

	string shapeSetCfg;						//	shape set configuration file

	string profileCfg;						//	profile configuration file

	LTKConfigFileReader* mainProperties;			//	main config file name value pairs
	
	LTKConfigFileReader* shapesetProperties;		//	shapeset config name value pairs

	LTKConfigFileReader* profileProperties;		//	profile config name value pairs

	//	reading the main configuration file

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
	    "Main configuration file is " << configFile  << endl;

	mainProperties = new LTKConfigFileReader(configFile);

	LOG( LTKLogger::LTK_LOGLEVEL_INFO) << 
        "Main configuration read"  << endl;

	//	setting config information
	
	mainProperties->getConfigValue("shapeset", m_shapeSet);

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "shapeSet = " << m_shapeSet  << endl;

	mainProperties->getConfigValue("profile", m_profile);

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "profile = " << m_profile  << endl;

	//	composing the shape set configuration file name

	shapeSetCfg = m_lipiRoot + SEPARATOR + m_shapeSet + SEPARATOR + SHAPESETFILE;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "Shapeset configuration file is " << shapeSetCfg  << endl;

	//	reading the shape set configuration file

	shapesetProperties = new LTKConfigFileReader(shapeSetCfg);

	LOG( LTKLogger::LTK_LOGLEVEL_INFO) << 
        "Shapeset configuration read"  << endl;

	//	setting config information
	string numShapesStr;
	shapesetProperties->getConfigValue(PROJECT_CFG_ATTR_NUMSHAPES_STR, numShapesStr);
	m_numShapes = atoi(numShapesStr.c_str());

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "m_numShapes = " << m_numShapes  << endl;

	if(m_numShapes <= 0)
	{
		delete mainProperties;
		delete shapesetProperties;

		LOG( LTKLogger::LTK_LOGLEVEL_ERR) <<
            "Invalid value for number of shapes : " << m_numShapes << endl;

		LTKReturnError(EINVALID_NUM_OF_SHAPES); // Error while reading project.cfg 

		//throw LTKException("numShapes cannot be less than or equal to zero");
	}

	//	composing the proile configuration file name
	
	profileCfg = m_lipiRoot + SEPARATOR + m_shapeSet + SEPARATOR + m_profile + SEPARATOR + PROFILEFILE;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "Profile configuration file is " << profileCfg  << endl;

	//	reading the profile configuration file

	profileProperties = new LTKConfigFileReader(profileCfg);

	LOG( LTKLogger::LTK_LOGLEVEL_INFO) << "Profile configuration read"  << endl;

	//	setting config information

	profileProperties->getConfigValue(SHAPE_RECOGNIZER_STRING, m_shapeRecognizerName);

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "m_shapeRecognizerName = " << m_shapeRecognizerName  << endl;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  "Exiting LTKShapeRecoConfig::readConfig"  << endl;

	delete mainProperties;
	delete shapesetProperties;
	delete profileProperties;
	return SUCCESS;
	
}

/**********************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: getLipiRoot
* DESCRIPTION	: returns the root directory of the lipi tool kit
* ARGUMENTS		: 
* RETURNS		: root directory of the lipi tool kit
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
* ************************************************************************************/

const string& LTKShapeRecoConfig::getLipiRoot()
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "Entered LTKShapeRecoConfig::getLipiRoot"  << endl;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<  
        "Exiting LTKShapeRecoConfig::getLipiRoot with return value " <<
        m_lipiRoot  << endl;

	return m_lipiRoot;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -