Getting the Kinect SDK to work with visual studio 2010 in c++
Asked Answered
R

3

6

I've been following the guide microsoft have made for setting up the Kinect SDK with c++. The steps they have created are as follows.

  1. Include windows.h in your source code.
  2. To use the NUI API, include MSR_NuiApi.h. Location: Program Files\Microsoft Research KinectSDK\inc
  3. To use the Kinect Audio API, include MSRKinectAudio.h. Location: Program Files\Microsoft Research KinectSDK\inc
  4. Link to MSRKinectNUI.lib. Location: Program Files\Microsoft Research KinectSDK\lib
  5. Ensure that the beta SDK DLLs are on your path when you run your project. Location: \Program Files\Microsoft Research KinectSDK

I believe I've done everything apart from step 5. Could anyone give me more details on what this means and how to do this?

thanks in advance, John

Rickyrico answered 20/10, 2011 at 18:18 Comment(0)
L
5

2.To use the NUI API, include MSR_NuiApi.h. Location: Program Files\Microsoft Research KinectSDK\inc

To do this, you probably want to add that path to your project

  • Right-click on your project, properties, VC++ directories
  • Add ;C:\Program Files\Microsoft Research KinectSDK\inc to the end of the include paths
  • Add ;C:\Program Files\Microsoft Research KinectSDK\lib to the end of the libraries paths

then add

#include <MSR_NuiApi.h>

to the includes at top of your source file. If you're using precompiled headers then you should put it below the stdafx.h include, or just add it to stdafx.h instead.

5.Ensure that the beta SDK DLLs are on your path when you run your project. Location: \Program Files\Microsoft Research KinectSDK

This means that your binary needs to be able to find these files at runtime.

The easiest way to do this is to add them to your system path; go to

  • start menu
  • right-click computer, properties
  • advanced system settings
  • environment variables
  • PATH, in your user or system settings - edit and append ; then the path given

You may then need to restart Visual Studio to pick this up, or it should be registered when you open a new command prompt.

Or, if you don't want to change the system settings, you can e.g. add it to an open command prompt with

PATH=%PATH%;C:\Program Files\Microsoft Research KinectSDK

or you can work out exactly which files there are necessary and copy them into the same directory as your binary, etc.

Lauter answered 20/10, 2011 at 18:45 Comment(9)
Ok so I've added the Kinect dll's to the path specified in the system settings. Now when I try and build my project I get a load of errors all from the kinect files that I've included. Most of the errors are IntelliSense errors. Is there something I've forgotten to add or download?Rickyrico
The path is purely for runtime, sorry - if you're getting compile errors then it'll be from one of the earlier steps. Have you added the other paths to your environment? I'll edit my answer.Lauter
You should also check that that's exactly the path that exists -if you're on a 64-bit PC it might be "C:\Program Files (x86)\" insteadLauter
Yea I've added all the other paths. Visual studio's not having any problem finding the files that I'm including, it's just not liking whats inside them. Yea the paths correct, copied it from the file explorer.Rickyrico
Ah, sorry, misread. What kind of errors? Missing types or classes? You might need to include some of the other files that define those types first I guess.Lauter
It's mostly syntax errors and undeclared identifiers. I've just found an existing project that works so I'll try and compare and see what I'm missing. Thanks for the help.Rickyrico
Thanks - in case someone else has the same problems you should write up what actually fixed it as your own answer, though, and accept that instead.Lauter
Yeah, the above solution doesn't work for me. Probably using a newer version of the SDK though. Still missing something besides the include and library files.Ventage
This solution is out of date, as of version 1.0 of the Kinect SDKCzarevitch
V
5

To implement a C++ application

  1. Include windows.h in your source code first. (This is important--you can't have WIN32_LEAN_AND_MEAN defined anywhere in your project or else you won't be able to compile NuiApi.h)

  2. Include <NuiApi.h> in your source code.

  3. Make sure you have an environment variable set up for your OS that reflects the SDK file path. The SDK installation should automatically do this for you. Example:

     KINECTSDK10_DIR = "C:\Program Files\Microsoft SDKs\Kinect\v1.0\"
    
  4. Go to your Visual Studio project settings under VC++ directories. Add $(KINECTSDK10_DIR)\inc to the include directories.

  5. Under the same VC++ directories area, include $(KINECTSDK10_DIR)\lib\x86 (for 32-bit apps) or $(KINECTSDK10_DIR)\lib\amd64 (for 64-bit apps) in your libraries directory.

Ventage answered 27/2, 2012 at 14:29 Comment(1)
This is the correct solution for version 1.0 of the Kinect SDK (current as of 2/28/12)Czarevitch
N
1

We are using the Kinect SDK version 1.0 and this is how the project is configured. Please note that the developer machine is Windows 7 x86. If you are using x64, please change the path accordingly.

Step 1. Copy header files and library. There is a reason to do this: the project can be checked out to any machine and compile just fine (the machine doesn't have to install the SDK). Another benefit: we upgraded the SDK to version 1.0 but because our project hasn't been updated and the deadline is coming, we had to built it with SDK version beta and everything went smoothly.

I suggest you create a new directory in your solution called "3rdparty/KinectSDK" (change it to suit your need).

Copy C:\Program Files\Microsoft SDKs\Kinect\v1.0\inc

Copy C:\Program Files\Microsoft SDKs\Kinect\v1.0\lib (you will have both x86 and x64 libraries)

Step 2. Configure the project. You will need to do this for each project that uses Kinect SDK! All configuration is happened in the Project Properties dialog.

C/C++ > General > add "$(SolutionDir)\3rdparty\KinectSDK\inc" to your Additional Include Directories

Linker > General > add "$(SolutionDir)\3rdparty\KinectSDK\lib\x86" to your Additional Library Directories (if you are configuring for x64, use the amd64 directory)

Linker > Input > add "Kinect10.lib" to Additional Dependencies

Step 3. Compile time!

Note:

  • If you install the SDK correctly, your machine will be able to run / debug the program without further configuration.
  • In order to run the program in client machine, you will need to copy the Kinect10.dll file. It's best to build a deploy project, the DLL will be detected automatically for you.
  • Talking about client machine, you don't need to install SDK for it. Just grab the driver files (.inf and stuff) and install the driver manually when you plug in the Kinect.

Good luck.

Nevski answered 1/3, 2012 at 5:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.