Ubuntu14.04下搭建Kinect V2的环境以及出现的问题解决方案

2024-05-30 06:08

本文主要是介绍Ubuntu14.04下搭建Kinect V2的环境以及出现的问题解决方案,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

请各位注意是kinect V2,kinect有两个版本,V1和V2


一、安装

1、Download libfreenect2 source

git clone git@github.com:DongdongBai/libfreenect2.git
cd libfreenect2

2、Download upgrade deb files

cd depends; ./download_debs_trusty.sh

3、Install build tools

sudo apt-get install build-essential cmake pkg-config

4、先安装Nvidia显卡驱动和cuda,然后源码编译Opencv(本步骤的顺序不可以颠倒,因为Opencv在编译时会查找显卡驱动的版本(是使用集成显卡还是独立显卡呢,以及独立显卡驱动的版本),如果先装Opencv,则Opencv会使用系统的默认的继承显卡驱动,后面安装Nvidia驱动将导致Opencv无法正常使用)

5、Install libusb. The version must be >= 1.0.20.

sudo dpkg -i debs/libusb*deb

6、Install TurboJPEG

sudo apt-get install libturbojpeg libjpeg-turbo8-dev

7、 Install OpenGL

sudo dpkg -i debs/libglfw3*deb
sudo apt-get install -f
sudo apt-get install libgl1-mesa-dri-lts-vivid

如果最后一步出现依赖错误,直接忽略,无需做任何处理

8、Build

cd ..
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2 -DENABLE_CXX11=ON
make
make install

9、执行Cmake时出现

