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

相关文章

Python如何自动生成环境依赖包requirements

《Python如何自动生成环境依赖包requirements》:本文主要介绍Python如何自动生成环境依赖包requirements问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录生成当前 python 环境 安装的所有依赖包1、命令2、常见问题只生成当前 项目 的所有依赖包1、

Node.js 数据库 CRUD 项目示例详解(完美解决方案)

《Node.js数据库CRUD项目示例详解(完美解决方案)》:本文主要介绍Node.js数据库CRUD项目示例详解(完美解决方案),本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考... 目录项目结构1. 初始化项目2. 配置数据库连接 (config/db.js)3. 创建模型 (models/

kali linux 无法登录root的问题及解决方法

《kalilinux无法登录root的问题及解决方法》:本文主要介绍kalilinux无法登录root的问题及解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,... 目录kali linux 无法登录root1、问题描述1.1、本地登录root1.2、ssh远程登录root2、

SpringBoot应用中出现的Full GC问题的场景与解决

《SpringBoot应用中出现的FullGC问题的场景与解决》这篇文章主要为大家详细介绍了SpringBoot应用中出现的FullGC问题的场景与解决方法,文中的示例代码讲解详细,感兴趣的小伙伴可... 目录Full GC的原理与触发条件原理触发条件对Spring Boot应用的影响示例代码优化建议结论F

Vuex Actions多参数传递的解决方案

《VuexActions多参数传递的解决方案》在Vuex中,actions的设计默认只支持单个参数传递,这有时会限制我们的使用场景,下面我将详细介绍几种处理多参数传递的解决方案,从基础到高级,... 目录一、对象封装法(推荐)二、参数解构法三、柯里化函数法四、Payload 工厂函数五、TypeScript

MySQL 中查询 VARCHAR 类型 JSON 数据的问题记录

《MySQL中查询VARCHAR类型JSON数据的问题记录》在数据库设计中,有时我们会将JSON数据存储在VARCHAR或TEXT类型字段中,本文将详细介绍如何在MySQL中有效查询存储为V... 目录一、问题背景二、mysql jsON 函数2.1 常用 JSON 函数三、查询示例3.1 基本查询3.2

Redis在windows环境下如何启动

《Redis在windows环境下如何启动》:本文主要介绍Redis在windows环境下如何启动的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Redis在Windows环境下启动1.在redis的安装目录下2.输入·redis-server.exe

Pytest多环境切换的常见方法介绍

《Pytest多环境切换的常见方法介绍》Pytest作为自动化测试的主力框架,如何实现本地、测试、预发、生产环境的灵活切换,本文总结了通过pytest框架实现自由环境切换的几种方法,大家可以根据需要进... 目录1.pytest-base-url2.hooks函数3.yml和fixture结论你是否也遇到过

Pyserial设置缓冲区大小失败的问题解决

《Pyserial设置缓冲区大小失败的问题解决》本文主要介绍了Pyserial设置缓冲区大小失败的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录问题描述原因分析解决方案问题描述使用set_buffer_size()设置缓冲区大小后,buf

resultMap如何处理复杂映射问题

《resultMap如何处理复杂映射问题》:本文主要介绍resultMap如何处理复杂映射问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录resultMap复杂映射问题Ⅰ 多对一查询:学生——老师Ⅱ 一对多查询:老师——学生总结resultMap复杂映射问题