How to Use - JohnMcCaffery/NuiLib GitHub Wiki

<NuiLib dir> specifies the directory where NuiLib is installed to. It includes the sub directories "Include" and "Src" and has the solution, prebuild and makefile files in it.
<flags> can be _d, _v, _dv or nothing. _d specifies debug, _v specifies visual. Visual mode means that, if the depth stream is enabled, the depth frames will be output, overlaid with debug information such as the position of joints and how the fist finder algorithm is operating.

Downloading: Grab the project from github. If you have git installed clone it with git clone git://github.com/JohnMcCaffery/NuiLib.git.

Setting Up: Currently NuiLib only supports the Microsoft Kinect SDK. This will hopefully change soon. To work with NuiLib the first thing you have to do is install the microsoft SDK. This project also relies upon OpenCV. To work you will need OpenCV to be present on your computer. Before attempting to compile NuiLib or any project that links to NuiLib you will need to download and install OpenCV which can be downloaded here. Once installed you need to copy the relevant libraries to your Bin/ directory. If you want to use the pre-setup build tools such as the makefile and Visual Studio projects you also need to set up a global environment variable called "OPENCV_DIR" which points to the OpenCV installation. To do both these things automatically run run prebuild.bat (Visual Studio) or prebuild.sh (MingW).

How to Build: Visual Studio 10

  1. Open NuiLib.sln
  2. Select a profile
  3. Build all (F6)
    Libraries compile to "NuiLib<flags>.lib" and "NuiLib-Kinect-MS<flags>.lib" in Lib/x86/vc10/.

MingW + make + G++

  1. Run the make target "DLL". Library compiles to "NuiLib.dll" in Lib/. "libNuiLib.dll.a" is also compiled to the same folder for linking. "NuiLib.dll" is copied to Bin/.

How to Include: Add /Include/ to the include path. VS-10: <NuiLib dir>Project->Properties->VC++ Directories->Include Directories. G++: -I <NuiLib dir>/Include/ #include <NuiLib-API.h> at the top of any relevant source. This will give access to everything documented here.

How to Link: Visual Studio 10 Add the following to the library path (Project->Properties->VC++ Directories->Library Directories):
<NuiLib dir>\Lib\x86\vc10\
$(OPENCV_DIR)build\x86\vc10\lib\
$(KINECTSDK10_DIR)lib\x86

Add the following to the linker's additional dependencies (Project->Properties->Linker->Input->Additional Dependencies):
NuiLib-VC10<flags>.lib
NuiLib-Kinect-MS-VC10<flags>.lib
opencv_core241[d].lib
opencv_highgui241[d].lib
opencv_imgproc241[d].lib
opencv_objdetect241[d].lib
kinect10.lib

G++ Add the following to the library path (-L flag for each folder):
<NuiLib dir>/Lib/x86/mingw/
$(OPENCV_DIR)build/x86/mingw/lib/
$(KINECTSDK10_DIR)lib/x86/

Add the following to the linker's inputs (-l flag for each file):
NuiLib.dll
opencv_core241.dll
opencv_highgui241.dll
opencv_imgproc241.dll
opencv_objdetect241.dll
Kinect10.lib

How to Add Components:
Add /Include/ to the include path.
VS-10: <NuiLib dir>Project->Properties->VC++ Directories->Include Directories.
G++: -I <NuiLib dir>/Include/
#include <NuiLib-Extendable.h> at the top of any relevant source. This will give access to everything documented here. Specifically IComponent, IScalar, IVector and ICondition. To be compatible new components must extend from IScalar, IVector or ICondition (or one of their pre-existing abstract sub-classes such as VectorWrappingScalar. These are found in 'NuiLib-Vectors.h', 'NuiLib-Conditions.h' or 'NuiLib-Scalars.h'). Generally all that is necessary is to implement a new component is to declare the class and one or more factory functions. The class must have a 0 argument constructor. It must also override the 'CalculateValue' function and implement 'static string GetName()' function. It may also need to provide mechanisms for setting any fields it needs to work with. If it has generic behaviour such as wrapping a Vector a pre-existing abstract super class may exist that does this for you. The factory functions should return a Scalar, Vector or Condition with the _p field assigned to a new instance of the class that has been fully initialized.

How to Add Support for new Devices/Drivers:
Add /Include/ to the include path.
VS-10: <NuiLib dir>Project->Properties->VC++ Directories->Include Directories.
G++: -I <NuiLib dir>/Include/
#include <NuiLib-Extendable.h> at the top of any relevant source. This will give access to everything documented here. Specifically INuiFactoryExtension. The main implementation is done via a factory class which extends INuiFactoryExtension. This should take care of polling the device and updating any components which need to be updated. As well as extending the INuiFactoryExtension class the following functions must be implemented:
INuiFactory()
INuiFactoryExtension()
joint(int)
The first two should return a pointer to a singleton instance of the new factory class. The last should return a Vector that will contain the coordinates of a skeleton joint.

More Info Prebuild: Prebuild does 3 things. Firstly it creates a global environment variable $(OPENCV_DIR) and asks the user to enter a value for it. This value should point to the main directory where Open CV has been installed and built. This variable will be used in the Visual Studio projects and the makefile to resolve dependencies. Secondly the prebuild creates a Bin/ directory. Thirdly it copies all the required libraries from the Open CV installation and the Microsoft Kinect SDK installation into Bin/.

Notes This project has only been tested on Windows 7 using Visual Studio 10 and MingW.

⚠️ **GitHub.com Fallback** ⚠️