`
小斤陈
  • 浏览: 32916 次
社区版块
存档分类
最新评论

Kinect开发教程七:OpenNI2自带范例程序的编译执行

阅读更多

 

小斤觉得,研究自带的范例程序是学习的重要途径之一,在编译与配置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中发现

    //---------------------------------------------------------------------------  
    // 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未定义造成,加入定义后编译成功。

    #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启动,则拷贝到程序执行目录)
      否则将会看到以下错误:
 

----------------------------------

作者:小斤(陈忻)

新浪围脖:@小斤陈

本文属于原创文章,如需转载引用请注明原文作者和链接,谢谢。

0
0
分享到:
评论
1 楼 Tophuhu 2013-02-16  
这个系列的图全挂了,请检查一下

相关推荐

Global site tag (gtag.js) - Google Analytics