Exemplo n.º 1
0
void openCommon()
{
	XnStatus nRetVal = XN_STATUS_OK;

	g_bIsDepthOn = false;
	g_bIsImageOn = false;
	g_bIsIROn = false;
	g_bIsAudioOn = false;

	NodeInfoList list;
	nRetVal = g_Context.EnumerateExistingNodes(list);
	if (nRetVal == XN_STATUS_OK)
	{
		for (NodeInfoList::Iterator it = list.Begin(); it != list.End(); ++it)
		{
			switch ((*it).GetDescription().Type)
			{
			case XN_NODE_TYPE_DEVICE:
				(*it).GetInstance(g_Device);
				break;
			case XN_NODE_TYPE_DEPTH:
				g_bIsDepthOn = true;
				(*it).GetInstance(g_Depth);
				break;
			case XN_NODE_TYPE_IMAGE:
				g_bIsImageOn = true;
				(*it).GetInstance(g_Image);
				break;
			case XN_NODE_TYPE_IR:
				g_bIsIROn = true;
				(*it).GetInstance(g_IR);
				break;
			case XN_NODE_TYPE_AUDIO:
				g_bIsAudioOn = true;
				(*it).GetInstance(g_Audio);
				break;
			case XN_NODE_TYPE_PLAYER:
				g_bIsPlayerOn = true;
				(*it).GetInstance(g_Player);
			}
		}
	}

	XnCallbackHandle hDummy;
	g_Context.RegisterToErrorStateChange(onErrorStateChanged, NULL, hDummy);

	initConstants();

	readFrame();
}
Exemplo n.º 2
0
/**
  * Inicia los nodos de información provinientes de Kinect
  *
  */
void openCommon(){
    XnStatus nRetVal = XN_STATUS_OK;
    NodeInfoList list;
    nRetVal = g_Context.EnumerateExistingNodes(list);
    if (nRetVal == XN_STATUS_OK){
        for (NodeInfoList::Iterator it = list.Begin(); it != list.End(); ++it){
            switch ((*it).GetDescription().Type){
                case XN_NODE_TYPE_DEPTH:
                    (*it).GetInstance(g_DepthGenerator);
                break;
                case XN_NODE_TYPE_IMAGE:
                    (*it).GetInstance(g_ImageGenerator);
                    break;
                case XN_NODE_TYPE_USER:
                    (*it).GetInstance(g_UserGenerator);
                    break;
                case XN_NODE_TYPE_PLAYER:
                    (*it).GetInstance(g_Player);
                    break;
            }
        }
    }
}//openCommon
Exemplo n.º 3
0
XnStatus GeneratorWatcher::UpdateFrameSync()
{
	// go over all nodes, and find the frame synced one
	Context context;
	m_generator.GetContext(context);
	
	NodeInfoList nodes;
	XnStatus nRetVal = context.EnumerateExistingNodes(nodes);
	XN_IS_STATUS_OK(nRetVal);

	for (NodeInfoList::Iterator it = nodes.Begin(); it != nodes.End(); ++it)
	{
		NodeInfo info = *it;
		// make sure this is a generator
		if (xnIsTypeDerivedFrom(info.GetDescription().Type, XN_NODE_TYPE_GENERATOR))
		{
			Generator otherGen;
			nRetVal = info.GetInstance(otherGen);
			XN_IS_STATUS_OK(nRetVal);

			if (m_generator.GetFrameSyncCap().IsFrameSyncedWith(otherGen))
			{
				nRetVal = NotifyStringPropChanged(XN_PROP_FRAME_SYNCED_WITH, otherGen.GetName());
				XN_IS_STATUS_OK(nRetVal);

				return XN_STATUS_OK;
			}
		}
	}

	// if we got here, we're not frame synced
	nRetVal = NotifyStringPropChanged(XN_PROP_FRAME_SYNCED_WITH, "");
	XN_IS_STATUS_OK(nRetVal);

	return XN_STATUS_OK;
}
Exemplo n.º 4
0
int main(int argc, char* argv[])
{
	XnStatus nRetVal = XN_STATUS_OK;

	Context context;
	EnumerationErrors errors;
	Mode mode;

	// default mode
#if XN_PLATFORM == XN_PLATFORM_WIN32
	mode = MODE_PLAY;
#else
	mode = MODE_RECORD;
#endif

	// check if mode was provided by user
	if (argc > 1)
	{
		if (strcmp(argv[1], "play") == 0)
		{
			mode = MODE_PLAY;
		}
		else if (strcmp(argv[1], "record") == 0)
		{
			mode = MODE_RECORD;
		}
		else
		{
			printUsage(argv[0]);
			return -1;
		}
	}

	// make sure mode is valid
#if XN_PLATFORM != XN_PLATFORM_WIN32
	if (mode == MODE_PLAY)
	{
		printf("Playing is not supported on this platform!\n");
		return -1;
	}
#endif

	ScriptNode scriptNode;

	nRetVal = context.InitFromXmlFile(SAMPLE_XML_PATH, scriptNode);
	if (nRetVal == XN_STATUS_NO_NODE_PRESENT)
	{
		XnChar strError[1024];
		errors.ToString(strError, 1024);
		printf("%s\n", strError);
		return (nRetVal);
	}
	else if (nRetVal != XN_STATUS_OK)
	{
		printf("Open failed: %s\n", xnGetStatusString(nRetVal));
		return (nRetVal);
	}

	// find audio nodes
	AudioGenerator gens[nSupportedNodes];
	XnUInt32 nNodes = 0;

	NodeInfoList list;
	nRetVal = context.EnumerateExistingNodes(list, XN_NODE_TYPE_AUDIO);
	CHECK_RC(nRetVal, "Enumerate audio nodes");

	for (NodeInfoList::Iterator it = list.Begin(); it != list.End(); ++it)
	{
		NodeInfo info = *it;
		nRetVal = info.GetInstance(gens[nNodes]);
		CHECK_RC(nRetVal, "Get audio node");
		nNodes++;
	}

	if (nNodes == 0)
	{
		printf("No audio node was found!\n");
		return -1;
	}

	if (mode == MODE_PLAY)
	{
		nRetVal = play(context, gens, nNodes);
	}
	else if (mode == MODE_RECORD)
	{
		nRetVal = record(context, gens, nNodes);
	}

	scriptNode.Release();
	for (int i = 0; i < nSupportedNodes; ++i)
		gens[i].Release();
	context.Release();

	return nRetVal;
}