• ROS-melodic安装Kinect V2步骤和测试及问题解决


    要想Kinect V2在ROS上运行。
    需要libfreenect2 和 iai_kinect2两个驱动

    再用摄像头前,要确保你安装opencv  ,我用的版本是opencv-3.4.3

    安装教程网上比较多,这里就不啰嗦了

    一.首先安装libfreenect2

    1.安装依赖

    sudo apt-get install build-essential cmake pkg-config libturbojpeg libjpeg-turbo8-dev mesa-common-dev freeglut3-dev libxrandr-dev libxi-dev 
    sudo apt-get install libglfw3-dev
    sudo apt-get install libopenni2-dev
    sudo apt-get install libusb-dev
    sudo apt-get install libturbojpeg0-dev

    2.开始安装

    下载源码

    git clone https://github.com/OpenKinect/libfreenect2.git

    安装

    cd libfreenect2
    mkdir build 
    cd build
    cmake ..
    make
    sudo make install

    设定udev路径

    #设定udev rules:(填好自己libfreenect2的路径)
    sudo cp libfreenect2/platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/

    3.测试

    #运行build目录下的例子
    ./bin/Protonect

    二.安装iai_kinect2驱动

    1,首先进入ROS的工作空间下载源码

    cd ~/catkin_ws/src/
    git clone https://github.com/code-iai/iai_kinect2.git
    cd iai_kinect2
    rosdep install -r --from-paths .

    在这一步rosdep install -r --from-paths .会报错

    解决方法

    rosdep install --from-paths ~/catkin_ws/src/iai_kinect2 --ignore-src -r

    然后开始编译

    cd ~/catkin_ws           
    catkin_make -DCMAKE_BUILD_TYPE="Release"      #编译
    
    #如果没有添加永久环境变量,则每次都需要source以下
    source ~/catkin_ws/devel/setup.bash 
    #添加ros永久环境变量
    echo "source ~/catkin_ws/devel/setup.sh" >> ~/.bashrc

    我在编译时候出现了问题,如下

     
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp: In member function ‘void Kinect2Bridge::initCompression(int32_t, int32_t, bool)’:
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:465:28: error: ‘CV_IMWRITE_JPEG_QUALITY’ was not declared in this scope
         compressionParams[0] = CV_IMWRITE_JPEG_QUALITY;
                                ^~~~~~~~~~~~~~~~~~~~~~~
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:465:28: note: suggested alternative: ‘CV_WRITE_SEQ_ELEM’
         compressionParams[0] = CV_IMWRITE_JPEG_QUALITY;
                                ^~~~~~~~~~~~~~~~~~~~~~~
                                CV_WRITE_SEQ_ELEM
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:467:28: error: ‘CV_IMWRITE_PNG_COMPRESSION’ was not declared in this scope
         compressionParams[2] = CV_IMWRITE_PNG_COMPRESSION;
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:469:28: error: ‘CV_IMWRITE_PNG_STRATEGY’ was not declared in this scope
         compressionParams[4] = CV_IMWRITE_PNG_STRATEGY;
                                ^~~~~~~~~~~~~~~~~~~~~~~
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:470:28: error: ‘CV_IMWRITE_PNG_STRATEGY_RLE’ was not declared in this scope
         compressionParams[5] = CV_IMWRITE_PNG_STRATEGY_RLE;
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp: In member function ‘void Kinect2Bridge::initCompression(int32_t, int32_t, bool)’:
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:465:28: error: ‘CV_IMWRITE_JPEG_QUALITY’ was not declared in this scope
         compressionParams[0] = CV_IMWRITE_JPEG_QUALITY;
                                ^~~~~~~~~~~~~~~~~~~~~~~
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:465:28: note: suggested alternative: ‘CV_WRITE_SEQ_ELEM’
         compressionParams[0] = CV_IMWRITE_JPEG_QUALITY;
                                ^~~~~~~~~~~~~~~~~~~~~~~
                                CV_WRITE_SEQ_ELEM
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:467:28: error: ‘CV_IMWRITE_PNG_COMPRESSION’ was not declared in this scope
         compressionParams[2] = CV_IMWRITE_PNG_COMPRESSION;
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:469:28: error: ‘CV_IMWRITE_PNG_STRATEGY’ was not declared in this scope
         compressionParams[4] = CV_IMWRITE_PNG_STRATEGY;
                                ^~~~~~~~~~~~~~~~~~~~~~~
    /home/zztsj/catkin_ws/src/iai_kinect2/kinect2_bridge/src/kinect2_bridge.cpp:470:28: error: ‘CV_IMWRITE_PNG_STRATEGY_RLE’ was not declared in this scope
         compressionParams[5] = CV_IMWRITE_PNG_STRATEGY_RLE;
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~

    查阅资料好像是版本不对应的问题,用oopencv2可以成功,用opencv3的话需要指定安装路径,我的是默认安装的,就出现了一系列没有定义的问题

    我的解决方法,没有安装过opencv3,而是改了一种定义方式

    将CV_IMWRITE_JPEG_QUALITY;
    改为cv::IMWRITE_JPEG_QUALITY;

    剩下的改法相同,改完就编译好了,

    2.测试

    roslaunch kinect2_bridge kinect2_bridge.launch    #运行kinect2自带的launch
    
    rosrun kinect2_viewer kinect2_viewer              #查看运行结果。

    到此,驱动就安装完成了。 

  • 相关阅读:
    《易中天中华史》——易中天
    《易中天品三国》——易中天
    Excel 实现多列文本合并/合并单元格内容 的三种方法
    Excel函数OFFSET的用法、举例
    【转】链接服务器"(null)"的 OLE DB 访问接口 "Microsoft.Jet.OLEDB.4.0" 返回了消息 "未指定的错误"。+SQL Server Management Studio中访问EXCEL 2007(XLSX)文件的方法
    SQL 2005启用组件Ad Hoc Distributed Queries
    FTP 550 Permission denied 只能建文件夹,没法删除及上传文件的原因说明
    Access中"''80004005''"操作必须使用一个可更新的查询"错误的解决办法
    修改 打开方式为Excel
    VMware10新建虚拟机
  • 原文地址:https://www.cnblogs.com/tanshengjiang/p/13967940.html
Copyright © 2020-2023  润新知