none
native C++ Desktop App using WinRT: possible ? RRS feed

  • Question

  • Hello, i would like to use the nice, object oriented way of programming the Kinect v2 using WinRT under Windows 8.1 using Visual Studio 2015rc.

    I managed to set up a desktop project having a console and can print something to it using    

    Platform::Details::Console::WriteLine("Welcome to WinRT");

    but as soon as i call "KinectSensor^ sensor = KinectSensor::GetDefault();"

    i get the error message: "Platform::ClassNotRegisteredException"

    is it possible to use the Kinect v2 that way, or is it only possible to use WinRT and C++/CX it as an Windows8 app ?

    using namespace Windows::Globalization;
    using namespace Platform;
    using namespace WindowsPreview::Kinect;
    using namespace Windows::Foundation;
    using namespace Windows::Foundation::Collections;

    int main(Array<String^>^ args)
    {
        
    #ifdef __cplusplus_winrt
        // C++/CX specific code goes here...

        Platform::Details::Console::WriteLine("Welcome to WinRT");

        vector<int> v{ 1,2,3,4,5};
     
        // copy std::vector
        Array<int>^ arr = ref new Array<int>(&v[0], v.size());

        for (unsigned int i = 0;i < arr->Length;++i)
            cout << arr[i] << endl;

        KinectSensor^ sensor = KinectSensor::GetDefault();
        sensor->Open();
        auto reader = sensor->ColorFrameSource->OpenReader();

        while (1)
        {
            auto frame = reader->AcquireLatestFrame();
            if (frame != nullptr)
            {
                auto s = frame->RelativeTime.ToString();
                auto tmp =  s->Data();
                wcout << tmp << endl;
            }
        }

    #endif
      return 0;
    }

    Friday, May 22, 2015 9:24 AM

All replies

  • You can use the COM api's(see the D2D samples) in Desktop app. While there are ways of using the WinRT components in desktop applications Kinect v2 api's are not supported.

    Carmine Sirignano - MSFT

    Tuesday, May 26, 2015 4:55 PM
  • Carmine, thanks alot for your reply.

    I hope that maybe a new version of the Kinect v2 SDK might support WinRT for Desktop C++ Apps.

    The COM Interface feels like stone-age compared to the wonderful, object-oriented C# or WinRT Interfaces.

    for now, i will stick to Cinder++ with the CinderKCB2 block. But i dont really like the many layers that happen there: from the COM interface to the internally objectoriented Kinect common bridge that then puts out a C interface that then again is wrapped by the C++ interface of the CinderKCB2 Block. thats madness !

    If there only would the WinRT interface working for native desktop apps in the first place - that would be fantastic.

    by the way - what about supporting that amazing moderncpp project directly by microsoft ? No need for custom extensions to the C++ Language:

    http://moderncpp.com/windows-runtime/

    "The Modern C++ Library provides a Standard C++ language projection for the Windows Runtime. No need to use non-standard language extensions or cryptic ABI interfaces and functions. With Modern you get a power library for the Windows Runtime, whether you want the convenience of a class-based API or the ability to go under-the-hood for more control."

    supporting the modernc++ lib directly in visual studio would be absolutely amazing !

    please microsoft, make that happen ! http://moderncpp.com/licensing-and-sponsorship/

    Saturday, May 30, 2015 2:16 PM