CMake Warning at CMakeLists.txt:405 (ADD_LIBRARY):Cannot generate a safe runtime search path for target freenect2 becausefiles in some directories may conflict with libraries in implicitdirectories:runtime library [libOpenCL.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:/usr/local/cuda-7.5/lib64Some of these libraries may not be found correctly.CMake Warning at CMakeLists.txt:451 (ADD_LIBRARY):Cannot generate a safe runtime search path for target freenect2-openni2because files in some directories may conflict with libraries in implicitdirectories:runtime library [libOpenCL.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:/usr/local/cuda-7.5/lib64Some of these libraries may not be found correctly.CMake Warning at examples/CMakeLists.txt:76 (ADD_EXECUTABLE):Cannot generate a safe runtime search path for target Protonect becausefiles in some directories may conflict with libraries in implicitdirectories:runtime library [libOpenCL.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:/usr/local/cuda-7.5/lib64Some of these libraries may not be found correctly.

解决方法:在项目的cmake_modules文件夹中的FindOpenCL.cmake中添加下面两句话即可(本教程中clone源代码的CMakeLists.txt已经做了更改,不回出现上述问题,请放心使用):

SET(OpenCL_INCLUDE_DIR /usr/local/cuda/include/ )
SET(OpenCL_LIBRARY  /usr/local/cuda-7.5/lib64/libOpenCL.so)

10、编译时如果出现以下错误:


/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h(432): error: identifier "nullptr" is undefined/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h(432): error: expected a ";"/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h(190): error: expected a ";"/usr/include/c++/4.8/exception(63): error: expected a ";"/usr/include/c++/4.8/exception(68): error: expected a ";"/usr/include/c++/4.8/exception(76): error: expected a ";"/usr/include/c++/4.8/exception(83): error: expected a ";"/usr/include/c++/4.8/exception(93): error: expected a "{"/usr/include/c++/4.8/bits/exception_ptr.h(64): error: function "std::current_exception" returns incomplete type "std::__exception_ptr::exception_ptr"/usr/include/c++/4.8/bits/exception_ptr.h(64): error: expected a "{"/usr/include/c++/4.8/bits/exception_ptr.h(79): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(81): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(82): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(84): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(86): error: declaration is incompatible with previous "std::current_exception"
(64): here/usr/include/c++/4.8/bits/exception_ptr.h(86): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(86): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(87): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(90): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(92): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(95): error: incomplete type is not allowed/usr/include/c++/4.8/bits/exception_ptr.h(95): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(116): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(126): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(143): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(144): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(147): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(152): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(153): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(156): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(157): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(160): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(161): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(169): error: expected a ";"/usr/include/c++/4.8/bits/nested_exception.h(57): error: incomplete type is not allowed/usr/include/c++/4.8/bits/nested_exception.h(60): error: expected a ";"/usr/include/c++/4.8/bits/nested_exception.h(66): error: expected a ";"/usr/include/c++/4.8/bits/nested_exception.h(70): error: identifier "rethrow_exception" is undefined/usr/include/c++/4.8/bits/nested_exception.h(73): error: function "std::nested_exception::nested_ptr" returns incomplete type "std::__exception_ptr::exception_ptr"/usr/include/c++/4.8/new(95): error: expected a "{"/usr/include/c++/4.8/new(110): error: identifier "__p" is undefined/usr/include/c++/4.8/new(111): error: expected a "{"/usr/include/c++/4.8/new(115): error: expected a "{"/usr/include/c++/4.8/new(116): error: expected a "{"/usr/local/cuda-7.5/include/common_functions.h(102): warning: exception specification is incompatible with that of previous function "operator new[](std::size_t, void *)"
/usr/include/c++/4.8/new(111): here/usr/local/cuda-7.5/include/common_functions.h(103): warning: exception specification is incompatible with that of previous function "operator delete(void *, void *)"
/usr/include/c++/4.8/new(115): here/usr/local/cuda-7.5/include/common_functions.h(104): warning: exception specification is incompatible with that of previous function "operator delete[](void *, void *)"
/usr/include/c++/4.8/new(116): here/usr/include/c++/4.8/bits/cpp_type_traits.h(184): error: identifier "char16_t" is undefined/usr/include/c++/4.8/bits/cpp_type_traits.h(191): error: identifier "char32_t" is undefined/usr/include/c++/4.8/bits/cpp_type_traits.h(191): error: class "std::__is_integer<<error-type>>" has already been defined/usr/include/c++/4.8/bits/cpp_type_traits.h(314): error: namespace "std::__gnu_cxx" has no member "__normal_iterator"/usr/include/c++/4.8/bits/cpp_type_traits.h(314): error: expected a ">"/usr/include/c++/4.8/cmath(80): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(80): error: expected a ";"/usr/include/c++/4.8/cmath(105): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(105): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(105): error: expected a ";"/usr/include/c++/4.8/cmath(124): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(124): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(124): error: expected a ";"/usr/include/c++/4.8/cmath(143): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(143): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(143): error: expected a ";"/usr/include/c++/4.8/cmath(162): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(162): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(162): error: expected a ";"/usr/include/c++/4.8/cmath(183): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(183): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(183): error: expected a ";"/usr/include/c++/4.8/cmath(202): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(202): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(202): error: expected a ";"/usr/include/c++/4.8/cmath(221): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(221): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(221): error: expected a ";"/usr/include/c++/4.8/cmath(240): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(240): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(240): error: expected a ";"/usr/include/c++/4.8/cmath(259): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(259): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(259): error: expected a ";"/usr/include/c++/4.8/cmath(278): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(278): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(278): error: expected a ";"/usr/include/c++/4.8/cmath(297): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(297): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(297): error: expected a ";"/usr/include/c++/4.8/cmath(328): error: "constexpr" is not a function or static data member/usr/include/c++/4.8/cmath(337): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(337): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(337): error: expected a ";"/usr/include/c++/4.8/cmath(356): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(356): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(356): error: expected a ";"/usr/include/c++/4.8/cmath(375): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(375): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(375): error: expected a ";"/usr/include/c++/4.8/cmath(406): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(406): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(406): error: expected a ";"/usr/include/c++/4.8/cmath(443): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(443): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(443): error: expected a ";"Error limit reached.
100 errors detected in the compilation of "/tmp/tmpxft_00001206_00000000-7_cuda_kde_depth_packet_processor.cpp1.ii".
Compilation terminated.
CMake Error at cuda_compile_generated_cuda_kde_depth_packet_processor.cu.o.cmake:264 (message):Error generating file/home/bdd/libfreenect2-master/build/CMakeFiles/cuda_compile.dir/src/./cuda_compile_generated_cuda_kde_depth_packet_processor.cu.omake[2]: *** [CMakeFiles/cuda_compile.dir/src/./cuda_compile_generated_cuda_kde_depth_packet_processor.cu.o] Error 1
make[1]: *** [CMakeFiles/freenect2.dir/all] Error 2
make: *** [all] Error 2

将项目中的cuda关闭即可,即将CMakeLists.txt中的第35行的OPTION(ENABLE_CUDA “Enable CUDA support” ON)的ON改为OFF即可(本教程中clone源代码的CMakeLists.txt已经做了更改,不回出现上述问题,请放心使用)。


二、验证安装是否成功及问题解决方法

在build下面有个bin文件夹,放置生成的输出文件,插上kinect,然后运行。此时黄灯变成白色的,表示有驱动。注意:只能用于USB3的接口,好在台式机和笔记本都有3.0的口。

./bin/Protonect gl
./bin/Protonect cl
./bin/Protonect cpu

但是如果提示权限不够,failed to open Kinect V2 Access denied,设定执行:sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/, 然后重新插拔Kinect2.


Ros接口安装

1、对于已经安装了Ros Indigo的Ubuntu14.04来说,使用下面的命令

cd ~/catkin_ws/src/
git clone git@github.com:DongdongBai/iai_kinect2.git
cd iai_kinect2
sudo rosdep install -r --from-paths .
cd ~/catkin_ws
catkin_make -DCMAKE_BUILD_TYPE="Release"
rospack profile

注意:针对于上述命令中最后一行指令, 需要说明的是, 如果前面libfreenect2你安装的位置不是$HOME/freenect2或/usr/local这两个标准路径下下, 需要提供参数指定libfreenect2所在路径:

catkin_make -Dfreenect2_DIR=path_to_freenect2/lib/cmake/freenect2 -DCMAKE_BUILD_TYPE="Release"

2、sudo rosdep install -r –from-paths . 出现如下问题:

ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies (ROS distro is not set. Make sure `ROS_DISTRO` environment variable is set, or use `--rosdistro` option to specify the distro, e.g. `--rosdistro indigo`):
kinect2_viewer: Cannot locate rosdep definition for [cv_bridge]
kinect2_registration: Cannot locate rosdep definition for [cv_bridge]
kinect2_bridge: Cannot locate rosdep definition for [cv_bridge]
kinect2_calibration: Cannot locate rosdep definition for [cv_bridge]
Continuing to install resolvable dependencies...
#All required rosdeps installed successfully

这个问题是正常情况,不是错误,请大家直接忽视!

3、接下来可以测试了。

roslaunch kinect2_bridge kinect2_bridge.launch

然后重新开一个新的终端

rosrun kinect2_viewer kinect2_viewer

显示如下图所示。Good Luck and enjoy it!

这篇关于Ubuntu14.04下搭建Kinect V2的环境以及出现的问题解决方案的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1015779

相关文章

详谈redis跟数据库的数据同步问题

《详谈redis跟数据库的数据同步问题》文章讨论了在Redis和数据库数据一致性问题上的解决方案,主要比较了先更新Redis缓存再更新数据库和先更新数据库再更新Redis缓存两种方案,文章指出,删除R... 目录一、Redis 数据库数据一致性的解决方案1.1、更新Redis缓存、删除Redis缓存的区别二

oracle数据库索引失效的问题及解决

《oracle数据库索引失效的问题及解决》本文总结了在Oracle数据库中索引失效的一些常见场景,包括使用isnull、isnotnull、!=、、、函数处理、like前置%查询以及范围索引和等值索引... 目录oracle数据库索引失效问题场景环境索引失效情况及验证结论一结论二结论三结论四结论五总结ora

element-ui下拉输入框+resetFields无法回显的问题解决

《element-ui下拉输入框+resetFields无法回显的问题解决》本文主要介绍了在使用ElementUI的下拉输入框时,点击重置按钮后输入框无法回显数据的问题,具有一定的参考价值,感兴趣的... 目录描述原因问题重现解决方案方法一方法二总结描述第一次进入页面,不做任何操作,点击重置按钮,再进行下

python 字典d[k]中key不存在的解决方案

《python字典d[k]中key不存在的解决方案》本文主要介绍了在Python中处理字典键不存在时获取默认值的两种方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录defaultdict:处理找不到的键的一个选择特殊方法__missing__有时候为了方便起见,

解决mybatis-plus-boot-starter与mybatis-spring-boot-starter的错误问题

《解决mybatis-plus-boot-starter与mybatis-spring-boot-starter的错误问题》本文主要讲述了在使用MyBatis和MyBatis-Plus时遇到的绑定异常... 目录myBATis-plus-boot-starpythonter与mybatis-spring-b

Mycat搭建分库分表方式

《Mycat搭建分库分表方式》文章介绍了如何使用分库分表架构来解决单表数据量过大带来的性能和存储容量限制的问题,通过在一对主从复制节点上配置数据源,并使用分片算法将数据分配到不同的数据库表中,可以有效... 目录分库分表解决的问题分库分表架构添加数据验证结果 总结分库分表解决的问题单表数据量过大带来的性能

Java汇编源码如何查看环境搭建

《Java汇编源码如何查看环境搭建》:本文主要介绍如何在IntelliJIDEA开发环境中搭建字节码和汇编环境,以便更好地进行代码调优和JVM学习,首先,介绍了如何配置IntelliJIDEA以方... 目录一、简介二、在IDEA开发环境中搭建汇编环境2.1 在IDEA中搭建字节码查看环境2.1.1 搭建步

mysql主从及遇到的问题解决

《mysql主从及遇到的问题解决》本文详细介绍了如何使用Docker配置MySQL主从复制,首先创建了两个文件夹并分别配置了`my.cnf`文件,通过执行脚本启动容器并配置好主从关系,文中还提到了一些... 目录mysql主从及遇到问题解决遇到的问题说明总结mysql主从及遇到问题解决1.基于mysql

如何测试计算机的内存是否存在问题? 判断电脑内存故障的多种方法

《如何测试计算机的内存是否存在问题?判断电脑内存故障的多种方法》内存是电脑中非常重要的组件之一,如果内存出现故障,可能会导致电脑出现各种问题,如蓝屏、死机、程序崩溃等,如何判断内存是否出现故障呢?下... 如果你的电脑是崩溃、冻结还是不稳定,那么它的内存可能有问题。要进行检查,你可以使用Windows 11

如何安装HWE内核? Ubuntu安装hwe内核解决硬件太新的问题

《如何安装HWE内核?Ubuntu安装hwe内核解决硬件太新的问题》今天的主角就是hwe内核(hardwareenablementkernel),一般安装的Ubuntu都是初始内核,不能很好地支... 对于追求系统稳定性,又想充分利用最新硬件特性的 Ubuntu 用户来说,HWEXBQgUbdlna(Har