예제 #1
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;
}
예제 #2
0
bool IisuManager::resumeStream()
{
	// Check device.
	if (!m_device)
	{
		SK_LOGGER(LOG_ERROR) << "No iisu device available: cannot stream.";
		return false;
	}

	// Linearize PathMaps.
	linearizePathMap(m_dataBase->getPathMapsRoot());
	SK_LOGGER(LOG_INFO) << "Path maps linearization OK.";

	// Create the TypedPathMaps (depending of their type returned by iisu).
	for (uint i = 0; i < m_pathMapsLinearized.size(); ++i)
	{
		const PathMap* pathMap = m_pathMapsLinearized[i];
		assert(pathMap);

		if (pathMap->getIisuPath() == "")
			continue;

		// Check the path exists and get its type.
		SK::Return<SK::TypeInfo> retType = m_device->getDataType(pathMap->getIisuPath().c_str()) ;
		if (retType.failed())
		{
			SK_LOGGER(LOG_ERROR) << "Path \'" << pathMap->getIisuPath() << "\' does not exist.";

			continue;
		}

		std::string fullOscPaths = pathMap->findFullOscPath();

		SK::TypeInfo typeInfo = retType.get() ;
		TypedPathMap* typedPathMap = SK::TypeInfo::injectIisuType<BaseTypedPathMapFactory, TypedPathMapFactory>(typeInfo)->create(fullOscPaths, pathMap->getIisuPath());
	
		if (!typedPathMap)
		{
			SK_LOGGER(LOG_WARNING) << "Type \'" << typeInfo.name() << "\' is not handled by the OSC stream. Data \'" << pathMap->getIisuPath() << "\' will not stream.";

			continue;
		}

		m_typedPathMapsLinearized.push_back(typedPathMap);
	}

	SK_LOGGER(LOG_INFO) << "TypedPathMaps instantiated.";

	// Register data handles.
	IisuDataRegistrator iisuPathRegistrator(m_device, m_iisuDataHandles);
	for (uint i = 0; i < m_typedPathMapsLinearized.size(); ++i)
		m_typedPathMapsLinearized[i]->accept(&iisuPathRegistrator);

	// Start device.
	m_device->start();

	SK_LOGGER(LOG_INFO) << "The iisu engine is started.";
	SK_LOGGER(LOG_INFO) << "OscBridge is now streaming OSC...";

	return true;
}
예제 #3
0
void CloseIisuServer::handPoseGestureHandler ( SK::HandPosingGestureEvent e ) 
{
	//Get posing metaInfo
	SK::Return<SK::MetaInfo<SK::HandPosingGestureEvent> > retMetaInfo = m_device->getEventManager().getMetaInfo<SK::HandPosingGestureEvent>("CI.HandPosingGesture") ; 

	if ( retMetaInfo.succeeded() ) 
	{
		SK::MetaInfo<SK::HandPosingGestureEvent> poseMetaInfo = retMetaInfo.get() ; 
		const SK::EnumMapper &enumMapper = poseMetaInfo.getEnumMapper() ; 

		/*
		//Get the Big 5
		SK::Return<uint32_t> retBig5GestureId = enumMapper["BIG_5"] ; 
		if ( retBig5GestureId.succeeded() ) 
		{
			uint32_t big5GestureID = retBig5GestureId.get() ; 
			//cout << "BIG_5 id : " << big5GestureID << endl ; 
		}
		

		SK::Return<uint32_t> retFistGestureID = enumMapper["FIST"] ; 
		if ( retBig5GestureId.succeeded() ) 
		{
			uint32_t fistGestureID = retFistGestureID.get() ; 
			//cout << "FIST id : " << fistGestureID << endl ; 
		}*/


		int gestureID = e.getGestureTypeID() ; 
		SK::Return<SK::String> retPosingGestureName = enumMapper[gestureID] ; 
		if ( retPosingGestureName.succeeded() ) 
		{
			SK::String gestureName = retPosingGestureName.get() ; 
			cout << "pose: " << gestureName << "   _ gestureTypeID : " << e.getGestureTypeID() << "   _ firstHand ID: " << e.getFirstHandID() << endl ; 
			int args =  e.getGestureTypeID() ; 
			ofNotifyEvent( IisuEvents::Instance()->POSE_GESTURE , args ) ; 
		}

		/*
		if ( gestureID == 3 || gestureID == 12  ) 
		{
			//cout << "selection event occured!" << endl ; 
			//ofNotifyEvent( IisuEvents::Instance()->HAND_CLAMP_SELECTION , gestureID ) ; 
		}

		if ( gestureID == 13 ) 
		{
			cout << "selection event occured!" << endl ; 
			//ofNotifyEvent( IisuEvents::Instance()->THUMBS_UP , gestureID ) ; 
		}*/
		
	}
	else
	{
		//cout << "meta Info did not succeed! " << endl ; 
	}
	
	//cout << "hand pose handled!" << endl ; 
	
	
}