Incorrect configuration in OpenCV4Tegra debian packages and solution

There have been a few discussions on how to install ROS along side with OpenCV4Tegra. To install ROS packages related to opencv, the aptitude system will report libopencv-* not installed yet. Furthermore, apt-get will notice a conflict between the vanilla opencv and OoenCV4Tegra. Thus, it will suggest the user to uninstall OpenCV4Tegra in order to install opencv, which is required by those ROS packages.

https://devtalk.nvidia.com/default/topic/779315/jetson-tk1-opencv-and-ros/
http://answers.ros.org/question/202643/opencv4tegra-and-ros-howto-jetson-tk1/

After looking into this issue, I figured out the problem. The cause is that OpenCV4Tegra specifies the package relationships incorrectly. It only declares OpenCV4Tegra conflicts with the upstream opencv, but hasn’t declared OpenCV4Tegra provides the packages of opencv. Thus, once to install a package depending on opencv, the aptitude system would think that opencv has not been installed yet. To install opencv (which it should not), the aptitude asks user if to uninstall OpenCV4Tegra (since OpenCV4Tegra itself specifies a conflict with opencv).

To solve this problem, I had to manually unpack the OpenCV4Tegra debian packages, update the DEBIAN/control file, rebuild the debian packages, and then install manually with dpkg -i

Roughly, the process is as follows.

download libopencv4tegra-repo
 $ sudo dpkg -i libopencv4tegra-repo_l4t-r21_2.4.10.1_armhf.deb
 $ cd /var/opencv4tegra-repo
 $ sudo dpkg-deb -R libopencv4tegra_2.4.10.1_armhf.deb libopencv4tegra_2.4.10.1_armhf
 $ sudo vi libopencv4tegra_2.4.10.1_armhf/DEBIAN/control
    update w.r.t. the contents below
 $ sudo dpkg-deb -b libopencv4tegra_2.4.10.1_armhf libopencv4tegra_2.4.10.1_armhf_mod.deb
 $ sudo dpkg -i libopencv4tegra_2.4.10.1_armhf_mod.deb
repeat the same thing for libopencv4tegra-dev_2.4.10.1_armhf.deb
and libopencv4tegra-python_2.4.10.1_armhf.deb

The correct relationship should be as follows. (Pasting my modified DEBIAN/control files)
Hope NVIDIA can fix this issue in the next release.

libopencv4tegra_2.4.10.1_armhf/DEBIAN/control

Package: libopencv4tegra
Version: 2.4.10.1
Section: libs
Priority: optional
Architecture: armhf
Depends: libavcodec54 (>= 6:9.1-1) | libavcodec-extra-54 (>= 6:9.16), libavformat54 (>= 6:9.1-1), libavutil52 (>= 6:9.1-1), libc6 (>= 2.15), libgcc1 (>= 1:4.4.0), libglib2.0-0 (>= 2.31.8), libgtk2.0-0 (>= 2.8.0), libjasper1, libjpeg8 (>= 8c), libpng12-0 (>= 1.2.13-4), libstdc++6 (>= 4.6), libswscale2 (>= 6:9.1-1), libtiff5 (>= 4.0.3), zlib1g (>= 1:1.1.4), cuda-cudart-6-5, cuda-npp-6-5, cuda-cufft-6-5
Homepage: http://opencv.org
Conflicts:libopencv-calib3d2.4,libopencv-contrib2.4,libopencv-core2.4,libopencv-features2d2.4,libopencv-flann2.4,libopencv-gpu2.4,libopencv-highgui2.4,libopencv-imgproc2.4,libopencv-legacy2.4,libopencv-ml2.4,libopencv-objdetect2.4,libopencv-ocl2.4,libopencv-photo2.4,libopencv-stitching2.4,libopencv-superres2.4,libopencv-ts2.4,libopencv-video2.4,libopencv-videostab2.4
Provides:libopencv-calib3d2.4,libopencv-contrib2.4,libopencv-core2.4,libopencv-features2d2.4,libopencv-flann2.4,libopencv-gpu2.4,libopencv-highgui2.4,libopencv-imgproc2.4,libopencv-legacy2.4,libopencv-ml2.4,libopencv-objdetect2.4,libopencv-ocl2.4,libopencv-photo2.4,libopencv-stitching2.4,libopencv-superres2.4,libopencv-ts2.4,libopencv-video2.4,libopencv-videostab2.4
Replaces:libopencv-calib3d2.4,libopencv-contrib2.4,libopencv-core2.4,libopencv-features2d2.4,libopencv-flann2.4,libopencv-gpu2.4,libopencv-highgui2.4,libopencv-imgproc2.4,libopencv-legacy2.4,libopencv-ml2.4,libopencv-objdetect2.4,libopencv-ocl2.4,libopencv-photo2.4,libopencv-stitching2.4,libopencv-superres2.4,libopencv-ts2.4,libopencv-video2.4,libopencv-videostab2.4
Installed-Size: 239054
Maintainer: Alban Douillet <adouillet@nvidia.com>
Description: OpenCV4Tegra
 Tegra optimized Open Computer Vision Library

