程序员人生 网站导航

ubuntu 14.04 +Kinect+ openNI+ openCV+ Sensorkinect 配置 +获取深度图像及相关问题

栏目:php教程时间:2016-07-11 08:53:38

1. 最初参考的是:http://blog.csdn.net/u011700636/article/details/41493645的教程进程,但是其中遇到诸多问题,主要是来自于git包的问题,好像是相互不兼容的问题,安装SensorKinect的时候总是报错,把openni和sensorKinect都换成Unstable都不行。

2. Nite用于提取图下功能SKETEON,暂不需要,跳过不装没有问题!!

3. 配置中 openNI+ openCV+ Sensorkinect是相互依赖的,因此opencv最后配置,如果之前配置过opencv,应当重新编译配置1边,添加openNI的选项,没法获得图象报错:

 VideoCapture capture(CV_CAP_OPENNI) 不能获得数据

4. USB 1.0或2.0没有区分,都可以获得信号。

5. 基本依赖库的安装:首先安装,为了不以后安装中的大量毛病。
sudo apt-get install git-core cmake freeglut3-dev pkg-config build-essential libxmu-dev libxi-dev libusb⑴.0-0-dev doxygen graphviz mono-complete


6.关于kinect配置和调试的文章: http://wiki.opencv.org.cn/index.php/%E5%9F%BA%E4%BA%8EKinect-OpenNI-OpenCV-OpenGL%E7%9A%84%E7%8E%AF%E5%A2%83%E4%B8%89%E7%BB%B4%E9%87%8D%E6%9E%84

========================


6. 使用以下方法通过安装:http://blog.csdn.net/u013453604/article/details/48013959

以下转载:

1、前言

先说1下博主的运行环境:
Ubuntu kylin14.04
kinect第1代
另外还要注意的是openni、NITE、Sensor这3个包的版本必须匹配才能正常运行,我的版本分别是:
OpenNI-Bin-Dev-Linux-x64-v1.5.7.10.tar
NITE-Bin-Linux-x64-v1.5.2.23.tar
SensorKinect093-Bin-Linux-x64-v5.1.2.1
可以在我的网盘下载:http://pan.baidu.com/s/1hqHB10w 提取密码:wrmn
本文地址:http://blog.csdn.net/u013453604/article/details/48013959

【重要】
这3个软件包的安装要注意顺序:先安装openni,再安装Sensor,最后安装NITE。
另外可以带-u参数卸载这些软件包重新安装$ sudo ./install.sh -u,但是NITE里有专门的uninstall.sh可以运行它来卸载。

2、安装OpenNI

下载OpenNI-Bin-Dev-Linux-x64-v1.5.7.10.tar解压得到OpenNI-Bin-Dev-Linux-x64-v1.5.7.10文件夹,我把这3个包都放在home下面的software目录下

<code class="hljs lasso has-numbering"></code><pre name="code" class="prettyprint"><code class="hljs lasso has-numbering">$ cd /home/siat/software/OpenNI<span class="hljs-attribute">-Bin</span><span class="hljs-attribute">-Dev</span><span class="hljs-attribute">-Linux</span><span class="hljs-attribute">-x64</span><span class="hljs-attribute">-v1</span><span class="hljs-number">.5</span><span class="hljs-number">.7</span><span class="hljs-number">.10</span> $ sudo <span class="hljs-built_in">.</span>/install<span class="hljs-built_in">.</span>sh</code>

如果显示以下

<code class="hljs lasso has-numbering">Installing OpenNI <span class="hljs-subst">****************************</span> copying shared libraries<span class="hljs-attribute">...</span>OK copying executables<span class="hljs-attribute">...</span>OK copying include files<span class="hljs-attribute">...</span>OK creating database directory<span class="hljs-attribute">...</span>OK registering module <span class="hljs-string">'libnimMockNodes.so'</span><span class="hljs-attribute">...</span>OK registering module <span class="hljs-string">'libnimCodecs.so'</span><span class="hljs-attribute">...</span>OK registering module <span class="hljs-string">'libnimRecorder.so'</span><span class="hljs-attribute">...</span>OK creating java bindings directory<span class="hljs-attribute">...</span>OK Installing java bindings<span class="hljs-attribute">...</span>OK <span class="hljs-subst">***</span> DONE <span class="hljs-subst">***</span></code>

