OpenNI 1.5 ::无法从文档中运行代码 [英] OpenNI 1.5::Could not run code from documentation

查看:130
本文介绍了OpenNI 1.5 ::无法从文档中运行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从OpenNI 1.5文档中运行示例代码.我已经导入了所需的库XnCppWrapper.h,以便可以使用C ++.该代码对特定变量"bshouldrun"只有一个错误.我知道它应该被声明为某些东西,但是由于我是新手,并且文档中的主要内容都不包含任何内容,因此我不知道将其声明为什么..请帮助!! 并预先感谢.

I am trying to run a sample code from the OpenNI 1.5 documentation.I have imported the library required XnCppWrapper.h so that I can use C++.The code has only one error on a particular variable "bshouldrun".I know that it should be declared as something but since I am new at this and the documentation does not contain anything above the main, I dont know what to declare it as..Please help!! And thanks in advance.

 #include <XnOpenNI.h>
 #include <XnCppWrapper.h>
 #include <stdio.h>

int main()
  {

    XnStatus nRetVal = XN_STATUS_OK;

    xn::Context context;

   // Initialize context object
   nRetVal = context.Init();
   // TODO: check error code

   // Create a DepthGenerator node
   xn::DepthGenerator depth;
   nRetVal = depth.Create(context);
   // TODO: check error code

   // Make it start generating data
   nRetVal = context.StartGeneratingAll();
   // TODO: check error code

   // Main loop
   while (bShouldRun) //<-----------------------------**ERROR;bShouldRun Undefined**
   {
       // Wait for new data to be available
       nRetVal = context.WaitOneUpdateAll(depth);
       if (nRetVal != XN_STATUS_OK)
      {
          printf("Failed updating data: %s\n", xnGetStatusString(nRetVal));
          continue;
      }

       // Take current depth map
       const XnDepthPixel* pDepthMap = depth.GetDepthMap();

       // TODO: process depth map
   }

   // Clean-up
   context.Shutdown();

   }

推荐答案

这是我在Windows(8)上运行Visual Studio 2010 Express的示例所要做的:

Here's what I did to run a sample from Visual Studio 2010 Express on Windows (8):

  1. 从C:\ Program Files(x86)\ OpenNI \ Samples \ NiSimpleViewer打开NiSimpleViewer.vcxproj VS2010项目
  2. 编辑OpenNI.rc以注释掉第10行上的#include "afxres.h"(可能不确定,因为我使用的是Express版本,不确定.您的计算机可能会编译得很好/不会抱怨缺少的头文件)
  3. 已启用工具>选项>调试>符号> Microsoft符号服务器(以解决过去丢失的pdb文件问题)
  4. (可选)将SAMPLE_XML_PATH编辑为"SamplesConfig.xml",而不是默认的"../../../Data/SamplesConfig.xml",否则,您需要通过浏览至.. \ Bin \ Debug \ NiSimpleViewer.exe来运行示例可执行文件,而不是使用Ctrl + F5.答;因此将SamplesConfig.xml文件复制到示例文件夹中,如下所示
  1. Opened the NiSimpleViewer.vcxproj VS2010 project from C:\Program Files (x86)\OpenNI\Samples\NiSimpleViewer
  2. Edited OpenNI.rc to comment out #include "afxres.h" on line 10(might be missing this because I'm using Express version, not sure. Your machine might compile this fine/not complain about the missing header file)
  3. Enabled Tools > Options > Debugging > Symbols > Microsoft Symbol Servers (to get past missing pdb files issue)
  4. Optionally edit the SAMPLE_XML_PATH to "SamplesConfig.xml" rather than the default "../../../Data/SamplesConfig.xml", otherwise you need to run the sample executable from ..\Bin\Debug\NiSimpleViewer.exe by navigating to there rather than using the Ctrl+F5. A;so copy the SamplesConfig.xml file into your sample folder as you can see bellow

以下是一些说明上述步骤的图片:

Here are a few images to illustrate some of the above steps:

您还可以编译NiHandTracker示例,听起来更接近您的需求. 因此,这解释了OpenNI 1.5的设置,这是您的问题所在.

You can also compile the NiHandTracker sample, which sounds closer to what you need. So this explains the setup for OpenNI 1.5 which is what your question is about.

我在评论中注意到了您的OpenNI 2 lib问题.可以通过项目属性(右键单击项目->选择属性)>链接器>输入>其他依赖项>编辑来链接到SimpleHandTracker.lib. 我在这台机器上没有安装OpenNI2,但是假设SimpleHandTracker.lib位于OpenNI_INSTALL_FOLDER \ Lib中.如果我可能写错了,请尝试搜索文件.

I've noticed your OpenNI 2 lib issue in the comments. It should be a matter of linking against SimpleHandTracker.lib which you can do via Project Properties (right-click project->select Properties) > Linker > Input > Additional Dependencies > Edit. I don't have OpenNI2 setup on this machine, but assuming SimpleHandTracker.lib would be in OpenNI_INSTALL_FOLDER\Lib. Try a file search in case I might be wrong.

这篇关于OpenNI 1.5 ::无法从文档中运行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