OpenCV3 in Kinetic: technical discussion

6,147 views
Skip to first unread message

Vincent Rabaud

unread,
Nov 15, 2015, 4:43:17 PM11/15/15
to ROS Perception Special Interest Group
Hi all,

as mentioned on ROS users, it's probably time we thought seriously about OpenCV3 in ROS. Let's discuss the technicality of such a thing if it were to happen. I'll write down a few thoughts.

As far as I know, OpenCV3 is in no major distribution which most likely means we would have to package it ourselves. We could have it be a ROS package or an independent .debian package (but I doubt this is popular these days as we want a solution that works with OSX, Fedora and others).

opencv_apps is a pain to package but that is where all the cool stuff is. It cannot be compiled independently from the core as of now.

There is already an OpenCV3 package in Indigo and Jade. I recently (2 weeks ago) had to rename the libraries so that it could be installed side by side with OpenCV2 and not create problems at runtime with ROS packages compiles with OpenCV2. The headers are not renamed though but I don't think that create a problem: to compile with OpenCV 2, we should use  find_package(OpenCV 2) in CMake.

That package is patched as follows: http://wiki.ros.org/vision_opencv#OpenCV3 (to rename shared libraries and enable Qt)

It is actually easy to write code that compiles with OpenCV2 and OpenCV3: a bit more info in the transition guide: http://docs.opencv.org/master/db/dfa/tutorial_transition_guide.html#gsc.tab=0. I have done it with a few code vision packages. This would be useful for people that don't want to maintain several branches depending on the OpenCV version.

I have not tested Python in OpenCV3.



This is a technical discussion: if you have generic questions or disagree with the usage of OpenCV3, please start a new thread. Thx !

Lucas Walter

