Qt creator and Kinect SDK



  • Hi,

    I'm trying to use the Kinect SDK with Qt creator. I use Qt creator 2.4.1 based on Qt 4.7.4 (32bits). I don't have installed Visual Studio. I use Kinect SDK 1.6.

    I have correctly add the library of kinect in C:\Program Files\Microsoft SDKs\Kinect\v1.6\lib\x86\Kinect10.lib
    and include the headers files situated in C:\Program Files\Microsoft SDKs\Kinect\v1.6\inc\ in my project.

    My .pro file look like this :
    @TEMPLATE = app
    CONFIG += console
    CONFIG -= qt

    SOURCES += main.cpp

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/C:/Program Files/Microsoft SDKs/Kinect/v1.6/lib/x86/ -lKinect10
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/C:/Program Files/Microsoft SDKs/Kinect/v1.6/lib/x86/ -lKinect10d

    INCLUDEPATH += $$PWD/C:/Program Files/Microsoft SDKs/Kinect/v1.6/lib/x86
    DEPENDPATH += $$PWD/C:/Program Files/Microsoft SDKs/Kinect/v1.6/lib/x86

    HEADERS +=
    C:/Program Files/Microsoft SDKs/Kinect/v1.6/inc/NuiSkeleton.h
    C:/Program Files/Microsoft SDKs/Kinect/v1.6/inc/NuiSensor.h
    C:/Program Files/Microsoft SDKs/Kinect/v1.6/inc/NuiImageCamera.h
    C:/Program Files/Microsoft SDKs/Kinect/v1.6/inc/NuiApi.h
    @

    But when i make #include <NuiApi.h> or #include "NuiApi.h" i have an error kind file or directory not found.

    For testing i have copy all headers file in my header's project directory. My #include is now Ok but i have many error of compilation look like this :
    @In file included from ..\TestKinect\main.cpp:2:
    ..\TestKinect/NuiApi.h:77: warning: identifier 'static_assert' will become a keyword in C++0x
    In file included from ..\TestKinect/NuiApi.h:109,
    from ..\TestKinect\main.cpp:2:
    ..\TestKinect/NuiSensor.h:19: warning: ignoring #pragma warning
    In file included from ..\TestKinect/NuiApi.h:109,
    from ..\TestKinect\main.cpp:2:
    ..\TestKinect/NuiSensor.h:128:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:151:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:200:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:214:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:226:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:237:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:247:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:257:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:269:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:278:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:288:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:298:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:313:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:330:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:339:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:350:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:368:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:369:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:380:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:389:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:416:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiSensor.h:425:8: warning: extra tokens at end of #endif directive
    In file included from ..\TestKinect\main.cpp:2:
    ..\TestKinect/NuiApi.h:110:8: warning: extra tokens at end of #endif directive
    In file included from ..\TestKinect/NuiApi.h:112,
    from ..\TestKinect\main.cpp:2:
    ..\TestKinect/NuiImageCamera.h:168:8: warning: extra tokens at end of #endif directive
    ..\TestKinect/NuiImageCamera.h:255:8: warning: extra tokens at end of #endif directive
    In file included from ..\TestKinect\main.cpp:2:
    ..\TestKinect/NuiApi.h:116:8: warning: extra tokens at end of #endif directive
    In file included from ..\TestKinect\main.cpp:2:
    ..\TestKinect/NuiApi.h:46: error: expected constructor, destructor, or type conversion before 'WINAPI'
    ..\TestKinect/NuiApi.h:53: error: expected constructor, destructor, or type conversion before 'WINAPI'
    ..\TestKinect/NuiApi.h:77: error: expected constructor, destructor, or type conversion before '(' token@

    What's wrong ? Librery forget ? my link ?



  • I think that problem is with paths in which you have a white spaces. Setup INCLUDEPATH, LIBS etc. with a qmake function "quote":http://doc.qt.digia.com/qt/qmake-function-reference.html#quote-string



  • Thinks for your reply. It's that, with the quote i no longer error this include.
    But the compiler error is always. (second code listed)



  • Can you paste here a NuiApi.h?



  • Yes but is a little long. This is not a header that I created but a header from kinect SDK.

    @/************************************************************************

    •                                                                   *
      
    • NuiApi.h -- This module aggregates all the Natural User *
    •           Interface(NUI) API headers.                             *
      
    •                                                                   *
      
    • Copyright (c) Microsoft Corp. All rights reserved. *
    •                                                                   *
      

    ************************************************************************/

    #pragma once

    #ifndef NUIAPI
    #define NUIAPI __declspec( dllimport ) WINAPI
    #endif

    #include <pshpack8.h>

    #ifdef __cplusplus
    extern "C" {
    #endif

    //
    // NUI Common Initialization Declarations
    //

    #define NUI_INITIALIZE_FLAG_USES_AUDIO 0x10000000
    #define NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX 0x00000001
    #define NUI_INITIALIZE_FLAG_USES_COLOR 0x00000002
    #define NUI_INITIALIZE_FLAG_USES_SKELETON 0x00000008
    #define NUI_INITIALIZE_FLAG_USES_DEPTH 0x00000020
    #define NUI_INITIALIZE_FLAG_USES_HIGH_QUALITY_COLOR 0x00000040 // implies COLOR stream will be from uncompressed YUY2 at 15fps

    #define NUI_INITIALIZE_DEFAULT_HARDWARE_THREAD 0xFFFFFFFF

    /// <summary>
    /// Initializes the sensor. If the sensor is already initialized, this will shut down the sensor
    /// and reinitialize it.
    /// </summary>
    /// <param name="dwFlags">
    /// The NUI subsystems to initialize, as a bitwise-OR combination of the NUI_INITIALIZE constants.
    /// </param>
    /// <returns>
    /// <para>Returns S_OK if successful; otherwise, returns a failure code.</para>
    /// </returns>
    HRESULT NUIAPI NuiInitialize(
    In DWORD dwFlags
    );

    /// <summary>
    /// Shuts down the sensor. If the sensor is already shut down, nothing happens.
    /// </summary>
    VOID NUIAPI NuiShutdown(
    );

    //
    // Define NUI specific error codes
    // **** ALSO DEFINED IN NuiError.h. Keep in sync! ****
    //

    #ifndef _NUI_HRESULTS
    #define _NUI_HRESULTS

    //
    // Define NUI error codes derived from win32 errors
    //

    #define E_NUI_DEVICE_NOT_CONNECTED __HRESULT_FROM_WIN32(ERROR_DEVICE_NOT_CONNECTED)
    #define E_NUI_DEVICE_NOT_READY __HRESULT_FROM_WIN32(ERROR_NOT_READY)
    #define E_NUI_ALREADY_INITIALIZED __HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED)
    #define E_NUI_NO_MORE_ITEMS __HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS)

    #define FACILITY_NUI 0x301
    #define S_NUI_INITIALIZING MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NUI, 1) // 0x03010001
    #define E_NUI_FRAME_NO_DATA MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 1)
    static_assert(E_NUI_FRAME_NO_DATA == 0x83010001, "Error code has changed.");
    #define E_NUI_STREAM_NOT_ENABLED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 2)
    #define E_NUI_IMAGE_STREAM_IN_USE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 3)
    #define E_NUI_FRAME_LIMIT_EXCEEDED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 4)
    #define E_NUI_FEATURE_NOT_INITIALIZED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 5)
    #define E_NUI_NOTGENUINE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 6)
    #define E_NUI_INSUFFICIENTBANDWIDTH MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 7)
    #define E_NUI_NOTSUPPORTED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 8)
    #define E_NUI_DEVICE_IN_USE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 9)

    #define E_NUI_DATABASE_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 13)
    #define E_NUI_DATABASE_VERSION_MISMATCH MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 14)
    // The requested feateure is not available on this version of the hardware
    #define E_NUI_HARDWARE_FEATURE_UNAVAILABLE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, 15) // 0x8301000F
    // The hub is no longer connected to the machine
    #define E_NUI_NOTCONNECTED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, /* 20 / ERROR_BAD_UNIT) // 0x83010014
    // Some part of the device is not connected.
    #define E_NUI_NOTREADY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, /
    21 / ERROR_NOT_READY) // 0x83010015
    // Skeletal engine is already in use
    #define E_NUI_SKELETAL_ENGINE_BUSY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, /
    170 / ERROR_BUSY)
    // The hub and motor are connected, but the camera is not
    #define E_NUI_NOTPOWERED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, /
    639 / ERROR_INSUFFICIENT_POWER) // 0x8301027F
    // Bad index passed in to NuiCreateInstanceByXXX
    #define E_NUI_BADINDEX MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NUI, /
    1413 */ ERROR_INVALID_INDEX) // 0x83010585
    #define E_NUI_BADIINDEX E_NUI_BADINDEX // V 1.0 compatibility
    #endif

    #ifdef __cplusplus
    } // end extern "C"
    #endif

    #ifndef No__NuiSensor_h
    #include <NuiSensor.h>
    #endif No__NuiSensor_h

    #include <NuiImageCamera.h>

    #ifndef No__NuiSkeleton_h
    #include <NuiSkeleton.h>
    #endif No__NuiSkeleton_h

    #include <poppack.h>

    @

    apparently the first error line is : exepted constructor, destructor or type conversion befor 'WINAPI'
    and the header line is :

    @HRESULT NUIAPI NuiInitialize(
    In DWORD dwFlags
    );@



  • Are you sure that NuiApi.h should be in HEADERS? Maybe this header should be only in INCLUDEPATH, not in HEADERS.



  • I tried both methods and the same error appears. I think i forgot something. I have inclue the path of MicrosoftKinect.dll but always the same.

    I would like work with C++ and Qt for my kinect project. If it's not work, i'll going to buy a Xbox kinect and work with a library compatible with Qt and C + + as OpenKinect or OpenNi.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.