则安装成功

3、安装Sensor

下载SensorKinect093-Bin-Linux-x64-v5.1.2.1.tar.bz2解压得到SensorKinect093-Bin-Linux-x64-v5.1.2.1文件夹放到software下面

<code class="hljs lasso has-numbering">$ cd /home/siat/software/Sensor<span class="hljs-attribute">-Bin</span><span class="hljs-attribute">-Linux</span><span class="hljs-attribute">-x64</span><span class="hljs-attribute">-v5</span><span class="hljs-number">.1</span><span class="hljs-number">.2</span><span class="hljs-number">.1</span> $ sudo <span class="hljs-built_in">.</span>/install<span class="hljs-built_in">.</span>sh</code>

如果显示以下

<code class="hljs lasso has-numbering">Installing PrimeSense Sensor <span class="hljs-subst">****************************</span> creating config dir /usr/etc/primesense<span class="hljs-attribute">...</span>OK copying shared libraries<span class="hljs-attribute">...</span>OK copying executables<span class="hljs-attribute">...</span>OK registering module <span class="hljs-string">'libXnDeviceSensorV2KM.so'</span> <span class="hljs-keyword">with</span> OpenNI<span class="hljs-attribute">...</span>OK registering module <span class="hljs-string">'libXnDeviceFile.so'</span> <span class="hljs-keyword">with</span> OpenNI<span class="hljs-attribute">...</span>OK copying server config file<span class="hljs-attribute">...</span>OK setting uid of server<span class="hljs-attribute">...</span>OK creating server logs dir<span class="hljs-attribute">...</span>OK installing usb rules<span class="hljs-attribute">...</span>OK installing modprobe blacklist<span class="hljs-attribute">...</span>OK <span class="hljs-subst">***</span> DONE <span class="hljs-subst">***</span></code>

则安装成功

4、安装NITE

下载NITE-Bin-Linux-x64-v1.5.2.23.tar解压得到NITE-Bin-Linux-x64-v1.5.2.23文件夹放在software下面

<code class="hljs lasso has-numbering">$ cd /home/siat/software/NITE<span class="hljs-attribute">-Bin</span><span class="hljs-attribute">-Linux</span><span class="hljs-attribute">-x64</span><span class="hljs-attribute">-v1</span><span class="hljs-number">.5</span><span class="hljs-number">.2</span><span class="hljs-number">.23</span> $ sudo <span class="hljs-built_in">.</span>/install<span class="hljs-built_in">.</span>sh</code>

如果显示以下:

<code class="hljs r has-numbering">Installing NITE *************** Copying shared libraries... OK Copying includes... OK Installing java bindings... OK Installing module <span class="hljs-string">'Features_1_3_0'</span><span class="hljs-keyword">...</span> Registering module <span class="hljs-string">'libXnVFeatures_1_3_0.so'</span><span class="hljs-keyword">...</span> OK Installing module <span class="hljs-string">'Features_1_3_1'</span><span class="hljs-keyword">...</span> Registering module <span class="hljs-string">'libXnVFeatures_1_3_1.so'</span><span class="hljs-keyword">...</span> OK Installing module <span class="hljs-string">'Features_1_4_1'</span><span class="hljs-keyword">...</span> Registering module <span class="hljs-string">'libXnVFeatures_1_4_1.so'</span><span class="hljs-keyword">...</span> OK Installing module <span class="hljs-string">'Features_1_4_2'</span><span class="hljs-keyword">...</span> Registering module <span class="hljs-string">'libXnVFeatures_1_4_2.so'</span><span class="hljs-keyword">...</span> OK Installing module <span class="hljs-string">'Features_1_5_2'</span><span class="hljs-keyword">...</span> Registering module <span class="hljs-string">'libXnVFeatures_1_5_2.so'</span><span class="hljs-keyword">...</span> OK Copying XnVSceneServer... OK Installing module <span class="hljs-string">'Features_1_5_2'</span> registering module <span class="hljs-string">'libXnVHandGenerator_1_3_0.so'</span>...OK Installing module <span class="hljs-string">'Features_1_5_2'</span> registering module <span class="hljs-string">'libXnVHandGenerator_1_3_1.so'</span>...OK Installing module <span class="hljs-string">'Features_1_5_2'</span> registering module <span class="hljs-string">'libXnVHandGenerator_1_4_1.so'</span>...OK Installing module <span class="hljs-string">'Features_1_5_2'</span> registering module <span class="hljs-string">'libXnVHandGenerator_1_4_2.so'</span>...OK Installing module <span class="hljs-string">'Features_1_5_2'</span> registering module <span class="hljs-string">'libXnVHandGenerator_1_5_2.so'</span>...OK Adding license.. OK *** DONE ***</code>

