第一步:环境的搭建,比较简单,不做介绍(win8及以上、VS2013、Kinect V2)
第二步:新建空项目,然后我们将一个Demo中的stdafx.h中的内容拷贝过来
-
-
-
-
-
-
-
-
- #pragma once
-
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers //不包含Windows中很少使用的头文件
- #endif
-
-
- #include <windows.h>
-
- #include <Shlobj.h>
-
-
- #include <d2d1.h>
-
-
- #include <Kinect.h>
-
- #pragma comment (lib, "d2d1.lib")
-
- #ifdef _UNICODE
- #if defined _M_IX86
-
-
- #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #elif defined _M_X64
- #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #else
- #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #endif
- #endif
-
-
- template<class Interface>
- inline void SafeRelease(Interface *& pInterfaceToRelease)
- {
- if (pInterfaceToRelease != NULL)
- {
- pInterfaceToRelease->Release();
- pInterfaceToRelease = NULL;
- }
- }
如果此时不做任何操作,仅仅写一个主函数,会发现有错误无法打开包括文件“Kinect.h”
因为系统无法找到Kinect.h,所以此时需要对项目进行配置。
- 项目->属性->C/C++->常规->附加包含目录中添加$(KINECTSDK20_DIR)\inc;
- 链接器->常规->附加库目录中添加$(KINECTSDK20_DIR)\Lib\x86
- 链接器->输入->附加依赖项中添加kinect20.lib
此时编译运行,程序应该通得过!