libopencv4tegra-dev_2.4.10.1_armhf/DEBIAN/control

Package: libopencv4tegra-dev
Version: 2.4.10.1
Section: libdevel
Priority: optional
Architecture: armhf
Depends: libopencv4tegra (= 2.4.10.1), libc6 (>= 2.4), libgcc1 (>= 1:4.4.0), libstdc++6 (>= 4.4.0), cuda-cudart-dev-6-5, cuda-npp-dev-6-5, cuda-cufft-dev-6-5
Homepage: http://opencv.org
Conflicts:libopencv-calib3d-dev,libopencv-contrib-dev,libopencv-core-dev,libopencv-dev,libopencv-features2d-dev,libopencv-flann-dev,libopencv-gpu-dev,libopencv-highgui-dev,libopencv-imgproc-dev,libopencv-legacy-dev,libopencv-ml-dev,libopencv-objdetect-dev,libopencv-ocl-dev,libopencv-photo-dev,libopencv-stitching-dev,libopencv-superres-dev,libopencv-ts-dev,libopencv-video-dev,libopencv-videostab-dev
Provides:libopencv-calib3d-dev,libopencv-contrib-dev,libopencv-core-dev,libopencv-dev,libopencv-features2d-dev,libopencv-flann-dev,libopencv-gpu-dev,libopencv-highgui-dev,libopencv-imgproc-dev,libopencv-legacy-dev,libopencv-ml-dev,libopencv-objdetect-dev,libopencv-ocl-dev,libopencv-photo-dev,libopencv-stitching-dev,libopencv-superres-dev,libopencv-ts-dev,libopencv-video-dev,libopencv-videostab-dev
Replaces:libopencv-calib3d-dev,libopencv-contrib-dev,libopencv-core-dev,libopencv-dev,libopencv-features2d-dev,libopencv-flann-dev,libopencv-gpu-dev,libopencv-highgui-dev,libopencv-imgproc-dev,libopencv-legacy-dev,libopencv-ml-dev,libopencv-objdetect-dev,libopencv-ocl-dev,libopencv-photo-dev,libopencv-stitching-dev,libopencv-superres-dev,libopencv-ts-dev,libopencv-video-dev,libopencv-videostab-dev
Installed-Size: 5275
Maintainer: Alban Douillet <adouillet@nvidia.com>
Description: OpenCV4Tegra
 Development files for Tegra optimized Open Source Computer Vision Library

libopencv4tegra-python_2.4.10.1_armhf/DEBIAN/control

Package: libopencv4tegra-python
Version: 2.4.10.1
Section: python
Priority: optional
Architecture: armhf
Depends: libopencv4tegra (= 2.4.10.1), libc6 (>= 2.4), libgcc1 (>= 1:4.4.0), libpython2.7 (>= 2.7), libstdc++6 (>= 4.4.0), python2.7
Homepage: http://opencv.org
Conflicts:python-opencv
Replaces:python-opencv
Provides:python-opencv
Installed-Size: 900
Maintainer: Alban Douillet <adouillet@nvidia.com>
Description: OpenCV4Tegra
 Python bindings for Tegra optimized Open Source Computer Vision Library

I’m going to test your solution as soon as possible. Great work!!!

@davy_wb, great work man, thanks a ton.

Although I can safely use cv_bridge, I am still not able to install packages like rqt_image_view. The error I get is,

ros-indigo-rqt-image-view : Depends: libopencv-core2.4 but it is not going to be installed
                             Depends: libopencv-imgproc2.4 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Not sure how I should be tacking this. Any suggestions?

