ubuntu16.04 使用kinectv2跑Elasticfusion

时间:2023-03-09 05:41:18
ubuntu16.04 使用kinectv2跑Elasticfusion

1.安装openni2

参考:https://blog.****.net/D206_hero/article/details/78985859?utm_source=blogxgwz3

 sudo apt-add-repository ppa:deb-rob/ros-trusty && sudo apt-get update
 sudo apt-get install libopenni2-dev

2.安装libfreenect2

参考:http://www.cnblogs.com/hitcm/p/5118196.html

注意:按照上面链接中的方法编译成功,测试./bin/Protonect,如果没问题,则按照下面方法重新编译一遍:

cmake .. -DBUILD_OPENNI2_DRIVER=ON
make
sudo make install
sudo cp ../platform/linux/udev/-kinect2.rules /etc/udev/rules.d/
测试: ./bin/Protonect

如果按照上面语句直接编译,可能会出现以下错误:

[Debug] [DepthPacketStreamParser] not all subsequences received
[Debug] [DepthPacketStreamParser] not all subsequences received
[Debug] [RgbPacketStreamParser] skipping rgb packet!
[Debug] [RgbPacketStreamParser] skipping rgb packet!
[Debug] [RgbPacketStreamParser] skipping rgb packet!
The viewer is turned off. Received frames. Ctrl-C to stop.
The viewer is turned off. Received frames. Ctrl-C to stop.
The viewer is turned off. Received frames. Ctrl-C to stop.
[Debug] [RgbPacketStreamParser] skipping rgb packet!
The viewer is turned off. Received frames. Ctrl-C to stop.
The viewer is turned off. Received frames. Ctrl-C to stop.
The viewer is turned off. Received frames. Ctrl-C to stop.
The viewer is turned off. Received frames. Ctrl-C to stop.
The viewer is turned off. Received frames. Ctrl-C to stop.
The viewer is turned off. Received frames. Ctrl-C to stop.
The viewer is turned off. Received frames. Ctrl-C to stop.

如果没有问题,则在此路径下执行如下操作:

sudo apt-get install openni2-utils
sudo make install-openni2
NiViewer2

如果能显示图像,则可以编译Elasticfusion.

3.编译Elasticfusion

编译Core:

git clone https://github.com/mp3guy/ElasticFusion.git
cd ElasticFusion
cd Core
mkdir build && cd build
cmake ../src/
make
sudo make install
sudo ldconfig

编译GPUTest:

cd ../../GPUTest
mkdir build && cd build
cmake ../src/
make
sudo ldconfig

编译GUI

cd ../../GUI
mkdir build && cd build
cmake ../src/
make
sudo make install
sudo ldconfig

注:跑kinect2时,将MainController.cpp第37行的Resolution::getInstance(640, 480)改为Resolution::getInstance(512, 424)

否则可能会出现以下错误:

ElasticFusion: /home/slam/ElasticFusion/GUI/src/Tools/OpenNI2Interface.cpp:: 
OpenNI2Interface::OpenNI2Interface(int, int, int): Assertion `findMode(width, height, fps) && "Sorry, mode not supported!"' failed.

总之,非常的玄学。。。。。。