none
Kinect - multiple instances RRS feed

  • Question

  • Hi to all :)

    I'm writing a c++ code for Kinect (SDK 1.0) and having some problems. Now what I'm doing:

    First I calling Initialization:

    void Init()
    {
    	if ( !m_pNuiSensor )
    	{
    		HRESULT hr = NuiCreateSensorByIndex(0, &m_pNuiSensor);
    		if ( FAILED(hr) )
    		{
    			return hr;
    		}
    		SysFreeString(m_instanceId);
    		m_instanceId = m_pNuiSensor->NuiDeviceConnectionId();
    		DWORD nuiFlags = NUI_INITIALIZE_FLAG_USES_COLOR;
    		hr = m_pNuiSensor->NuiInitialize(nuiFlags);
    	}
    }

    I get m_pNuiSensor, and I Initialize NUI engine it with nuiFlags.

    when I want to Close my app I'm doing the folowing code:

    void Close()
    {
    	if(m_pNuiSensor)
    	{
    		m_pNuiSensor->NuiShutdown();
    	}
    	if ( m_pNuiSensor )
    	{
    		m_pNuiSensor->Release();
    		m_pNuiSensor = NULL;
    	}
    }

    If I call from my main program following code:

    Init();
    Close();
    Init();

    My program get stuck in Init() I called for second time in following line

    hr = m_pNuiSensor->NuiInitialize(nuiFlags);

    Now, my question is why my program stuck at this line if I previously with Close() function did turn off NUI engine with

    m_pNuiSensor->NuiShutdown();

    Am I missing something, or?

    Thank you!

    Thursday, February 23, 2012 9:46 AM

Answers

  • Problem solved!

    I was missing NuiSetDeviceStatusCallback.
    Now everything works.

    • Marked as answer by ayamiKinect Thursday, February 23, 2012 11:02 AM
    Thursday, February 23, 2012 11:02 AM