记录Kinect V1与V2在Ubuntu16.04下的配置过程以及在ros下的骨骼检测追踪

Kinect V2

install the libfreenect2

$ sudo apt-add-repository ppa:deb-rob/ros-trusty && sudo apt-get update(don't need if you have ros)
$ sudo apt-get install libopenni2-dev

$ git clone https://github.com/OpenKinect/libfreenect2.git
$ cd libfreenect2
$ cd depends
$ ./download_debs_trusty.sh
$ sudo apt-get install build-essential cmake pkg-config

$ mkdir build && cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/Projects/freenect2
$ make
$ sudo make install
$ sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/

利用$ ./bin/Protonect测试是否可以从Kinect中读图(此时我的V1不可以显示图片; V2可以):

  • $ NiViewer 用于驱动Kinect V1(测试ok)
  • $ NiViewer2 用于驱动Kinect V2(测试ok)

但上述命令执行完之后应该是没有NiViewer2的,因此需要在/libfreenect/build路径下:

$ sudo apt-get install openni2-utils
$ cmake ..
$ make && sudo make install (optional)
$ sudo make install-openni2
$ NiViewer2

能够正常显示图片即可。

install the OpenNI

$ git clone https://github.com/OpenNI/OpenNI.git
$ cd OpenNI/Platform/Linux/CreateRedist/
$ chmod +x RedistMaker
$ ./RedistMaker
$ cd ../Redist/OpenNI-Bin-Dev-Linux-x64.../
$ sudo ./install.sh

显示应如下:

Installing OpenNI
****************************

copying shared libraries...OK
copying executables...OK
copying include files...OK
creating database directory...OK
registering module 'libnimMockNodes.so'...OK
registering module 'libnimCodecs.so'...OK
registering module 'libnimRecorder.so'...OK
creating java bindings directory...OK
Installing java bindings...OK

*** DONE ***

测试NiViewer

$ cd OpenNI
$ ./Platform/Linux/Bin/x64-Release/NiViewer

如果之前在libfreenect2的安装中没有make install-openni2可能会报错,报错如下:

SimpleViewer: Device open failed:   
    DeviceOpen using default: no devices found

在执行$ ./RedistMaker过程中可能会报下面的错误,解决方法如下:

/bin/sh: 1: javac: not found
$ sudo apt install openjdk-8-jdk
sh: 1: doxygen: not found
$ sudo apt install doxygen

install the SensorKinect

$ git clone git://github.com/avin2/SensorKinect.git
$ cd SensorKinect/Platform/Linux/CreateRedist/
$ chmod +x RedistMaker
$ ./RedistMaker
在SensorKinect的Bin目录下解压出Sensor-Bin-Linux-x64...
$ cd ./Bin/Sensor-Bin-Linux-x64...
$ chmod +x install.sh
$ sudo ./install.sh

显示应如下:

Installing PrimeSense Sensor
****************************

creating config dir /usr/etc/primesense...\OK
copying shared libraries...OK
copying executables...OK
registering module 'libXnDeviceSensorV2KM.so' with OpenNI...OK
registering module 'libXnDeviceFile.so' with OpenNI...OK
copying server config file...OK
setting uid of server...OK
creating server logs dir...OK
installing usb rules...OK
installing modprobe blacklist...OK

*** DONE ***

install the Nite

下载NiTE-Linux-x64-2.2.tar.bz2,解压缩
$ cd NiTE-Linux-x64-2.2
$ sudo ./install.sh
生成NiTedevEnvironment文件 
$ gedit ./Samples/Bin/OpenNI.ini
加上一句Repository=/usr/lib/OpenNI2/Drivers(就是安装openni2生成的driver路径)
$ cd ./Samples/Bin 
$ ./UserViewer

不出意外应能看到骨骼图。

ROS包

kinectV2 ros驱动

$ cd ~/catkin_ws/src/
$ git clone https://github.com/code-iai/iai_kinect2.git
$ cd iai_kinect2
$ rosdep install -r --from-paths .
$ cd ~/catkin_ws
$ catkin_make -DCMAKE_BUILD_TYPE="Release" -Dfreenect2_DIR=path_to_freenect2/lib/cmake/freenect2
__NOTE:the <path_to_freenect2>is the '$HOME/Projects/freenect2' just setting before building the libfreenect2__
  • 有许多未引用的错误
viewer.cpp:(.text._ZN8Receiver11imageViewerEv[_ZN8Receiver11imageViewerEv]+0xae2): undefined reference to `cv::String::deallocate()'
viewer.cpp:(.text._ZN8Receiver11imageViewerEv[_ZN8Receiver11imageViewerEv]+0xb16): undefined reference to `cv::String::deallocate()'
viewer.cpp:(.text._ZN8Receiver11imageViewerEv[_ZN8Receiver11imageViewerEv]+0xb4b): undefined reference to `cv::String::deallocate()'
collect2: error: ld returned 1 exit status

解决方案

sudo apt-get install ros-indigo-opencv3(optional)
后删掉ros_ws中的build与devel,重新catkin_make,发现编译通过
  • 这里可能会出现一个问题:
    执行命令:
$ roslaunch kinect2_bridge kinect_bridge.launch
报错:
[ERROR] [1453460840.163354866]: Failed to load nodelet [/kinect2_bridge] of type [kinect2_bridge/kinect2_bridge_nodelet]: Could not find library corresponding to plugin kinect2_bridge/kinect2_bridge_nodelet. Make sure the plugin description XML file has the correct name of the library and that the library actually exists.
[FATAL] [1453460840.163649816]: Service call failed!
等一系列错误代码

rosrun kinect_bridge kinect_bridge
报错:
segmentation fault (core dumped)

解决方案
这是因为我配置的opencv的版本是3.3.1,而iai_kinect2是基于opencv2.4.9的。解决方法:在Ubuntu下安装opencv2.4.9,使之与高版本的opencv共存。

kinectV2 骨骼检测

还未配置(待续…)

Kinect V1

install the libfreenect

$ git clone https://github.com/OpenKinect/libfreenect
$ cd libfreenect
$ mkdir build
$ cd build
$ cmake -L .. # -L lists all the project options
$ make

install the OpenNI

install the SensorKinect

install the Nite

需要注意的是,上面安装Kinect V2的NiTE版本是2.2,但在这里需要安装1.5.2.21版本以上的,但不能是2的驱动,具体原因是ros包中的需求,将在后面提到。
我安装的是1.5.2.23版本的。
可以通过下面的链接下载: http://pan.baidu.com/s/1hqHB10w 提取密码:wrmn

$ cd NITE-Bin-Dev-Linux-x64-v1.5.2.23
$ sudo ./install.sh

ROS包

Kinect V1 驱动

  1. 使用openni_launch
    $ sudo apt-get install ros-kinetic-openni-camera ros-kinetic-openni-launch

(使用freenect_launch不报错)
$ sudo apt-get install ros-kinetic-freenect-camera ros-kinetic-freenect-stack ros-kinetic-freenect-launch
$ roslaunch freenect_launch freenect.launch

BUT!
$ roslaunch openni_launch openni.launch后运行中的错误如下:

Warning: USB events thread - failed to set priority. This might cause loss of data...
[ INFO] [1543141015.998271459]: Number devices connected: 2
[ INFO] [1543141016.099558181]: 1. device on bus 001:15 is a SensorKinect (2ae) from PrimeSense (45e) with serial id '0'
[ INFO] [1543141016.099633610]: 2. device on bus 001:15 is a SensorV2 (2ae) from PrimeSense (45e) with serial id 'A00364A05003107A'
[ INFO] [1543141016.100583768]: Searching for device with index = 1
[camera/camera_nodelet_manager-2] process has died [pid 19127, exit code -11, cmd /opt/ros/kinetic/lib/nodelet/nodelet manager __name:=camera_nodelet_manager __log:=/home/lesleybinglei/.ros/log/3a69c930-f09b-11e8-b898-30b49eb249b5/camera-camera_nodelet_manager-2.log].
log file: /home/lesleybinglei/.ros/log/3a69c930-f09b-11e8-b898-30b49eb249b5/camera-camera_nodelet_manager-2*.log

Solution:

$ cd /your/path/to/SensorKinect/Bin/Sensor-Bin-Linux-x64-v...
$ sudo ./install.sh -u
Uninstalling PrimeSense Sensor
******************************

unregistering module 'libXnDeviceSensorV2KM.so' from OpenNI...OK
unregistering module 'libXnDeviceFile.so' from OpenNI...OK
removing shared libraries...OK
removing executables...OK
removing config dir...OK
removing usb rules...OK
removing modprobe blacklist...OK

*** DONE ***

and the $ roslaunch openni_launch openni.launch is OK!!!

you can get the pic by:

$ rosrun image_view image_view image:=/camera/depth/image
$ rosrun rviz rviz
$ rosrun rqt_image_view rqt_image_view

Kinect V1 骨骼检测

  1. openni_tracker
    $ rosrun openni_tracker openni_tracker
    However, there is a problem.
[ERROR] [1543142140.496686826]: NITE is likely missing: Please install NITE >= 1.5.2.21. Check the readme for download ![1](/assets/1.jpg)information. Error Info: User generator failed: Can't create any node of the requested type!

出现这个问题的原因是NiTE版本不匹配,你可能没有安装NiTE或安装版本过低,也有可能是安装的是Kinect V2的NiTE版本,解决办法在Kinect V1的NiTE安装中

接下来可以在rivz中显示骨骼图

$ rosrun rivz rivz

1.在Rviz中,把Global Options > Fixed Frame 改成openni_depth_optical_frame;
2.”Add”(左下角),选择PointCloud2。
把 PointCloud2 >Topic改成/openni/depth_registered/points。
3.点击”Add”,选择TF(在列表的最下面)。
4.站在kinect前面,摆出“投降”姿势(进行calibration),稍等一会,跟踪到的各个节点就出来了。

  1. skeleton_markers使用
$ cd ros_ws/src
$ git clone -b https://github.com/pirobot/skeleton_markers.git
$ cd ../..
$ catkin_make
$ roslaunch skeleton_markers markers_from_tf.launch
$ rosrun rviz rviz -d `rospack find skeleton_markers`/markers_from_tf.rviz

如果可以正常显示骨骼图就完成了。

  1. 使用skeleton_markers publish and subscribe 3d坐标
$ roslaunch openni_launch openni.launch
$ rosrun skeleton_markers skeleton_tracker 或 roslaunch skeleton_markers skeleton.launch
$ rosrun skeleton_markers skeleton_subscriber.py 
# 接收节点的测试,其中position是3d坐标,orientation包含x,y,z,w,confidence是置信度
# 骨骼节点的顺序为head, neck, torso, left_shoulder, left_elbow, left_hand, right_shoulder, right_elbow, 
# right_hand, left_hip, left_knee, left_foot, right_hip, right_knee, right_foot

skeleton_subscriber.py参考了/nodes/markers_from_skeleton_msg.py
运行截图如下:
运行截图

参考链接:
参考链接:
Baxter学习笔记2-Kinect摄像头驱动安装篇
ubuntu上面的openni ,kinect 安装
SimpleViewer: Device open failed: DeviceOpen using default: no devices found
Kinect V2学习之Openi2,Nite2,Sensorkinect和Openni2_tracker编译安装来获取骨骼数据(ros)
https://github.com/mavlink/mavros/issues/199
ubuntu下opencv2.4.9和opencv3.1.0的使用
Ubuntu安装Kinect驱动(openni、NITE、Sensor)及遇到的问题
https://github.com/OpenKinect/libfreenect
http://wiki.ros.org/openni_tracker
https://github.com/ros-drivers/openni_camera/issues/54
http://wiki.ros.org/skeleton_markers#Skeleton_Markers_From_tf_Node
https://github.com/pirobot/skeleton_markers
ubuntu+ROS+kinect进行骨架跟踪
在程序中访问骨架图—35
OpenNI 的座標系統
kinect bookmark kinect传感系统详解

  • 3
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值