在ROS kinetic中编译python3的cv_bridge

运行环境:

Anaconda3, ROS Kinetic python3.x

问题:
ROS Kinetic 自带的cv_bridge 是基于python2.7的。如果使用python3.x,需要重新编译cv_bridge.

步骤:

  1. 先把anaconda3的环境deactivate,直接进入系统自带的环境,命令:

    conda deactivate
    
  2. 在已有的ROS工作空间添加opencv_vision包,命令:

    cd catkin_ws/src
    
    catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so
    
    catkin config --install
    
    git clone https://github.com/ros-perception/vision_opencv.git 
    
    cd vision_opencv
    
    git checkout kinetic
    
    cd cv_bridge/src/
    
  3. 修改CMakeList:

    find_package(Boost REQUIRED python3) --> find_package(Boost REQUIRED python-py35)

  4. 返回catkin_ws 根目录,编译并忽略一些警告:

    catkin build cv_bridge
    

    在ROS kinetic中编译python3的cv_bridge_第1张图片

  5. 添加环境变量进bashrc:
    source install/setup.bash --extend

编译结束,可以在ROS工作空间使用Cv_bridge了。

Reference:

  1. https://stackoverflow.com/questions/49221565/unable-to-use-cv-bridge-with-ros-kinetic-and-python3?rq=1

你可能感兴趣的:(技术笔记,ubuntu,anaconda,opencv)