How do I get back opencv 2.4 after installing ROS?

asked 2018-07-16 10:08:20 -0600

My debian stretch system had a pre-existing opencv 2.4.9.1 installation (installed as a debian package via apt-get, not built from source). 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 retag flag offensive close merge delete

Comments

can't you rather rebuild your programs with the 3.2 libs ?

2.4.9 is far too old, to be useful.

also note, that opencv does not maintain any prebuild packages, and in general you should just build it from (latest) src.

berak gravatar imageberak ( 2018-07-18 01:06:04 -0600 )edit