Click here to Skip to main content
15,882,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So, I'm trying to make Kinect v1.8 Run in C++/CX UWP XAML. Every other NUI Function seems to work besides NuiInitialize(). If I run the examples from the Developer Toolkit in native C++ they work just fine. I'm not really sure why it may be failing. If anyone can give me a little guidance it would be much appreciated.

I have tried looking at ColorBasics-D2D and seeing if I had anything in the properties of my project that wasn't allowing it to work. Couldn't find a solution. I have tried Initializing outside of the .DLL in a .EXE and still nothing. I'm not sure if it can work or not. Maybe C++/CX Doesn't work with the Kinect v1.8. I don't understand why It wouldn't. One more thing I tried was allowing /CLR code.

None of the above worked.

Debug Output

KSensorManager::Refresh();
{
Sensor Count: 1 NuiStatus() S_OK; NuiInitialize() FAILED;
}

The code below is running in a DLL

C++
void KSensorManager::Refresh()
    {
        OutputDebugStringA("KSensorManager::Refresh();\n{\n");
        INuiSensor * pNuiSensor;
        HRESULT hr;

        Sensors->Clear();

        int iSensorCount = 0;
        hr = NuiGetSensorCount(&iSensorCount);

        String^ str = iSensorCount.ToString();
        std::wstring ws1(str->Data());
        LPCSTR ls = LPCSTR(ws1.c_str());
        OutputDebugStringA("    Sensor Count: ");
        OutputDebugStringA(ls);
        for (int i = 0; i < iSensorCount; ++i)
        {
            hr = NuiCreateSensorByIndex(i, &pNuiSensor);
            if (FAILED(hr))
            {
                OutputDebugStringA("    NuiCreateSensorByIndex() FAILED; ");
                continue;
            }

            hr = pNuiSensor->NuiStatus();
            if (S_OK == hr)
            {
                OutputDebugStringA("    NuiStatus() S_OK; ");
                BSTR bs = pNuiSensor->NuiUniqueId();
                std::wstring ws(bs, SysStringLen(bs));
                Sensors->Insert(ref new Platform::String(ws.c_str()), ref new KSensor(pNuiSensor));
                hr = pNuiSensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_HIGH_QUALITY_COLOR);
                if (SUCCEEDED(hr))
                {
                    OutputDebugStringA("    NuiInitialize() SUCCEEDED; ");
                }
                if (FAILED(hr))
                {
                    OutputDebugStringA("    NuiInitialize() FAILED; ");
                }
                continue;
            }
        }
        OutputDebugStringA("\n}\n");
    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900