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

How do I get back opencv 2.4 after installing ROS?

asked 2018-07-14 16:23:35 -0500

tilyevsky gravatar image

updated 2018-07-16 10:14:23 -0500

My system had a pre-existing opencv 2.4.9.1 installation. Then I installed ROS Melodic with the following commands:

I created /etc/apt/sources.list.d/ros-latest

apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
apt-get update
apt-get -y install ros-melodic-desktop-full
rosdep init
apt-get -y install python-rosinstall python-rosinstall-generator python-wstool build-essential

Now all of my non-ROS programs that use opencv 2.4 crash because the system default (according to pk-config --modversion opencv) is 3.2 after the ROS installation. If I try uninstalling and reinstalling opencv via apt-get, it will insist on installing 3.2 and I get the following errors:

The following packages will be REMOVED:
   libcv-dev libcvaux-dev libhighgui-dev libopencv-gpu-dev libopencv-legacy-dev
   libopencv-ocl-dev libopencv2.4-java

 dpkg: libcv-dev:amd64: dependency problems, but removing anyway as you requested:
  libopencv-dev depends on libcv-dev (= 2.4.9.1+dfsg1-2).

 (Reading database ... 502160 files and directories currently installed.)
 Removing libcv-dev:amd64 (2.4.9.1+dfsg1-2) ...
 dpkg: libhighgui-dev:amd64: dependency problems, but removing anyway as you requested:
  libopencv-dev depends on libhighgui-dev (= 2.4.9.1+dfsg1-2); however:
   Package libhighgui-dev:amd64 is to be removed.

 Removing libhighgui-dev:amd64 (2.4.9.1+dfsg1-2) ...
 dpkg: libcvaux-dev:amd64: dependency problems, but removing anyway as you requested:
  libopencv-dev depends on libcvaux-dev (= 2.4.9.1+dfsg1-2); however:
   Package libcvaux-dev:amd64 is to be removed.
--------------------------------------------------------------------------------
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libopencv-gpu-dev : Depends: libopencv-core-dev (= 2.4.9.1+dfsg1-2) but 3.2.0+dfsg-4osrf1 is to be installed
 libopencv-legacy-dev : Depends: libopencv-video-dev (= 2.4.9.1+dfsg1-2) but 3.2.0+dfsg-4osrf1 is to be installed
                        Depends: libopencv-calib3d-dev (= 2.4.9.1+dfsg1-2) but 3.2.0+dfsg-4osrf1 is to be installed
                        Depends: libopencv-ml-dev (= 2.4.9.1+dfsg1-2) but 3.2.0+dfsg-4osrf1 is to be installed
                        Depends: libopencv-highgui-dev (= 2.4.9.1+dfsg1-2) but 3.2.0+dfsg-4osrf1 is to be installed
 libopencv-ocl-dev : Depends: libopencv-calib3d-dev (= 2.4.9.1+dfsg1-2) but 3.2.0+dfsg-4osrf1 is to be installed
                     Depends: libopencv-ml-dev (= 2.4.9.1+dfsg1-2) but 3.2.0+dfsg-4osrf1 is to be installed
                     Depends: libopencv-objdetect-dev (= 2.4.9.1+dfsg1-2) but 3.2.0+dfsg-4osrf1 is to be installed
                     Depends: libopencv-highgui-dev (= 2.4.9.1+dfsg1-2) but 3.2.0+dfsg-4osrf1 is to be installed
                     Depends: libopencv-video-dev (= 2.4.9.1+dfsg1-2) but 3.2.0+dfsg-4osrf1 is to be installed
E: Unable to correct problems, you have held broken packages.

How can I cleanly restore my original opencv installation without reinstalling the OS?

Thank you in advance

EDIT: I forgot to specify that I want to ultimately install opencv 2.4 via apt-get. My software infrastructure is written in such a way that a local source build of opencv won't work.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-07-16 02:53:56 -0500

pavel92 gravatar image

This is a common compatibility issue since Kinetic. You can check out this tutorial on "Setting up ROS on Ubuntu 16.04 with OpenCV 2.4.13". I hope it helps

edit flag offensive delete link more
0

answered 2018-07-15 00:24:58 -0500

Hamid Didari gravatar image

Hi

you can uninstall opencv and reinstall it .The blew command will find any file containing opencv in the name, and will prompt you to remove it. As always, be careful when deleting things manually!

$sudo find / -name "*opencv*" -exec rm -i {} \;

then reinstalling opencv2.4

edit flag offensive delete link more

Comments

1

Please do not suggest removing files manually as a solution, especially not when those files were installed using a package manager (as the OP has done using apt). There is a good chance the command you suggest will only worsen things.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-15 04:39:09 -0500 )edit

I've reinstalled OpenCV several times - building from source a stable version and overriding currently existing installation worked well. Although uninstalling beforehand via apt is a great suggestion

Mikhail K. gravatar image Mikhail K.  ( 2018-07-16 06:37:46 -0500 )edit

I am unable to fully uninstall the packages because the 3.2 install forced dependent packages to upgrade. Even if I remove opencv 3.2, apt-get will force the 3.2 installation because existing packages depend on it. I am not sure if this is because ROS is still installed.

tilyevsky gravatar image tilyevsky  ( 2018-07-16 10:16:12 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-07-14 16:23:35 -0500

Seen: 1,366 times

Last updated: Jul 16 '18