# process image with ros and python3 **Repository Path**: hwk0809/process-image-with-ros-and-python3 ## Basic Information - **Project Name**: process image with ros and python3 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-01-19 - **Last Updated**: 2022-01-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # process image with ros and python3 ### 介绍 简单的图像发布与订阅示例 用于解决python3(anaconda),ros下的图像处理问题 ### 环境配置 1. 依赖项安装 - conda 环境启动 ``` conda activate gaofen(your environment name) ``` - 在conda环境下安装必备依赖(rospkg ,opencv_python numpy pyyaml) ``` pip install numpy pyyaml rospkg opencv_python -i https://pypi.tuna.tsinghua.edu.cn/simple ``` reference : https://www.guyuehome.com/33763 - catkin tools for python python-catkin-tools is needed for catkin tool python3-dev and python3-catkin-pkg-modules is needed to build cv_bridge python3-numpy and python3-yaml is cv_bridge dependencies ros-meodic-cv-bridge is needed to install a lot of cv_bridge deps. Probaply you already have it installed. ``` sudo apt-get install python-catkin-tools python3-dev python3-catkin-pkg-modules python3-numpy python3-yaml ros-melodic-cv-bridge ``` 2. cv_bridge 单独编译 - 此时可以关掉conda环境 ``` conda deactivate ``` - 创建新的ros工作空间 ``` mkdir catkin_workspace cd catkin_workspace catkin init ``` - Instruct catkin to set cmake variables ``` catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so ``` - Instruct catkin to install built packages into install place. It is $CATKIN_WORKSPACE/install folder ``` catkin config --install ``` - Clone cv_bridge src ``` git clone https://github.com/ros-perception/vision_opencv.git src/vision_opencv ``` - Find version of cv_bridge in your repository ``` apt-cache show ros-melodic-cv-bridge | grep Version ``` 显示 Version: 1.12.8-0xenial-20180416-143935-0800 - Checkout right version in git repo. In our case it is 1.12.8 ``` cd src/vision_opencv/ git checkout 1.12.8 ``` - Build ``` cd ../../ catkin build cv_bridge ``` 3. bash加载 在~/.bashrc中加入 (工作空间换成当前的) ``` source ~/catkin_workspace/install/setup.bash source ~/catkin_workspace/devel/setup.bash ``` if you report error: "libgcc_s.so.1 must be installed for pthread_cancel to work" you can try sys.path.remove('/opt/ros/melodic/lib/python2.7/dist-packages') or conda install -c esgf libgcc-ng reference:https://stackoverflow.com/questions/49221565/unable-to-use-cv-bridge-with-ros-kinetic-and-python3