简介
安装驱动与OpenNI2
http://www.microsoft.com/en-us/kinectforwindows/develop/overview.aspx。
详见
http://blog.csdn.net/chenxin_130/article/details/8580636
VS开发环境
VS开发环境的配置与OpenNI1.X类似,还是配置include与library。
小斤安装的是32位OpenNI2,安装目录位C:\OpenNI2\,在OpenNI2安装完毕后,安装程序自动添加了以下环境变量:(注意,安装64位的话,变量名带有64后缀,配置也相应需要变化)
OPENNI2_INCLUDE=C:\OpenNI2\Include\
OPENNI2_LIB=C:\OpenNI2\Lib\
OPENNI2_REDIST=C:\OpenNI2\Redist\
新建VS C++项目后,右击进入项目属性,进行以下配置:
【1】Configuration Properties,C/C++,Gerenal,在Additiaonal Include Directories项中添加$(OPENNI2_INCLUDE)。
【2】Configuration Properties,Linker,Gerenal,在Additiaonal Library Directories项中添加$(OPENNI2_LIB)。
【3】Configuration Properties,Linker,Input,在Additiaonal Dependencies项中添加$(OPENNI2_LIB)。
最后需要注意的是,大家还需要拷贝\OpenNI2\Redist目录下的所有文件到VS的工作目录(如果不通过VS启动,则拷贝到程序执行目录)才可以正确运行,其中包含了OpenNI2启动所需的动态链接库等内容,详见以下解释(Copied From OpenNI Document):
Copy all the files from OpenNI's redist directory (see environment variable "$(OPENNI2_REDIST)" or "$(OPENNI2_REDIST64)") to your working directory. (The defaults are C:\Program Files\OpenNI2\Redist or C:\Program Files (x86)\OpenNI2\Redist). Be aware that when you run from command line, the working directory is the directory where the executable can be found, and where you run from Visual Studio the default directory is where the project file (.vcproj, .vcxproj) can be found.