则安装成功

5、运行示例

连上kinect的数据线

<code class="hljs lasso has-numbering">$ cd ~/software/OpenNI<span class="hljs-attribute">-Bin</span><span class="hljs-attribute">-Dev</span><span class="hljs-attribute">-Linux</span><span class="hljs-attribute">-x64</span><span class="hljs-attribute">-v1</span><span class="hljs-number">.5</span><span class="hljs-number">.7</span><span class="hljs-number">.10</span>/Samples/Bin/x64<span class="hljs-attribute">-Release</span> $ <span class="hljs-built_in">.</span>/NiViewer </code>

如果出现kinect画面则配置成功
这里写图片描述

如果想卸载这3个软件包只要一样运行./install.sh 带上参数-u 便可

<code class="hljs bash has-numbering">$ <span class="hljs-built_in">sudo</span> ./install.sh -u</code>

6、问题

1、注意如果出现:

<code class="hljs vbnet has-numbering">One <span class="hljs-keyword">or</span> more <span class="hljs-keyword">of</span> the following nodes could <span class="hljs-keyword">not</span> be enumerated: Device: PrimeSense/SensorV2/<span class="hljs-number">5.1</span><span class="hljs-number">.6</span><span class="hljs-number">.6</span>: The device <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> connected! Device: PrimeSense/SensorV2/<span class="hljs-number">5.1</span><span class="hljs-number">.0</span><span class="hljs-number">.41</span>: The device <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> connected! Device: PrimeSense/SensorV2/<span class="hljs-number">5.1</span><span class="hljs-number">.6</span><span class="hljs-number">.6</span>: The device <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> connected! Device: PrimeSense/SensorV2/<span class="hljs-number">5.1</span><span class="hljs-number">.0</span><span class="hljs-number">.41</span>: The device <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> connected! Press any <span class="hljs-keyword">key</span> <span class="hljs-keyword">to</span> <span class="hljs-keyword">continue</span> . . .</code>

这样的问题有多是这3个包版本不匹配,我这里的3个包亲测是可用的。但是Sensor如果是5.1.6.6版本则出现上面报错。

—⑵015.10.19
之前安装好了驱动可以正常运行的,今天运行openni的节点却发现不能正常打开Kinect了,报错以下:

<code class="hljs http has-numbering"><span class="hljs-attribute">Device</span>: <span class="hljs-string">PrimeSense/SensorV2/5.1.0.41: The device is not connected!</span></code>

因而我重新做了1遍步骤4

<code class="hljs lasso has-numbering">$ cd /home/siat/software/Sensor<span class="hljs-attribute">-Bin</span><span class="hljs-attribute">-Linux</span><span class="hljs-attribute">-x64</span><span class="hljs-attribute">-v5</span><span class="hljs-number">.1</span><span class="hljs-number">.2</span><span class="hljs-number">.1</span> $ sudo <span class="hljs-built_in">.</span>/install<span class="hljs-built_in">.</span>sh</code>

再次运行示例程序成功启动Kinect

—⑵016.06.13
我尝试用32位版本的驱动来启动xtion,还是提示连不上装备,当我重新编译上面3个64位驱动运行NiViewr的时候出现以下提示:

