How to compile and run Kinect related samples

Recently, I bought Microsoft Kinect motion sensor, keen on starting developing cute applications with that. If you are in the same situation, this post is here for you to made thinks easier. Currently, I have managed to run some sample demos and compile them in Microsoft Visual Studio 2010. As it turned out, thinks are not that easy.

This post describes problems I needed to solve to make run Kinect examples. These examples are part of distribution of OpenNI and Nite libraries. As I am utter newbie in C++ and MS Visual Studio, please consider these as “work for me” and “may not be best” solutions. However I hope they may be helpful to someone. If you encounter these or different problems related to running the samples, please share with us your experience (and possibly solution) in the comments.

My environment is Windows Vista 32 bit SP1, Intel Core Duo 2GHz, JDK 1.6.0_03.

Content

Problems debugging OpenNI and Nite in MS Visual Studio

Note: The fix procedures described here are valid for Debug configuration profile, but they work as well for Release, just swap Debug in the instructions for Release.

Failed to save the updated manifest to the file

This is a build time error. It appeared, when I converted project to newer format and tried to built it. Oddly enough, this error disappears if you close MS Studio and reopen the project using *.sln file.

This is the full text of the error:

mt.exe : general error c101008a: Failed to save the updated manifest to the file "Debug\NiSimpleRead.exe.embed.manifest". The parameter is incorrect.

fatal error RC1015: cannot open include file ‘afxres.h’

This is a build time error. If this happens to you, it is related to difference between your development environment to those used in distribution, as suggested in this discussion. To fix it, replace afxres.h with windows.h in NITE.rc file.

The program PointViewer has exited with code 131076

This is happens if you try to run sample and have incorrectly set working directory. To fix it:

  • Right click  your project in Solution Explorer and choose Properties
  • Go to Configuration properties\Debugging\Working Directory and change $(ProjectDir) to ..\Bin\Debug
    Note: I have changed Intermediate Directory as well, but I am not sure, if it was necessary.

The system cannot find the file specified

This may happen if you run sample from Visual Studio, even if it runs all right from Windows Explorer. I believe this is caused by mess in output folders and project name settings, as they are distributed in Nite samples’ vcproj files. Project name is f.e. PointViewer, but output file is set to Sample-PointViewer. Also, the default build path is set to ..\Bin\Debug, but settings point to Debug folder. To fix this:

  • Right click  your project in Solution Explorer and choose Properties
  • Go to Configuration properties\Target Name and replace variable $(ProjectName) with Sample-PointViewer (for different samples it will be similar, f.e. Sample-SimpleRead)
  • Go to Configuration properties\General\OutputDirectory and change Debug\ to ..\Bin\Debug\

The program ‘[5540] Sample-StickFigure.exe: Native’ has exited with code 131076 (0×20004)

Alternative symptoms of this error is that if you run the application exe file from command line, following error appears:

InitFromXml failed: Device Protocol: Bad Parameter sent!

This is caused by Kinect not accepting resolution 320×240.  To solve it:

  • In all 3 XML files under directory Change Nite unstable 1.3.0.18\Data\ change <MapOutputMode xRes=”320″ yRes=”240″ FPS=”30″/> to <MapOutputMode xRes=”640″ yRes=”480″ FPS=”30″/>

Running OpenKinect.org samples

Download compiled library freenect.dll and freenect_sync.dll

I spent a lot of time getting FreenectTest.java to run. One of the steps required and described at OpenKinect getting started Windows page was to build freenect.dll. First I tried to download it somewhere, but only found that lot of people in the discussions are looking for it too. So I went through the compile process – here are steps I needed to do (to name a few):

  1. Install proper kinect drivers
  2. Install and use cmake.exe to generated MS Visual Studio project files
  3. Compile these files and generate freenect.dll

If you want to skip these steps, download my compiled version of freenect.dll and freenect_sync.dll. Hopefully it will work for you, I was compiling using MS Visual Studio 10 on Windows Vista.

Note: If using java wrapper as me, place it in the lib folder alongside libusb0_x86.dll and run with -Djava.library.path=lib, when I did so I was able to run OpenKinect-libfreenect-2ea3ebb\wrappers\java\src\test\java\org\openkinect\freenect\FreenectTest.java.

