ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You do not need to modify cv_bridge source code for this. You can point cmake to your own opencv version by defining the OpenCV_DIR variable when running catkin_make.

For example:

If you compile and install your own OpenCV version like:

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

It will be installed to /usr/local

In this case you can force catkin_make to build your workspace against this OpenCV version by running:

catkin_make -DOpenCV_DIR=/usr/local/share/OpenCV

Note that OpenCV_DIR must point to a folder with opencv-conifg.cmake file.

This will compile and link all packages in your workspace against the modified opencv version, rather than the opencv version shipped with ROS.

Alternatively, if you do not want to polute your system directories you can run

make DESTDIR=$HOME/opencv_installation install

when building and installing opencv. This will place the opencv installation in your home folder (or whereever you like) so you can comfortably remove it.

In this case you run

catkin_make -DOpenCV_DIR=$HOME/opencv_installation install/usr/local/share/OpenCV

for building the workspace.

Important note:

All libraries that are linked in an executable have to use the same opencv version, otherwise attempting to run them will cause segfaults. Packages that are installed via sudo apt-get install ros-kinetic-whatever do link against the OpenCV version shipped with ROS. If your exec uses any lib package of ROS (frequently image_transport, image_geometry, image_pipeline, cv_bridge etc) you have to check them out from github and place them in your catkin workspace alongide your own packages so these are also compiled against your modified OpenCV version.