gpt4 book ai didi

c++ - 在 Ubuntu Linux 上使用 Kinect 编程

转载 作者:太空狗 更新时间:2023-10-29 12:14:50 25 4
gpt4 key购买 nike

第一次在这里提问,所以如果我不完全连贯,请多多包涵。

我一直在尝试学习如何使用 OpenNI、libfreenect 和 SensorKinect 库来为 kinect 创建一些代码。但是,我遇到的问题是我似乎无法正确设置 kinect,因此我可能无法实际测试代码并了解一切是如何工作的。最棘手的问题是当我尝试编译时收到大量 undefined reference 错误并且编译器退出。

/tmp/ccnXAyOZ.o: In function `main':
KinectDraw.cpp:(.text+0x9a): undefined reference to `xnEnumerationErrorsAllocate'
KinectDraw.cpp:(.text+0xb6): undefined reference to `xnGetStatusString'
KinectDraw.cpp:(.text+0xfa): undefined reference to `xnInitFromXmlFileEx'
KinectDraw.cpp:(.text+0x12a): undefined reference to `xnEnumerationErrorsToString'
KinectDraw.cpp:(.text+0x148): undefined reference to `xnEnumerationErrorsFree'
KinectDraw.cpp:(.text+0x169): undefined reference to `xnGetStatusString'
KinectDraw.cpp:(.text+0x18a): undefined reference to `xnEnumerationErrorsFree'
KinectDraw.cpp:(.text+0x1a4): undefined reference to `xnEnumerationErrorsFree'
KinectDraw.cpp:(.text+0x1bf): undefined reference to `xnFindExistingRefNodeByType'
KinectDraw.cpp:(.text+0x1db): undefined reference to `xnGetStatusString'
KinectDraw.cpp:(.text+0x202): undefined reference to `xnAllocateDepthMetaData'
KinectDraw.cpp:(.text+0x227): undefined reference to `xnWaitOneUpdateAll'
KinectDraw.cpp:(.text+0x243): undefined reference to `xnGetStatusString'
KinectDraw.cpp:(.text+0x273): undefined reference to `xnGetDepthMetaData'
KinectDraw.cpp:(.text+0x2fe): undefined reference to `xnOSWasKeyboardHit'
KinectDraw.cpp:(.text+0x31a): undefined reference to `xnFreeDepthMetaData'
KinectDraw.cpp:(.text+0x329): undefined reference to `xnProductionNodeRelease'
KinectDraw.cpp:(.text+0x338): undefined reference to `xnProductionNodeRelease'
KinectDraw.cpp:(.text+0x347): undefined reference to `xnContextRelease'
/tmp/ccnXAyOZ.o: In function `xn::NodeWrapper::SetHandle(XnInternalNodeData*)':
KinectDraw.cpp:(.text._ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData[_ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData]+0x39): undefined reference to `xnGetRefContextFromNodeHandle'
KinectDraw.cpp:(.text._ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData[_ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData]+0x54): undefined reference to `xnContextUnregisterFromShutdown'
KinectDraw.cpp:(.text._ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData[_ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData]+0x60): undefined reference to `xnContextRelease'
KinectDraw.cpp:(.text._ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData[_ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData]+0x6f): undefined reference to `xnProductionNodeRelease'
KinectDraw.cpp:(.text._ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData[_ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData]+0x82): undefined reference to `xnProductionNodeAddRef'
KinectDraw.cpp:(.text._ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData[_ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData]+0x91): undefined reference to `xnGetRefContextFromNodeHandle'
KinectDraw.cpp:(.text._ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData[_ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData]+0xb2): undefined reference to `xnContextRegisterForShutdown'
KinectDraw.cpp:(.text._ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData[_ZN2xn11NodeWrapper9SetHandleEP18XnInternalNodeData]+0xc1): undefined reference to `xnContextRelease'
collect2: error: ld returned 1 exit status

收到错误的命令是g++ KinectDraw.cpp -I/usr/include/ni -I ~/KinectLibs/OpenNI/Include。我用过https://www.kdab.com/setting-up-kinect-for-programming-in-linux-part-1/设置kinect。如果有人对我的问题有任何见解,或者只是一个开始阅读以弄清楚问题的好地方,我将不胜感激。感谢您的宝贵时间和协助!

更新:感谢 lxrec 的评论,我相当确定她/他和我最初的假设是正确的,因为我没有正确链接库。我还没有找到任何关于 Linux 代码实现的文档,其中包括编译中使用的目录,所以如果有人对此有深入的了解,我将不胜感激。

更新:所以我还没有解决这个问题(我不知道如何编译代码),但是我认为我安装的 OpenNI 或 libfreenect 是错误的我已经重新安装了它们。然而,这并没有解决我的问题。感谢任何可以提供见解的人!

更新:下面是我在编译时遇到问题的代码。我什至还没有尝试向其中添加任何东西......

#include <XnCppWrapper.h>
#include <XnStatusCodes.h>
#include <XnOS.h>
#include <math.h>
#include <XnOpenNI.h>
#include <iostream>

using namespace xn;
using namespace std;

int main()
{
cout<<"This is a test\n";
return 0;
}

最佳答案

OpenNI 源代码应在其 lib 目录 ($SOURCE_DIR/Platform/Linux/Redist/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10- $YOUR_VERSION/lib).所有这些文件(对我来说有 5 个文件:libnimCodecs.so、libnimMockNodes.so、libnimRecorder.solibOpenNI.jni.solibOpenNI.so) 在运行 install.sh 后被复制到/usr/lib(请遵循 OpenNI 构建/安装说明)

您的示例代码需要一个 -lOpenNI 参数来完成编译过程。所以你应该像这样编译你的代码:g++ your_code.cpp -I/usr/include/ni -lOpenNI

这可能已经是一个老问题了,希望你的问题已经解决了,这个答案可以在下次帮助别人。

关于c++ - 在 Ubuntu Linux 上使用 Kinect 编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29461147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com