@Kelkar, you don’t need to install the cracked cv_bridge. Uninstall it, as well as the vanilla opencv4tegra. Then following my steps to build and install the “cracked” opencv4tegra. Then libopencv-core2.4 etc should be satisfied.

I tried following your instructions, but cannot seem to successfully re-install ros using apt-get ros-indigo- (which are all python-opencv related possibly)

I get the same common error, hopefully you can help:

cmd:
$ sudo apt-get install ros-indigo-freenect-launch
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 ros-indigo-cv-bridge : Depends: python-opencv but it is not going to be installed
 ros-indigo-freenect-launch : Depends: ros-indigo-freenect-camera but it is not going to be installed
                              Depends: ros-indigo-image-proc but it is not going to be installed
                              Depends: ros-indigo-rgbd-launch bu tit is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

All dependencies listed above have the same root dependency issue: python-opencv. I tried apt-get -f install, which then tries to unpack “python-opencv (2.4.8+dfsg1-2ubuntu1) …” but fails.

dpkg: error processing archive /var/cache/apt/archives/python-opencvy_2.4.8+dfsg1-2ubuntu1_armhf.deb (--unpack):
 trying to overwrite '/usr/lib/python2.7/dist-packages/cv2.so', which is also in package libopencv4tegra-dev 2.4.10.1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/python-opencv_2.4.8+dfsg1-2ubuntu1_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Were there any pre-requisites to performing your modded package install that would cause this if missed?

Thanks for your help

