cv_bridge - Aeroclub-IITM/Plugins_setup GitHub Wiki
Cv-bridge
It is a package to convert camera image(video feed) from simulation environment which are published onto a ros topic to usable form for cv purposes. Default drone in px4 publishes to /iris/camera_red_iris/image_raw topic.We will be focussing to get output from it.In ardupilot the plugin we made will publish it to /webcam/image_raw. Type rostopic info to see more details and rosmsg show to reveal the structure of datatype.
I am using python3 and it works with opencv >2.5
Installation
You need ros plugins for gazebo inorder to publish sensor messages to ros nodes.
sudo apt install ros-melodic-gazebo-ros ros-melodic-gazebo-plugins
Install these prerequisite packages with :
sudo apt-get install python-catkin-tools python3-dev python3-numpy
sudo apt-get install python3.7-dev
Uninstall your existing opencv and install via
pip3 install opencv-contrib-python
pip install opencv-contrib-python
cd catkin_ws
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
cd src
git clone -b melodic https://github.com/ros-perception/vision_opencv.git
Type
apt-cache show ros-melodic-cv-bridge | grep Version
Output will be something like this:
Version: 1.13.0-0bionic.20200320.133849
Note the version 1.13.0
cd vision_opencv/
git checkout 1.13.0 (Your version)
cd ../../
catkin clean
rm -rf .catkin_tools
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
catkin build
Now to check if everything is correctly installed:
Type python3 in terminal and
from cv_bridge.boost.cv_bridge_boost import getCvType
If this doesn't give any errors you are good to go.
A sample program to display video feed is here.
For more information refer this site