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

相关文章

SpringBoot利用dynamic-datasource-spring-boot-starter解决多数据源问题

《SpringBoot利用dynamic-datasource-spring-boot-starter解决多数据源问题》dynamic-datasource-spring-boot-starter是一... 目录概要整体架构构想操作步骤创建数据源切换数据源后续问题小结概要自己闲暇时间想实现一个多租户平台,

VSCode中C/C++编码乱码问题的两种解决方法

《VSCode中C/C++编码乱码问题的两种解决方法》在中国地区,Windows系统中的cmd和PowerShell默认编码是GBK,但VSCode默认使用UTF-8编码,这种编码不一致会导致在VSC... 目录问题方法一:通过 Code Runner 插件调整编码配置步骤方法二:在 PowerShell

mybatis-plus分页无效问题解决

《mybatis-plus分页无效问题解决》本文主要介绍了mybatis-plus分页无效问题解决,原因是配置分页插件的版本问题,旧版本和新版本的MyBatis-Plus需要不同的分页配置,感兴趣的可... 昨天在做一www.chinasem.cn个新项目使用myBATis-plus分页一直失败,后来经过多方

VSCode配置Anaconda Python环境的实现

《VSCode配置AnacondaPython环境的实现》VisualStudioCode中可以使用Anaconda环境进行Python开发,本文主要介绍了VSCode配置AnacondaPytho... 目录前言一、安装 Visual Studio Code 和 Anaconda二、创建或激活 conda

pytorch+torchvision+python版本对应及环境安装

《pytorch+torchvision+python版本对应及环境安装》本文主要介绍了pytorch+torchvision+python版本对应及环境安装,安装过程中需要注意Numpy版本的降级,... 目录一、版本对应二、安装命令(pip)1. 版本2. 安装全过程3. 命令相关解释参考文章一、版本对

Flask解决指定端口无法生效问题

《Flask解决指定端口无法生效问题》文章讲述了在使用PyCharm开发Flask应用时,启动地址与手动指定的IP端口不一致的问题,通过修改PyCharm的运行配置,将Flask项目的运行模式从Fla... 目录android问题重现解决方案问题重现手动指定的IP端口是app.run(host='0.0.

使用DeepSeek搭建个人知识库(在笔记本电脑上)

《使用DeepSeek搭建个人知识库(在笔记本电脑上)》本文介绍了如何在笔记本电脑上使用DeepSeek和开源工具搭建个人知识库,通过安装DeepSeek和RAGFlow,并使用CherryStudi... 目录部署环境软件清单安装DeepSeek安装Cherry Studio安装RAGFlow设置知识库总

Seata之分布式事务问题及解决方案

《Seata之分布式事务问题及解决方案》:本文主要介绍Seata之分布式事务问题及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Seata–分布式事务解决方案简介同类产品对比环境搭建1.微服务2.SQL3.seata-server4.微服务配置事务模式1

mysql关联查询速度慢的问题及解决

《mysql关联查询速度慢的问题及解决》:本文主要介绍mysql关联查询速度慢的问题及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录mysql关联查询速度慢1. 记录原因1.1 在一次线上的服务中1.2 最终发现2. 解决方案3. 具体操作总结mysql

Linux搭建Mysql主从同步的教程

《Linux搭建Mysql主从同步的教程》:本文主要介绍Linux搭建Mysql主从同步的教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux搭建mysql主从同步1.启动mysql服务2.修改Mysql主库配置文件/etc/my.cnf3.重启主库my