eh… I think I got past the above occurrence, but installing ros-indigo- seems to still removed all libopencv4tegra, even after performing your mentioned fix. (as I see "removing libopencv4tegra-python and libopencv4tegra).

EDIT: Do you have to completely remove any opencv libraries? If so, how would one do this?

For example, to install the _mod packages I had notice the install was stopped because ‘libopencv-calib3d-dev’ was installed. So I removed just ‘libopencv-calib3d-dev’ and I was able to install the libopencv4tegra modded deb. However, I still run into the issue where installing something from ros that needs libopencv or python-opencv seems to want to remove libopencv4tegra

EDIT # 2:
I did COMPLETELY remove all python and opencv…re-performed the suggested ‘fix’ at the beginning of this post, but still other packages insist on removing libopencv4tegra…

Hello,

I’ve tried to make the steps explained above but i have conflicts with opencv libs:

ubuntu@tegra-ubuntu:~ cd OpenCV4Tegra/ ubuntu@tegra-ubuntu:~/OpenCV4Tegra sudo dpkg -i libopencv4tegra-repo_l4t-r21_2.4.10.1_armhf.deb
(Reading database … 183526 files and directories currently installed.)
Preparing to unpack libopencv4tegra-repo_l4t-r21_2.4.10.1_armhf.deb …
Unpacking libopencv4tegra-repo (2.4.10.1) over (2.4.10.1) …
Setting up libopencv4tegra-repo (2.4.10.1) …
ubuntu@tegra-ubuntu:~/OpenCV4Tegra$ cd /var/opencv4tegra-repo
ubuntu@tegra-ubuntu:/var/opencv4tegra-repo$ sudo dpkg-deb -R libopencv4tegra_2.4.10.1_armhf.deb libopencv4tegra_2.4.10.1_armhf
ubuntu@tegra-ubuntu:/var/opencv4tegra-repo$ sudo gedit libopencv4tegra_2.4.10.1_armhf/DEBIAN/control
error: XDG_RUNTIME_DIR not set in the environment.

(gedit:9262): Gtk-WARNING **: cannot open display:
ubuntu@tegra-ubuntu:/var/opencv4tegra-repo$ sudo nano libopencv4tegra_2.4.10.1_armhf/DEBIAN/control
ubuntu@tegra-ubuntu:/var/opencv4tegra-repo$ sudo dpkg-deb -b libopencv4tegra_2.4.10.1_armhf libopencv4tegra_2.4.10.1_armhf_mod.deb
dpkg-deb: building package libopencv4tegra' in libopencv4tegra_2.4.10.1_armhf_mod.deb’.
ubuntu@tegra-ubuntu:/var/opencv4tegra-repo$ sudo dpkg -i libopencv4tegra_2.4.10.1_armhf_mod.deb
Selecting previously unselected package libopencv4tegra.
dpkg: considering removing libopencv-calib3d2.4:armhf in favour of libopencv4tegra …
dpkg: no, cannot proceed with removal of libopencv-calib3d2.4:armhf (–auto-deconfigure will help):
libopencv-legacy2.4:armhf depends on libopencv-calib3d2.4 (= 2.4.8+dfsg1-2ubuntu1)
libopencv-calib3d2.4:armhf is to be removed.

dpkg: regarding libopencv4tegra_2.4.10.1_armhf_mod.deb containing libopencv4tegra:
libopencv4tegra conflicts with libopencv-calib3d2.4
libopencv-calib3d2.4:armhf (version 2.4.8+dfsg1-2ubuntu1) is present and installed.

dpkg: error processing archive libopencv4tegra_2.4.10.1_armhf_mod.deb (–install):
conflicting packages - not installing libopencv4tegra
Errors were encountered while processing:
libopencv4tegra_2.4.10.1_armhf_mod.deb
ubuntu@tegra-ubuntu:/var/opencv4tegra-repo$

Does anyone had the same problem?

It sounds like you are using a remote login like ssh and not natively on the Jetson…in which case it wants to display on your host rather than on Jetson. If you are physically logged in directly to Jetson, is the error any different?

great job. solve my problem in some way.

I guess it’s not actual any more for versions 2.4.13-17-g5317135 and higher

nvidia@tegra-ubuntu:~/development/tmp$ dpkg -s libopencv4tegra-dev
Package: libopencv4tegra-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 5990
Maintainer: VisionWorks developers visionworks-package@nvidia.com
Architecture: arm64
Version: 2.4.13-17-g5317135
Replaces: libopencv-dev, libopencv-calib3d-dev, libopencv-contrib-dev, libopencv-core-dev, libopencv-features2d-dev, libopencv-flann-dev, libopencv-gpu-dev, libopencv-highgui-dev, libopencv-imgproc-dev, libopencv-legacy-dev, libopencv-ml-dev, libopencv-objdetect-dev, libopencv-photo-dev, libopencv-stitching-dev, libopencv-superres-dev, libopencv-ts-dev, libopencv-video-dev, libopencv-videostab-dev, libhighgui-dev, libcv-dev, libcvaux-dev
Provides: libopencv-dev, libopencv-calib3d-dev, libopencv-contrib-dev, libopencv-core-dev, libopencv-features2d-dev, libopencv-flann-dev, libopencv-gpu-dev, libopencv-highgui-dev, libopencv-imgproc-dev, libopencv-legacy-dev, libopencv-ml-dev, libopencv-objdetect-dev, libopencv-photo-dev, libopencv-stitching-dev, libopencv-superres-dev, libopencv-ts-dev, libopencv-video-dev, libopencv-videostab-dev, libhighgui-dev, libcv-dev, libcvaux-dev
Depends: libopencv4tegra (= 2.4.13-17-g5317135), libc6 (>= 2.17), libgcc1 (>= 1:3.0), libstdc++6 (>= 5.2), cuda-cudart-dev-8-0 | nvidia-cuda-dev (>= 8.0), cuda-npp-dev-8-0 | nvidia-cuda-dev (>= 8.0), cuda-cufft-dev-8-0 | nvidia-cuda-dev (>= 8.0), libtbb-dev
Conflicts: libopencv-dev, libopencv-calib3d-dev, libopencv-contrib-dev, libopencv-core-dev, libopencv-features2d-dev, libopencv-flann-dev, libopencv-gpu-dev, libopencv-highgui-dev, libopencv-imgproc-dev, libopencv-legacy-dev, libopencv-ml-dev, libopencv-objdetect-dev, libopencv-photo-dev, libopencv-stitching-dev, libopencv-superres-dev, libopencv-ts-dev, libopencv-video-dev, libopencv-videostab-dev, libhighgui-dev, libcv-dev, libcvaux-dev
Description: Development files for Tegra optimized Open Source Computer Vision Library
OpenCV (Open Source Computer Vision Library) is an open source computer
vision and machine learning software library. OpenCV was built to provide
a common infrastructure for computer vision applications and to accelerate
the use of machine perception in the commercial products.
.
OpenCV4Tegra is a version of OpenCV containing proprietary NVIDIA algorithms
and optimizations.
Homepage: http://opencv.org

nvidia@tegra-ubuntu:~/development/tmp$ dpkg -s libopencv4tegra
Package: libopencv4tegra
Status: install ok installed
Priority: optional
Section: libs
Installed-Size: 245195
Maintainer: VisionWorks developers visionworks-package@nvidia.com
Architecture: arm64
Version: 2.4.13-17-g5317135
Replaces: opencv-data, libopencv-calib3d2.4v5, libopencv-contrib2.4v5, libopencv-core2.4v5, libopencv-features2d2.4v5, libopencv-flann2.4v5, libopencv-gpu2.4v5, libopencv-highgui2.4v5, libopencv-imgproc2.4v5, libopencv-legacy2.4v5, libopencv-ml2.4v5, libopencv-objdetect2.4v5, libopencv-photo2.4v5, libopencv-stitching2.4v5, libopencv-superres2.4v5, libopencv-ts2.4v5, libopencv-video2.4v5, libopencv-videostab2.4v5
Provides: opencv-data, libopencv-calib3d2.4v5, libopencv-contrib2.4v5, libopencv-core2.4v5, libopencv-features2d2.4v5, libopencv-flann2.4v5, libopencv-gpu2.4v5, libopencv-highgui2.4v5, libopencv-imgproc2.4v5, libopencv-legacy2.4v5, libopencv-ml2.4v5, libopencv-objdetect2.4v5, libopencv-photo2.4v5, libopencv-stitching2.4v5, libopencv-superres2.4v5, libopencv-ts2.4v5, libopencv-video2.4v5, libopencv-videostab2.4v5
Depends: cuda-cudart-8-0, cuda-cufft-8-0, cuda-npp-8-0, libavcodec-ffmpeg56 (>= 7:2.4) | libavcodec-ffmpeg-extra56 (>= 7:2.4), libavformat-ffmpeg56 (>= 7:2.4), libavutil-ffmpeg54 (>= 7:2.4), libc6 (>= 2.17), libgcc1 (>= 1:4.0), libglib2.0-0 (>= 2.31.8), libgtk2.0-0 (>= 2.8.0), libjasper1, libjpeg8 (>= 8c), libpng12-0 (>= 1.2.13-4), libstdc++6 (>= 5.2), libswscale-ffmpeg3 (>= 7:2.4), libtbb2, libtiff5 (>= 4.0.3), zlib1g (>= 1:1.1.4), cuda-cudart-8-0 | libcudart8.0, cuda-npp-8-0 | libnppc8.0, cuda-npp-8-0 | libnppi8.0, cuda-npp-8-0 | libnpps8.0, cuda-cufft-8-0 | libcufft8.0
Conflicts: opencv-data, libopencv-calib3d2.4v5, libopencv-contrib2.4v5, libopencv-core2.4v5, libopencv-features2d2.4v5, libopencv-flann2.4v5, libopencv-gpu2.4v5, libopencv-highgui2.4v5, libopencv-imgproc2.4v5, libopencv-legacy2.4v5, libopencv-ml2.4v5, libopencv-objdetect2.4v5, libopencv-photo2.4v5, libopencv-stitching2.4v5, libopencv-superres2.4v5, libopencv-ts2.4v5, libopencv-video2.4v5, libopencv-videostab2.4v5
Description: Tegra optimized Open Computer Vision Library
OpenCV (Open Source Computer Vision Library) is an open source computer
vision and machine learning software library. OpenCV was built to provide
a common infrastructure for computer vision applications and to accelerate
the use of machine perception in the commercial products.
.
OpenCV4Tegra is a version of OpenCV containing proprietary NVIDIA algorithms
and optimizations.
Homepage: http://opencv.org

nvidia@tegra-ubuntu:~/development/tmp$ dpkg -s libopencv4tegra-repo
Package: libopencv4tegra-repo
Status: install ok installed
Priority: extra
Section: devel
Maintainer: VisionWorks developers visionworks-package@nvidia.com
Architecture: arm64
Version: 2.4.13-17-g5317135
Conffiles:
/etc/apt/sources.list.d/libopencv4tegra-repo.list d1cbe558f0ebc1d732109a3f15bc386c
Description: Repository with Tegra optimized Open Source Computer Vision Library
OpenCV (Open Source Computer Vision Library) is an open source computer
vision and machine learning software library. OpenCV was built to provide
a common infrastructure for computer vision applications and to accelerate
the use of machine perception in the commercial products.
.
OpenCV4Tegra is a version of OpenCV containing proprietary NVIDIA algorithms
and optimizations.