How to force ROS using OpenCV 4 and above
In this article, I will explain the steps for forcing ROS Melodic to use a specific version of OpenCV.
Requirements
- OpenCV 4.0.1 or above installed (may be compatible with other versions)
- ROS Melodic installed (may be compatible with other versions)
- catkin_ws configured
- Ubuntu 18.04 (or above) LTS (may be compatible with other versions)
Steps
open a terminal and edit /opt/ros/melodic/share/catkin/cmake/toplevel.cmake
$ sudo nano /opt/ros/melodic/share/catkin/cmake/toplevel.cmake
Add the following lines
find_package(OpenCV 4 REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")find_package(OpenCV 4 REQUIRED)
after line 4
cmake_minimum_required(VERSION 2.8.3)
save and exit.
$ cd $HOME/catkin_ws
$ catkin_make
test the installation
$ python2
> import cv2
> cv2.__version__
'4.0.1'
Enjoy
No comments:
Post a Comment