1 | initial version |
Ok, thank you it helps me to understand what happened:
There was effectively a conflict between my system opencv version (3.2) and the sources (4.3.0) I wanted to build. I just set the CMAKE_IGNORE_PATH variable correctly to avoid this conflict, so rebuild OpenCV in my catkin_isolated_ws with:
catkin_make_isolated -DWITH_OPENCL=ON -DWITH_V4L=ON -DCMAKE_IGNORE_PATH=/usr/lib/x86_64-linux-gnu;/usr/include -DOPENCV_EXTRA_MODULES_PATH=../../../src/OpenCV/opencv_contrib/modules -DBUILD_EXAMPLES=ON --pkg OpenCV --install
Note: If someone is interested to use recent OpenCV version with ROS, you can find bellow step-by-step procedure to achieve it (this is the procedure I used to use OpenCV 4.3.0 with ros melodic which normally depends on OpenCV 3.2. Note that ROS packages installed via apt-get still depend on OpenCV 3.2. OpenCV 4.3.0 is used only for custom package build in the catkin_ws):
check no ros env is sourced
env | grep PATH
create isolated workspace and clone sources:
mkdir -p ~/catkin_isolated_ws/src cd ~/catkin_isolated_ws/src git clone https://github.com/opencv/opencv.git --branch 4.3.0 OpenCV cd OpenCV git clone https://github.com/opencv/opencv_contrib.git --branch 4.3.0 opencv_contrib
create a package.xml with the following content:
<package> <name>OpenCV</name> <version>4.3.0</version> <description>Open CV library for catkin</description> <maintainer email="your-email">your-name</maintainer> <license>your-licence</license> <buildtool_depend>cmake</buildtool_depend> <run_depend>catkin</run_depend> <export> <build_type>cmake</build_type> </export> </package>
Source ROS and init workspace:
source /opt/ros/melodic/setup.bash catkin_init_workspace
build and add the eventual opencv system's version to the cmake ignore path (CMAKE_IGNORE_PATH) (to avoid conflict with xfeatures2d):
cd ~/catkin_isolated_ws/ catkin_make_isolated -DWITH_OPENCL=ON -DWITH_V4L=ON -DCMAKE_IGNORE_PATH=/usr/lib/x86_64-linux-gnu;/usr/include -DOPENCV_EXTRA_MODULES_PATH=../../../src/OpenCV/opencv_contrib/modules -DBUILD_EXAMPLES=ON --pkg OpenCV --install
mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src source ~/catkin_isolated_ws/install_isolated/setup.bash catkin_init_workspace cd ~/catkin_ws catkin_make source ~/catkin_ws/devel/setup.bash
Note: You may have conflicts with ROS package cv_bridge, as it is linked against ros's opencv version (OpenCV 3.2), so you can:
build in the catkin_ws your own cv_bridge from sources which will then be build against OpenCV 4.3.0 (to hide native ros cv_bridge package linked to 3.2)
or convert ROS sensor_msgs::Image by your own to openCV format