unread,
Nov 30, 2015, 6:51:28 PM11/30/15
to ROS Perception Special Interest Group
Right now when trying to build with opencv3 installed along with libopencv-dev in Ubuntu 14.04 linker errors are generated when the desire is to build with 2.4.8 (http://answers.ros.org/question/214043/use-ros-indigo-opencv3-alongside-248/ has my own question about it and there a few more semi-duplicates there).  I've tried find_package(OpenCV 2.4.8 EXACT) so it isn't wrongly satisfied by finding 3.0, and then putting OpenCV_INCLUDE_DIRS before catkin_INCLUDE_DIRS in include_directories() to make sure the 3.0 /opt/ros/jade/include/opencv isn't included first, but the linking still fails even though it is pointing to all the right 2.4.8 libraries in /usr/lib/x86...   

What does work for me is to remove ros-jade-opencv3 and instead build opencv 3 from source in a special location that isn't included by default (like /opt/ros/jade/include is), and then point find_package() at that in the package that needs 3.0 and then the other packages that want to use cv_bridge etc. with 2.4.8 don't get confused by it.  I put some protective logic around this to unset OpenCV_CONFIG_PATH and OpenCV_Dir, and restore CMAKE_PREFIX_PATH to the original setting (I think this was necessary because other non cv 3.0 dependent packages in same catkin workspace would otherwise get confused).   

Could a working ros-jade-opencv3 be more like the latter solution?  It would be ideal to have installing opencv3 not require changing CMakeLists.txt for every package that wants the default cv 2, and only the packages that have the more unusual 3.0 requirement would require extra instructions for cmake (though even that is not working, or I'm missing something else required).

My need for opencv 3.0 was the fisheye lens distortion support.

Dave Coleman

unread,
Dec 3, 2015, 5:16:59 PM12/3/15
to ROS Perception Special Interest Group
I used OpenCV3 this summer and it was great, +1 for having it in Kinetic

Vincent Rabaud

unread,
Dec 6, 2015, 1:25:08 PM12/6/15
to ros-sig-p...@googlegroups.com
@Dave, you are winning the poll so far :)

@Lucas: definitely noted and I am working on a patch: I already fixed the .so so that their name is different from the OpenCV2 ones. But the include folder needs to be different indeed: maybe something like /opt/ros/*/include/opencv3/opencv2/imgproc/ ... Not the cleanest but that'll do for now.

--
You received this message because you are subscribed to the Google Groups "ROS Perception Special Interest Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ros-sig-percept...@googlegroups.com.
To post to this group, send email to ros-sig-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ros-sig-perception/5edf9851-1a34-4c1e-9dff-6cdff38fb8be%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

G.A. vd. Hoorn - 3ME

unread,
Dec 7, 2015, 9:03:29 AM12/7/15
to ros-sig-p...@googlegroups.com
On 6-12-2015 19:24, Vincent Rabaud wrote:
> @Dave, you are winning the poll so far :)
>
> @Lucas: definitely noted and I am working on a patch: I already fixed the
> .so so that their name is different from the OpenCV2 ones. But the include
> folder needs to be different indeed: maybe something like
> /opt/ros/*/include/opencv3/opencv2/imgproc/ ... Not the cleanest but
> that'll do for now.

Having tried to help a number of users now on ROS Answers with OpenCV3
related issues, I can only +1 this proposal to add proper support for it
in ROS K.

Especially the library linking strangeness (such as those described by
Lucas) has led to some weird approaches, all of which I think are
sub-optimal.


Gijs
>> <https://groups.google.com/d/msgid/ros-sig-perception/5edf9851-1a34-4c1e-9dff-6cdff38fb8be%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .

Vincent Rabaud

unread,
Jan 27, 2016, 5:39:20 PM1/27/16
to ros-sig-p...@googlegroups.com
Hi guys, I did not keep you posted but there have been fixes a long time ago (upstream too) and if you have the 3.1 package, you should be good to go. The wiki also got updated: http://wiki.ros.org/opencv3

Bhagesh Maheshwari

unread,
Aug 1, 2017, 1:23:33 PM8/1/17
to ROS Perception Special Interest Group

Hello Everyone,

I am trying to build ROS Kinetic for Cortex A9 AMR Processor.      When i run the following command:     ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release

When compling the opencv3 packages i get following erros, can anyone help me with that?


==> Processing plain cmake package: 'opencv3'
==> Building with env: '/root/ros_catkin_ws/install_isolated/env.sh'
==> cmake /root/ros_catkin_ws/src/opencv3 -DCMAKE_INSTALL_PREFIX=/root/ros_catkin_ws/install_isolated -DCMAKE_BUILD_TYPE=Release -G Unix Makefiles in '/root/ros_catkin_ws/build_isolated/opencv3/install'
-- Detected version of GNU GCC: 52 (502)
-- FP16: Compiler support is not available
-- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found suitable version "1.2.8", minimum required is "1.2.3")
-- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found version "1.2.8")
-- Found OpenEXR: /usr/lib/arm-linux-gnueabihf/libIlmImf.so
-- checking for module 'gstreamer-base-1.0'
--   package 'gstreamer-base-1.0' not found
-- checking for module 'gstreamer-video-1.0'
--   package 'gstreamer-video-1.0' not found
-- checking for module 'gstreamer-app-1.0'
--   package 'gstreamer-app-1.0' not found
-- checking for module 'gstreamer-riff-1.0'
--   package 'gstreamer-riff-1.0' not found
-- checking for module 'gstreamer-pbutils-1.0'
--   package 'gstreamer-pbutils-1.0' not found
-- checking for module 'gstreamer-base-0.10'
--   found gstreamer-base-0.10, version 0.10.36
-- checking for module 'gstreamer-video-0.10'
--   found gstreamer-video-0.10, version 0.10.36
-- checking for module 'gstreamer-app-0.10'
--   found gstreamer-app-0.10, version 0.10.36
-- checking for module 'gstreamer-riff-0.10'
--   found gstreamer-riff-0.10, version 0.10.36
-- checking for module 'gstreamer-pbutils-0.10'
--   found gstreamer-pbutils-0.10, version 0.10.36
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- checking for module 'libavresample'
--   package 'libavresample' not found
-- checking for module 'libgphoto2'
--   package 'libgphoto2' not found
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing:  Atlas_CLAPACK_INCLUDE_DIR)
-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE)
-- Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
-- Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
-- VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.5.10.1 + Qt4
-- Found VTK ver. 5.10.1 (usefile: /usr/lib/vtk-5.10/UseVTK.cmake)
-- Caffe:   NO
-- Protobuf:   YES
-- Glog:   NO
-- freetype2:   YES
-- harfbuzz:    YES
-- Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
-- Assume that non-module dependency is available: freetype (for module opencv_freetype)
-- Assume that non-module dependency is available: harfbuzz (for module opencv_freetype)
-- Module opencv_tracking disabled because opencv_dnn dependency can't be resolved!
-- Assume that non-module dependency is available: freetype (for module opencv_freetype)
-- Assume that non-module dependency is available: harfbuzz (for module opencv_freetype)
-- freetype2:   YES
-- harfbuzz:    YES
-- checking for modules 'tesseract;lept'
--   package 'tesseract' not found
--   package 'lept' not found
-- Tesseract:   NO
-- Check contents of vgg_generated_48.i ...

It remains stuck here. 

Thanks,
Regards
Bhagesh 

Lamprecht Markus

unread,
Oct 11, 2017, 4:23:52 PM10/11/17
to ROS Perception Special Interest Group

Hey there,

I am trying to figure out how to use opencv_contrib package in ros kinetic. I have opencv3.3 and opencv_contrib-3.3 installed. I would like to use the Tracker classes thats why i need the opencv_contrib package to work. 

Does anyone know if I have to link against the contrib lib in my CMake lists file?

This is my current CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8.3)
project
(trackers)

## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options
(-std=c++11)

find_package
(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  std_msgs
)

 
find_package
(OpenCV REQUIRED)

catkin_package
()

include_directories
(
    $
{catkin_INCLUDE_DIRS}
    $
{OpenCV_INCLUDE_DIRS}
)


add_executable
(tracker src/tracker.cpp)
target_link_libraries
(tracker ${catkin_LIBRARIES})
#add_dependencies(tracker tracker_gencpp)

I tested also to link against:     ${OpenCV_LIB_COMPONENTS}
    ${OpenCV_LIBRARIES} or  ${OpenCV_LIBRARIES}

In my cpp file I just try to use the selectROI(...) method.

Happy of any ideas or suggestions
Reply all
Reply to author
Forward
0 new messages