<code class="hljs vbnet has-numbering">One <span class="hljs-keyword">or</span> more <span class="hljs-keyword">of</span> the following nodes could <span class="hljs-keyword">not</span> be enumerated: Device: PrimeSense/SensorKinect/<span class="hljs-number">5.1</span><span class="hljs-number">.2</span><span class="hljs-number">.1</span>: The device <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> connected! Device: PrimeSense/SensorV2/<span class="hljs-number">5.1</span><span class="hljs-number">.0</span><span class="hljs-number">.41</span>: The device <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> connected! Device: PrimeSense/SensorKinect/<span class="hljs-number">5.1</span><span class="hljs-number">.2</span><span class="hljs-number">.1</span>: The device <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> connected! Device: PrimeSense/SensorV2/<span class="hljs-number">5.1</span><span class="hljs-number">.0</span><span class="hljs-number">.41</span>: The device <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> connected! Press any <span class="hljs-keyword">key</span> <span class="hljs-keyword">to</span> <span class="hljs-keyword">continue</span> . . .</code>

我用./install.sh -u 卸载Openni和Sensor,用./uninstall.sh 卸载NITE,然后重新到原64位Sensor驱动下运行./install.sh 以后正常使用NiViewr开启kinect。

2、注意openni2和NITE2版本的包现在只能用于xtion,kinect只能使用版本1的驱动
3、查看版本

<code class="hljs brainfuck has-numbering"><span class="hljs-comment">$</span> <span class="hljs-comment">pkg</span><span class="hljs-literal">-</span><span class="hljs-comment">config</span> <span class="hljs-literal">-</span><span class="hljs-literal">-</span><span class="hljs-comment">modversion</span> <span class="hljs-comment">opencv</span></code>

会显示版本号,比如

<code class="hljs has-numbering">2.4.11</code>

可以将opencv替换为其他包名字,用Tab键补全以免名字出错

4、用apt-get方式安装的1些包
kinect用的freenect:

<code class="hljs lasso has-numbering">$ sudo apt<span class="hljs-attribute">-get</span> install ros<span class="hljs-attribute">-indigo</span><span class="hljs-attribute">-freenect</span><span class="hljs-attribute">-launch</span> $ sudo apt<span class="hljs-attribute">-get</span> install ros<span class="hljs-attribute">-indigo</span><span class="hljs-attribute">-freenect</span><span class="hljs-attribute">-camera</span> $ sudo apt<span class="hljs-attribute">-get</span> install ros<span class="hljs-attribute">-indigo</span><span class="hljs-attribute">-freenect</span><span class="hljs-attribute">-stack</span></code>

xtion用的openni:

<code class="hljs lasso has-numbering">$ sudo apt<span class="hljs-attribute">-get</span> install ros<span class="hljs-attribute">-indigo</span><span class="hljs-attribute">-openni</span><span class="hljs-attribute">-camera</span> $ sudo apt<span class="hljs-attribute">-get</span> install ros<span class="hljs-attribute">-indigo</span><span class="hljs-attribute">-openni</span><span class="hljs-attribute">-launch</span> 上面如果不行请使用下面的驱动 $ sudo apt<span class="hljs-attribute">-get</span> install ros<span class="hljs-attribute">-indigo</span><span class="hljs-attribute">-openni2</span><span class="hljs-attribute">-camera</span> $ sudo apt<span class="hljs-attribute">-get</span> install ros<span class="hljs-attribute">-indigo</span><span class="hljs-attribute">-openni2</span><span class="hljs-attribute">-launch</span></code>

5、关于kinect和xtion切换的问题
openni默许的装备是kinect,如果你用的是kinect,装完上面的驱动以后运行NiViewer可以正常使用
但是如果你使用的装备是xtion,直接运行NiViewer会出现以下报错

<code class="hljs vbnet has-numbering">Open failed: USB <span class="hljs-keyword">interface</span> <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> supported!</code>

运行$ roslaunch openni_launch openni.launch 出现以下报错

