首先下载SDK
可在https://developer.orbbec.com.cn/develop.html或https://orbbec3d.com/develop/下载Astra SDK和OpenNI SDK
我下载的是这两个:OpenNI-Linux-x64-2.3.0.65.rar 和 AstraSDK-v2.1.1-24f74b8b15-20200426T012326Z-Linux-aarch64.tar.gz
大致流程:
~/***$ ls
AstraSDK OpenNI.rar AstraSDK.tar.gz OpenNI
# 安装AstraSDK
~/***$ cd AstraSDK/
~/***/AstraSDK$ ls
bin include install java lib LICENSE.txt README.txt samples
~/***/AstraSDK$ cd install/
~/***/AstraSDK/install$ ls
install.sh orbbec-usb.rules
~/***/AstraSDK/install$ ./install.sh
Installer requires root, escalating via sudo.
[sudo] usr 的密码:
Linux installer script for Astra SDK
Installing rules for orbbec devices into /etc/udev/rules.d/
Done.
NOTES:
We suggest adding the following lines to your .bash_profile or .bashrc
export ASTRA_SDK_INCLUDE=/home/xsl/Disk2/WorkSpace/Code/Orbbec/AstraSDK/install/include
export ASTRA_SDK_LIB=/home/xsl/Disk2/WorkSpace/Code/Orbbec/AstraSDK/install/lib
~/***/AstraSDK/install$ sudo gedit ~/.bashrc
# 在.bashrc中添加上面的两个export,注意路径中的install,需要改正
export ASTRA_SDK_INCLUDE=/home/xsl/Disk2/WorkSpace/Code/Orbbec/AstraSDK/include
export ASTRA_SDK_LIB=/home/xsl/Disk2/WorkSpace/Code/Orbbec/AstraSDK/lib
# 保存,source刷新
~/***/AstraSDK/install$ source ~/.bashrc
~/***/AstraSDK/install$ cd ../../
# 安装OpenNI
~/***$ cd OpenNI/
~/***/OpenNI$ ls
CHANGES.txt Include install.sh LICENSE NOTICE OpenNIDevEnvironment orbbec-usb.rules README Redist ReleaseNotes.txt Samples Tools
~/***/OpenNI$ sudo ./install.sh
~/***/OpenNI$ source OpenNIDevEnvironment
# 测试SimpleViewer
~/***/OpenNI$ cd Samples/SimpleViewer
~/***/OpenNI/Samples/SimpleViewer$ make
g++ -MD -MP -MT "./Bin/Intermediate/x64-Release/SimpleViewer/Viewer.d Bin/Intermediate/x64-Release/SimpleViewer/Viewer.o" -c -msse3 -DUNIX -DGLX_GLXEXT_LEGACY -Wall -O2 -DNDEBUG -I../../Include -I../../ThirdParty/GL/ -I../Common -I/home/xsl/Disk2/WorkSpace/Code/Orbbec/OpenNI/Include -fPIC -fvisibility=hidden -Werror -o Bin/Intermediate/x64-Release/SimpleViewer/Viewer.o Viewer.cpp
g++ -MD -MP -MT "./Bin/Intermediate/x64-Release/SimpleViewer/main.d Bin/Intermediate/x64-Release/SimpleViewer/main.o" -c -msse3 -DUNIX -DGLX_GLXEXT_LEGACY -Wall -O2 -DNDEBUG -I../../Include -I../../ThirdParty/GL/ -I../Common -I/home/xsl/Disk2/WorkSpace/Code/Orbbec/OpenNI/Include -fPIC -fvisibility=hidden -Werror -o Bin/Intermediate/x64-Release/SimpleViewer/main.o main.cpp
cp -R /home/xsl/Disk2/WorkSpace/Code/Orbbec/OpenNI/Redist/* Bin/x64-Release
g++ -o Bin/x64-Release/SimpleViewer ./Bin/Intermediate/x64-Release/SimpleViewer/Viewer.o ./Bin/Intermediate/x64-Release/SimpleViewer/main.o -LBin/x64-Release -lglut -lGL -lOpenNI2 -Wl,-rpath ./
~/***/OpenNI/Samples/SimpleViewer$ cd Bin/x64-Release/
~/***/OpenNI/Samples/SimpleViewer/Bin/x64-Release$ ls
libDepthUtils.a libOpenNI2.so libSonixCamera.a OpenNI2 OpenNI.ini SimpleViewer
~/***/OpenNI/Samples/SimpleViewer/Bin/x64-Release$ ./SimpleViewer
OpenNI目录Tools下有个NiViewer,可以尝试运行下,在界面上右键鼠标或Shift+?,有很多功能。
编译的时候遇到下面的错误
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:34: error:
大致查了下,切换成低版本的编译器即可,之前我有写过这方面的博客:Ubuntu20.04终端安装、切换低版本gcc/g++