New release of windows libfreenect port addresses compilation issues (updated on 26/01/2011)

Since this post has  been published, Marcos Slomp and libfreenect team released new version of windows port, that adresses compilation issues I was facing. Fortunatelly, building your own version of libfreenect.dll on Windows should be easier. See readme.txt for Windows port.

Problems running CLNUI and CLUNI4J sample (new)

Unable to load library ‘CLNUIDevice.dll’

There can be multiple causes for this problem, like missing dll file in java.library.path. Even if you have library there, the error can still pop up. To fix this, I needed to following:

  • Fix wrong DLL identifier in CLUNI4J distribution
    On line 11 in CLNUI.java remove .dll from libraryFilename pointer and rebuild project.

        public static String libraryFilename = "CLNUIDevice";
  • Always start the project in Debug mode
    To be honest, I do not understand this one. However, when I run PointCloudApp using Run mode in my IntelliJ Idea, it fails with the UnsatisfiedLinkError. If I run it using Debug mode, it does not fails (however fails with Couldn’t start camera problem described later in this post).

Full error message is:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'CLNUIDevice.dll': The specified module could not be found.

    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:164)

 CLUNI4J – (KinectDevice)  Couldn’t start camera

This happens, when I try to run PointCloudApp. It happens at line 185 of cl.nui.KinectDevice class. Then follows this error:

Exception in thread "Animation Thread" java.lang.NullPointerException

    at cl.nui.KinectDevice.getDepthAt(KinectDevice.java:776)

Up till now, I was unfortunatelly unable to find reason for this error and this is the reason I am abondoning my experiments with CLUNI4J library. If you have any ideas I will be gratefull if you give me a hint in the comments section.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

14 Comments so far

  1. Wipeles on Únor 17th, 2011

    Thanks for this post. Very useful for OpenNI noobies.

  2. Jimi on Únor 18th, 2011

    Hey, thank you for sharing this. Absolutely awesome, you had the solutions to all of the problems I was having. (cannot open include afxres.h and exiting with code 131076). All working beautifully now on Windows 7

  3. Jety on Únor 23rd, 2011

    Hi guys, thanks for encouraging comments, glad to know that my post helped.

  4. James Davies on Únor 25th, 2011

    Thank you so much! “Go to Configuration properties\Debugging\Working Directory and change $(ProjectDir) to ..\Bin\Debug” was exactly what I needed! I owe you friend!

  5. Jety on Únor 25th, 2011

    Hi, James, my pleasure :)

  6. Anphase on Květen 27th, 2011

    You sir are a star. I was having trouble compiling those examples and I had given up. Awesome stuff. Cheers! :-)

  7. Krystof Litomisky on Srpen 25th, 2011

    Same thing as James. Took me a long time to get this damn thing to work. D?ky, brachu!

  8. Beto on Září 13th, 2011

    hey yo help one more guy here, thanks, if have any other doubt I hope you can help me, i’m very new in this, thanks again.

  9. alejandro on Listopad 22nd, 2011

    just thanks man!

  10. ign on Únor 9th, 2012

    what are the tools required to install in windows xp?

    pls give me the links to download those softwares,

    and also tell me the procedure to install, i am new to develop apps using kinect

  11. ign on Únor 9th, 2012

    hi any body pls help me

    what are the tools required to connect KINECT in windows xp environment?

    pls give me the links to download those softwares,

    and also tell me the procedure to install, i am new to develop apps using kinect

  12. Jety on Únor 9th, 2012

    Hi, Ign, I have never tried to install the Kinect on Windows XP myself, but there is a guide here: http://kinect.dashhacks.com/kinect-guides/2011/02/02/beginners-guide-setting-your-microsoft-kinect-windows-pc-hacking

  13. mop parowy on Květen 19th, 2014

    mop parowy…

    Jetyho blog ? How to compile and run Kinect related samples…

  14. social network marketing on Říjen 5th, 2014

    social network marketing…

    Jetyho blog ? How to compile and run Kinect related samples…