<code class="hljs oxygene has-numbering">[ INFO] [<span class="hljs-number">1464612941.306334563</span>]: Initializing nodelet <span class="hljs-keyword">with</span> <span class="hljs-number">4</span> worker threads. [ INFO] [<span class="hljs-number">1464612947.664521213</span>]: Number devices connected: <span class="hljs-number">1</span> [ INFO] [<span class="hljs-number">1464612947.666982470</span>]: <span class="hljs-number">1</span>. device <span class="hljs-keyword">on</span> bus <span class="hljs-number">002</span>:<span class="hljs-number">04</span> <span class="hljs-keyword">is</span> a SensorV2 (<span class="hljs-number">601</span>) <span class="hljs-keyword">from</span> PrimeSense (<span class="hljs-number">1</span>d27) <span class="hljs-keyword">with</span> serial id <span class="hljs-string">'1312120224'</span> [ INFO] [<span class="hljs-number">1464612947.667906288</span>]: Searching <span class="hljs-keyword">for</span> device <span class="hljs-keyword">with</span> <span class="hljs-keyword">index</span> = <span class="hljs-number">1</span> [ INFO] [<span class="hljs-number">1464612947.670034045</span>]: No <span class="hljs-keyword">matching</span> device found.... waiting <span class="hljs-keyword">for</span> devices. Reason: openni_wrapper::OpenNIDevice::OpenNIDevice(xn::Context&, <span class="hljs-keyword">const</span> xn::NodeInfo&, <span class="hljs-keyword">const</span> xn::NodeInfo&, <span class="hljs-keyword">const</span> xn::NodeInfo&, <span class="hljs-keyword">const</span> xn::NodeInfo&) @ /tmp/binarydeb/ros-indigo-openni-camera-<span class="hljs-number">1.9</span>.<span class="hljs-number">5</span>/src/openni_device.cpp @ <span class="hljs-number">61</span> : creating depth generator failed. Reason: USB <span class="hljs-keyword">interface</span> <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> supported!</code><ul class="pre-numbering"><li><span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">也是</span><code style="background-color: rgb(255, 255, 255);">USB interface is not supported!</code><span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"> 的问题 </span></li></ul>

解决方案以下:参考博客
修改GlobalDefaults.ini配置文件

<code class="hljs bash has-numbering">$ <span class="hljs-built_in">sudo</span> gedit /etc/openni/GlobalDefaults.ini </code>

将第60行前面的分号去掉(即取消注释)

<code class="hljs fix has-numbering"><span class="hljs-attribute">;UsbInterface</span>=<span class="hljs-string">2</span></code>

再次尝试运行openni.launchNiViewer 就能够用xtion了,如果不行还需要重启1下电脑


关于xtion博主还有1个1直很困扰的问题,在刚装系统的电脑上安装上面3个驱动使用xtion很正常,但是在使用了1段时间的电脑上装这3个驱动却1直提示the device is not connected!,试了上面所有的方案都不行,估计是驱动冲突,我卸载了所有openni、nite相干的包重新安装驱动也不行,最后只好无奈的使用微软的Kinect才正常

6、Open failed: Xiron OS failed to wait on event!
运行以下命令:

<code class="hljs bash has-numbering">$ <span class="hljs-built_in">sudo</span> chmod +x /usr/bin/XnSensorServer</code>

7、博主重装了32位ubuntu14.04,然后下载上面3个驱动对应的32位驱动,编译以后可以驱动华硕的xtion pro live,值得注意的是有可能遇到以下问题

<code class="hljs vbnet has-numbering">Open failed: Failed <span class="hljs-keyword">to</span> <span class="hljs-keyword">set</span> USB <span class="hljs-keyword">interface</span>!</code>

这个问题跟前面的类似,需要改GlobalDefaults.ini 文件,但是32位驱动的这个配置文件不在/etc/openni/下了,搜索了1下文件夹找到这个文件原来是在/usr/etc/primesense/

<code class="hljs bash has-numbering">$ <span class="hljs-built_in">sudo</span> gedit /usr/etc/primesense/GlobalDefaults.ini </code>

将第60行前面的分号去掉(即取消注释)

<code class="hljs fix has-numbering"><span class="hljs-attribute">;UsbInterface</span>=<span class="hljs-string">2</span></code>

再次尝试运行openni.launchNiViewer 就能够用xtion了,如果不行还需要重启1下电脑




------分隔线----------------------------
------分隔线----------------------------

最新技术推荐