コード例 #1
0
bool IisuManager::loadIidGraph(const std::string& newIidFilePath)
{
	if (newIidFilePath == "")
	{
		SK_LOGGER(LOG_INFO) << "The new IID file path is empty.";

		return true;
	}

	if (!m_device)
	{
		SK_LOGGER(LOG_ERROR) << "Load IID graph : device does not exist, cannot load iid graph.";

		return false;
	}

	SK::CommandHandle<SK::Result (const SK::String&)> loadIidGraph = m_device->getCommandManager().registerCommandHandle<SK::Result(const SK::String&)>("IID.loadGraph");
	SK::Result resLoadCmd = loadIidGraph(newIidFilePath.c_str());
	if (resLoadCmd.failed())
	{
		SK_LOGGER(LOG_ERROR) << std::string("Load IID graph : ") + resLoadCmd.getDescription().ptr();

		return false;
	}

	SK_LOGGER(LOG_INFO) << "IID file loaded correctly.";

	return true;
}
コード例 #2
0
void CloseIisuServer::setup() 
{
	// We need to specify where is located the iisu dll and it's configuration file.
	// in this sample we'll use the SDK's environment variable.

	string dllLocation = getenv("IISU_SDK_DIR") ;
	dllLocation+="/bin" ;

	// get the working context
	Context& context = Context::Instance();

	// create an iisu configuration
	IisuHandle::Configuration iisuConfiguration(dllLocation.c_str(),"iisu_config.xml");
	// you can customize the configuration here
	
	// create the handle according to the configuration structure
	Return<IisuHandle*> retHandle = context.createHandle(iisuConfiguration);
	if(retHandle.failed())
	{
		cerr << "Failed to get iisu handle!" << endl
			<< "Error " << retHandle.getErrorCode() << ": " << retHandle.getDescription().ptr() << endl;
		getchar();
		exit(0);
	}

	// get the iisu handle
	m_iisuHandle = retHandle.get();

	// create device configuration
	Device::Configuration deviceConfiguration ;
	// you can customize the configuration here

	// create the device according to the configuration structure
	Return<Device*> retDevice = m_iisuHandle->initializeDevice(deviceConfiguration);
	if(retDevice.failed())
	{
		cerr << "Failed to create device!" << endl
			<< "Error " << retDevice.getErrorCode() << ": " << retDevice.getDescription().ptr() << endl;
		getchar();
		exit(0);
	}

	// get the device
	m_device = retDevice.get();

	registerEvents() ; 
	initIisu() ; 

	SK::Result devStart = m_device->start();
	if(devStart.failed())
	{
		cerr << "Failed to start device!" << endl
			<< "Error " << devStart.getErrorCode() << ": " << devStart.getDescription().ptr() << endl;
		getchar();
		exit(0);
	}

}
コード例 #3
0
bool IisuManager::initIisu()
{
	// Iisu context.
	SK::Context& context = SK::Context::Instance();

	SK_LOGGER(LOG_INFO) << "The context instance was obtained.";

	// Iisu handle.
	char* iisuSdkDir_char = getenv("IISU_SDK_DIR");
	if (iisuSdkDir_char == 0)
	{
		SK_LOGGER(LOG_ERROR) << "Cannot find environment variable \'IISU_SDK_DIR\':";
		SK_LOGGER(LOG_ERROR) << "     -> the iisu runtime may not have been installed correctly.";
		return false;
	}

	std::string iisuSdkDir(iisuSdkDir_char);
	std::string iisuBinDir = iisuSdkDir + "\\bin";

	SK::IisuHandle::Configuration handleConf(iisuBinDir.c_str());
	SK::Return<SK::IisuHandle*> retHandle = context.createHandle(handleConf);
	if (retHandle.failed())
	{
		SK_LOGGER(LOG_ERROR) << retHandle.getDescription().ptr();
		return false;
	}
	SK::IisuHandle* handle = retHandle.get();

	SK_LOGGER(LOG_INFO) << "The application handle was obtained.";

	// Iisu device.
	SK::Device::Configuration deviceConf;
	SK::Return<SK::Device*> retDevice = handle->initializeDevice(deviceConf);
	if (retDevice.failed())
	{
		SK_LOGGER(LOG_ERROR) << retDevice.getDescription().ptr();

		SK::Result result = context.destroyHandle(*handle);
		if (result.failed())
			SK_LOGGER(LOG_ERROR) << result.getDescription().ptr();

		return false;
	}
	m_device = retDevice.get();

	SK_LOGGER(LOG_INFO) << "The iisu device was obtained.";

	// Iisu events registration.
	m_device->getEventManager().registerEventListener("SYSTEM.Error", *this, &IisuManager::iisuErrorListener);
	m_device->getEventManager().registerEventListener("DEVICE.DataFrame", *this, &IisuManager::newIisuDataFrameListener);

	SK_LOGGER(LOG_INFO) << "The event listeners were registered.";

	return true;
}
コード例 #4
0
void CloseIisuServer::onDataFrame(const DataFrameEvent& event)	
{ 

	SK::Result resUpdate = m_device->updateFrame(true);
	if(resUpdate.failed())
	{
		cerr << "Failed to update data frame" << endl;
	}
	// the rest of the logic depends on iisu data, so we need to make sure that we have
	// already a new data frame
	const int32_t currentFrameID = m_device->getDataFrame().getFrameID();
	if (currentFrameID == m_lastFrameID)
	{
		cout << "Same Frame as before" << endl ; 
		return;
	}
	else
	{
		//cout << "frame# " << currentFrameID << endl ; 

	}
	
	m_hand1_status = m_hand1_statusHandle.get( ) ; 
	if ( m_hand1_status >  0 ) 
	{
		m_hand1_palmPosition = m_hand1_palmPositionHandle.get() ;
		m_hand1_fingerTipsStatus = m_hand1_fingerTipsStatusHandle.get() ; 
		m_hand1_fingerTips = m_hand1_fingerTipsHandle.get() ; 
		m_hand1_open = m_hand1_openHandle.get() ; 
		m_hand1_openAmount = m_hand1_openAmountHandle.get() ; 
	}
	// remember current frame id
	m_lastFrameID = currentFrameID;

	// tell iisu we finished using data.
	m_device->releaseFrame();
}