Kinect开发教程七:OpenNI2自带范例程序的编译执行
2014-10-27 16:54
239 查看
研究自带的范例程序是学习的重要途径之一,在编译与配置OpenNI2的范例程序时,并没有安装时候那么顺利,在这里分享一下经验。
安装版本OpenNI 2.1 beta,开发环境VS2008。
依照上一篇教程六安装成功后,会有以下目录:
范例程序主目录:
OpenNI2\Samples\
可执行文件:
OpenNI2\Samples\Bin
公共头文件:
OpenNI2\Samples\Common
GL库:
OpenNI2\Samples\GL
如果有VS2010应该能直接打开项目。
新建VS范例工程
在较早的VS版本运行,可以参考以下步骤来新建一个范例工程:
【1】新建C/C++工程
【2】配置工程属性(参考教程六)
【3】拷贝源代码,这里小斤拷贝了SimpleViewer的源码到工程目录。
【4】拷贝公共头文件:\OpenNI2\Samples\Common\OniSampleUtilities.h到工程目录。
如下图
GLUT库
【1】对于OpenNI2\Samples\GL目录下的头文件目录gl与glh
复制到以下文件夹:
Visual Studio 6:X:\Program Files\Microsoft Visual Studio\VC98\Include\GL
Visual Studio .net 2003:X:\Program Files\Microsoft Visual Studio NET 2003\Vc7\PlatformSDK\Include\gl
Visual Studio 2005:X:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\gl
Visual Studio 2008:X:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl
【2】对于OpenNI2\Samples\GL目录下的*.lib复制到以下文件夹:
Visual Studio 6:X:\Program Files\Microsoft Visual Studio\VC98\Lib
Visual Studio .net 2003:X:\Program Files\Microsoft Visual Studio NET 2003\Vc7\PlatformSDK\Lib
Visual Studio 2005:X:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib
Visual Studio 2008:X:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
【3】OpenNI2\Samples\GL目录下的*.dll复制到工程目录或者C:\Windows\system中。
一些小坑
【1】在小斤的工作环境VS2008中,遇到编译错误:
error C2146: syntax error : missing ';' before identifier 'usbVendorId'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2146: syntax error : missing ';' before identifier 'usbProductId'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
在OpenNI2\Include\Win32\OniPlatformWin32.h中发现
[cpp] view
plaincopy
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <io.h>
#include <time.h>
#include <assert.h>
#include <float.h>
#include <crtdbg.h>
#if _MSC_VER < 1600 // Visual Studio 2008 and older doesn't have stdint.h...
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
该错误由于uint32_t与uint8_t未定义造成,加入定义后编译成功。
[cpp] view
plaincopy
#if _MSC_VER < 1600 // Visual Studio 2008 and older doesn't have stdint.h...
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int8 uint8_t;
#else
#include <stdint.h>
#endif
【2】在上一篇教程中,小斤也说过,要拷贝\OpenNI2\Redist目录下的所有文件到VS的工作目录(如果不通过VS启动,则拷贝到程序执行目录)
否则将会看到以下错误:
安装版本OpenNI 2.1 beta,开发环境VS2008。
依照上一篇教程六安装成功后,会有以下目录:
范例程序主目录:
OpenNI2\Samples\
可执行文件:
OpenNI2\Samples\Bin
公共头文件:
OpenNI2\Samples\Common
GL库:
OpenNI2\Samples\GL
如果有VS2010应该能直接打开项目。
新建VS范例工程
在较早的VS版本运行,可以参考以下步骤来新建一个范例工程:
【1】新建C/C++工程
【2】配置工程属性(参考教程六)
【3】拷贝源代码,这里小斤拷贝了SimpleViewer的源码到工程目录。
【4】拷贝公共头文件:\OpenNI2\Samples\Common\OniSampleUtilities.h到工程目录。
如下图
GLUT库
【1】对于OpenNI2\Samples\GL目录下的头文件目录gl与glh
复制到以下文件夹:
Visual Studio 6:X:\Program Files\Microsoft Visual Studio\VC98\Include\GL
Visual Studio .net 2003:X:\Program Files\Microsoft Visual Studio NET 2003\Vc7\PlatformSDK\Include\gl
Visual Studio 2005:X:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\gl
Visual Studio 2008:X:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl
【2】对于OpenNI2\Samples\GL目录下的*.lib复制到以下文件夹:
Visual Studio 6:X:\Program Files\Microsoft Visual Studio\VC98\Lib
Visual Studio .net 2003:X:\Program Files\Microsoft Visual Studio NET 2003\Vc7\PlatformSDK\Lib
Visual Studio 2005:X:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib
Visual Studio 2008:X:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
【3】OpenNI2\Samples\GL目录下的*.dll复制到工程目录或者C:\Windows\system中。
一些小坑
【1】在小斤的工作环境VS2008中,遇到编译错误:
error C2146: syntax error : missing ';' before identifier 'usbVendorId'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2146: syntax error : missing ';' before identifier 'usbProductId'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
在OpenNI2\Include\Win32\OniPlatformWin32.h中发现
[cpp] view
plaincopy
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <io.h>
#include <time.h>
#include <assert.h>
#include <float.h>
#include <crtdbg.h>
#if _MSC_VER < 1600 // Visual Studio 2008 and older doesn't have stdint.h...
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
该错误由于uint32_t与uint8_t未定义造成,加入定义后编译成功。
[cpp] view
plaincopy
#if _MSC_VER < 1600 // Visual Studio 2008 and older doesn't have stdint.h...
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int8 uint8_t;
#else
#include <stdint.h>
#endif
【2】在上一篇教程中,小斤也说过,要拷贝\OpenNI2\Redist目录下的所有文件到VS的工作目录(如果不通过VS启动,则拷贝到程序执行目录)
否则将会看到以下错误:
相关文章推荐
- Kinect开发教程七:OpenNI2自带范例程序的编译执行
- Kinect开发教程三:利用OpenNI进行手势识别
- Kinect开发教程一:OpenNI的安装与开发环境配置
- Heresy透過 OpneNI 讀取 Kinect 深度影像資料(Kinect开发教程二:OpenNI读取深度图像与彩色图像并显示)
- Kinect开发教程二:OpenNI读取深度图像与彩色图像并显示
- [学习笔记]java基础Java8SE开发环境搭建、第一个Java Hello World、Java程序的编译与执行
- Android 开发手记二 C可执行程序编译实例(转帖)
- Android 开发手记二 C可执行程序编译实例(转帖)
- Heresy透過 OpneNI 合併 Kinect 深度以及彩色影像資料(Kinect开发教程二:OpenNI读取深度图像与彩色图像并显示)
- android开发教程之间隔执行程序(android计时器)
- Kinect开发教程一:OpenNI的安装与开发环境配置
- [转载]Kinect开发教程五:OpenNI获取人体骨架
- Lazarus开发平台编译后的可执行程序的减肥方法
- ANDROID NDK实践开发系列--(01) 使用ndk编译c可执行程序
- [学习笔记]java基础Java8SE开发环境搭建、第一个Java Hello World、Java程序的编译与执行
- Kinect开发教程一:OpenNI的安装与开发环境配置
- Android 开发手记二 C可执行程序编译实例
- Kinect开发教程八:OpenNI2显示深度、彩色及融合图像
- Kinect开发教程三:利用OpenNI进行手势识别
- [学习笔记]java基础Java8SE开发环境搭建、第一个Java Hello World、Java程序的编译与执行