[SOLVED] Correct way to switch from OpenCV 2.4 to OpenCV 3.3

Hello,

I am trying to find the correct way to uninstall OpenCV 2.4 (default of Netrunner and Debian), and install OpenCV 3.3.

My method so far:

  1. Install Netrunner (keeping default repos) and update + upgrade system.
  2. Uninstall everything starting with “libopencv”:
sudo apt purge libopencv*
  1. Mark as manually installed anything which was unmarked during step 1).
  2. Install OpenCV 3.3.0 dependencies.
  3. Build OpenCV 3.3.0 from source.
  4. Install OpenCV 3.3.0 from source build.
sudo make install

The method works, and I can use OpenCV 3.3 in my CMake projects, which is what I wanted.

However, I am not sure if I have done something bad to my installation during step 1).
Specifically, running “sudo apt dist-upgrade --fix-policy”
now results in the following output:

The following NEW packages will be installed:                                                                                                                                                                                      
  appstream bsd-mailx exim4-base exim4-config exim4-daemon-light ffmpeg ffmpegthumbnailer ffmpegthumbs frei0r-plugins gnupg-l10n gstreamer1.0-libav gstreamer1.0-plugins-bad kdenlive laptop-detect libatm1 libav-tools            
  libavdevice57 libavfilter6 libfarstream-0.2-5 libffmpegthumbnailer4v5 liblockfile-bin liblockfile1 libmlt++3 libmlt6 libopencv-calib3d2.4v5 libopencv-contrib2.4v5 libopencv-core2.4v5 libopencv-features2d2.4v5                 
  libopencv-flann2.4v5 libopencv-gpu2.4v5 libopencv-highgui2.4-deb0 libopencv-imgproc2.4v5 libopencv-legacy2.4v5 libopencv-ml2.4v5 libopencv-objdetect2.4v5 libopencv-ocl2.4v5 libopencv-photo2.4v5 libopencv-stitching2.4v5       
  libopencv-superres2.4v5 libopencv-ts2.4v5 libopencv-video2.4v5 libopencv-videostab2.4v5 libpurple-bin libpurple0 melt muon-notifier muon-updater pidgin plasma-discover plasma-discover-common plasma-discover-private           
  plasma-discover-updater publicsuffix qml-module-org-kde-kirigami2 smplayer smplayer-l10n smplayer-themes virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11 vokoscreen

Can you give me any hints on how to keep the command from reinstalling OpenCV 2.4 (besides not using --fix-policy)?
Perhaps you know which policy I’ve messed up, or can show me how I can find out myself.

I would like to be able to call “sudo apt dist-upgrade --fix-policy” later on for various reasons, without accidentally reinstalling OpenCV 2.4.

Thanks,
Mikael

PS: On a side note, do you think I could have both versions of OpenCV installed without conflict? If so, can OpenCV 3.3.0 be default?

Edit: By using apt-cache rdepends on a number of packages, I found out that some packages depend on OpenCV 2.4.
So I will try to install OpenCV 3.3 side-by-side with OpenCV 2.4. If I succeed, I will post my findings :slight_smile:

Edit2:
I found a very simple way.
Leave OpenCV 2.4 installed.
Build OpenCV 3.3, install to a custom directory using the CMAKE_INSTALL_PREFIX parameter.
Set environment variable OpenCV_DIR to the share/OpenCV folder of said custom directory.
This lets CMake find OpenCV 3.3. If I don’t want that, I either don’t set OpenCV_DIR, or I unset it in CMakeLists.txt.