Jetson TK1: OpenCV and ROS

Hi,

I’m setting up my Jetson TK1 to work with ROS and OpenCV 4 Tegra. Right now I’m facing a tiny problem:

I have installed the grinch kernel + Cuda4Tegra + OpenCV4Tegra + OpenCV4Tegra-dev. Everything went smoothly until I installed a ros package called “ros-indigo-cv-bridge”, which is useful to translate ROS’ image messages to OpenCV’s matrix format. I broke my package system when trying to install it!

Ros-indigo-cv-bridge depends heavily on libopencv-dev and it seems that OpenCV4Tegra-dev is of no use when apt-get tries to install all dependencies. I get the following error from apt-get, for every component included in libopencv-dev:

dpkg: error processing archive /var/cache/apt/archives/libopencv-core-dev_2.4.8+dfsg1-2ubuntu1_armhf.deb (--unpack):
 trying to overwrite '/usr/include/opencv2/core/wimage.hpp', which is also in package libopencv4tegra-dev 2.4.8.2

So, my guess is, there must be a way to make apt-get to look into Opencv4Tegra to solve all dependencies when trying to install Ros-Indigo-CV-Bridge, but I don’t know how to do it. Or, the apt-get result is completely misleading.

Any suggestions would be appreciated.

Don’t know if you solved this…but I ran in to the same trouble here when trying ROS/CV with the Tegra version of OpenCV. I ended up creating a “fake” package (using equivs) that tells apt that libopencv + libopencv-dev is already installed. This worked nicely for me and now I am running the tegra-version of opencv under ROS. Very nice…but a little hackish solution to the problem!

Note that this might be a good trick for many other opencv-dependent packages that you want to test under the Jetson TK1…

Anyhow, this was the contents of the input file for “equivs-build”:

Section: misc
Priority: optional
Standards-Version: 3.9.2

Package: libopencv-dev-dummy
Version: 2.4.8
Maintainer: yourname <<a href="mailto:yourname@somemail">yourname@somemail</a>>
Provides: libopencv-calib3d-dev, libopencv-calib3d2.4, 
	libopencv-contrib-dev, libopencv-contrib2.4, 
	libopencv-core-dev, libopencv-core2.4,
	libopencv-dev,
	libopencv-facedetect-dev, libopencv-facedetect2.4, 
	libopencv-features2d-dev, libopencv-features2d2.4, 
	libopencv-flann-dev, libopencv-flann2.4, 
	libopencv-gpu-dev, libopencv-gpu2.4, 
	libopencv-highgui-dev, libopencv-highgui2.4, 
	libopencv-imgproc-dev, libopencv-imgproc2.4,
	libopencv-imuvstab-dev, libopencv-imuvstab2.4,
	libopencv-legacy-dev, libopencv-legacy2.4, 
	libopencv-ml-dev, libopencv-ml2.4,
	libopencv-objdetect-dev, libopencv-objdetect2.4, 
	libopencv-ocl-dev, libopencv-ocl2.4, 
	libopencv-photo-dev, libopencv-photo2.4,
	libopencv-softcascade-dev, libopencv-softcascade2.4,
	libopencv-stitching-dev, libopencv-stitching2.4, 
	libopencv-superres-dev,	libopencv-superres2.4, 
	libopencv-video-dev, libopencv-video2.4, 
	libopencv-videostab-dev, libopencv-videostab2.4,
	libopencv-vstab, libopencv-vstab2.4

Description: empty dummy package
   no description

This will get you a “dummy-package” that you simply install using “sudo dpkg -i libopencv-dev-dummy_2.4.8_all.deb”. After this, all other packages that depend on opencv will install without trying to install the SW-version of opencv. Make sure you have installed the CUDA version before running this…

Note that the CUDA-version of OpenCV does not contain the nonfree package, i.e. SURF etc. Have not tried to solve that yet…

I’m going to install OpenCV under ROS and I’m happy to know that it is possible… but I did not understand very well how you created the dummy “deb”.

I really never created a “deb” so this may be a bit hard to understand…

Thank you
Walter

PS I think that I could publish a guide about this process in the blog of my robotic project (http://myzharbot.robot-home.it), but I want to be sure to publish correct information…

I am a bit late to this thread but I tried the method Stefan posted.

I get this error

dpkg: regarding libopencv-dev-dummy_2.4.8_all.deb containing libopencv-dev-dummy:
 libopencv4tegra conflicts with libopencv-calib3d-dev
  libopencv-dev-dummy provides libopencv-calib3d-dev and is to be installed.

dpkg: error processing archive libopencv-dev-dummy_2.4.8_all.deb (--install):
 conflicting packages - not installing libopencv-dev-dummy

I thought increasing the version no might help but it doesn’t.

I tried using --force-conflicts option

$sudo dpkg --force-conflicts -i libopencv-dev-dummy_2.4.8_all.deb
$sudo apt-get install ros-indigo-image-proc
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 libopencv4tegra : Conflicts: libopencv-calib3d-dev
                   Conflicts: libopencv-calib3d2.4
                   Conflicts: libopencv-contrib-dev
                   Conflicts: libopencv-contrib2.4
                   .
                   .
                   .
                   Conflicts: libopencv-video2.4
                   Conflicts: libopencv-videostab-dev
                   Conflicts: libopencv-videostab2.4
 libopencv4tegra-dev : Conflicts: libopencv-calib3d-dev
                       Conflicts: libopencv-calib3d2.4
                       Conflicts: libopencv-contrib-dev
                       Conflicts: libopencv-contrib2.4
                      .
                      .
                      .
                       Conflicts: libopencv-video2.4
                       Conflicts: libopencv-videostab-dev
                       Conflicts: libopencv-videostab2.4
 ros-indigo-image-pipeline : Depends: ros-indigo-camera-calibration but it is not going to be installed
                             Depends: ros-indigo-depth-image-proc but it is not going to be installed
                             Depends: ros-indigo-image-rotate but it is not going to be installed
                             Depends: ros-indigo-image-view but it is not going to be installed
                             Depends: ros-indigo-stereo-image-proc but it is not going to be installed
 ros-indigo-image-proc : Depends: ros-indigo-cv-bridge but it is not going to be installed
                         Depends: ros-indigo-image-geometry but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
$sudo apt-get -f install
The following packages will be REMOVED:
  libopencv-dev-dummy

So in the end, we are at where we started from.
Can you help me?

Thanks
Sezal

I faced exactly the same problem and I tried to change the version too (2.4.10.2), but I have the same error message.

Anyone solved it?

I saw this on a website that somebody is using to document their ROS installation:

“It looks like the CMake files for the TK1-optimized OpenCV libraries don’t set OpenCV_INCLUDE_DIRS properly, which causes cv_bridge to pass these bad include directories on to its downstream dependencies.”

From: http://namniart.com/jetson-tk1/ubuntu/2014/05/20/ROS-on-Jetson-part2.html

If somebody can either figure out how to fix the equivs issue or how to fix the CMake file issue, please let me know!! I would love to have ROS working on my Jetson board!

I want to try this:

  1. install opencv4tegra
  2. make a copy of lib and include in a temp folder
  3. install ros-indigo-cv-bridge that will remove the current installation of opencv4tegra and opencv4tegra-dev
  4. overwrite the “new” libraries with the one I saved from opencv4tegra

Do you think that this method can work?

I want to try this:

  1. install opencv4tegra
  2. make a copy of lib and include in a temp folder
  3. install ros-indigo-cv-bridge that will remove the current installation of opencv4tegra and opencv4tegra-dev
  4. overwrite the “new” libraries with the one I saved from opencv4tegra

Do you think that this method can work?

I received a possible solution from a gui on ROS answer website:
http://answers.ros.org/question/202643/opencv4tegra-and-ros-howto-jetson-tk1/?answer=202875#post-id-202875

You can get the cv-bridge.deb i modified here http://l0g1x.pl/?p=39

Just do

sudo dpkg -i <file>.deb

I did this fix on a fresh L4T 21.2.0 install, so i first installed CUDA 6.5 and then opencv4tegra and THEN ros-indigo-base

@L0g1x great work. If we add opencv4tegra and opencv4tegra-dev in the new cv-bridge.deb I think that we are fully operative :)

Woo hoo!! That eliminated my OpenCV problem. But now I have a driver_base problem. Thanks for the fix! I’m one step closer!

It solved the issue with cv-bridge, but not with each other package that relies on OpenCV.
I tried to install OpenNI2-camera and I went to the starting point. Each deb that has dependency on OpenCV must be modified using this method.

Try for example
sudo apt-get install ros-indigo-rgbd-launch ros-indigo-openni2-camera ros-indigo-openni2-launch

Actually the list of packages to be hacked is the following:
ros-indigo-cv-bridge
ros-indigo-depth-image-proc
ros-indigo-image-geometry
ros-indigo-image-proc
ros-indigo-rqt-image-view

Just to let everyone know (incase you dont already) this is a temporary fix until i finish the permanent fix, which is correcting the opencv4tegra.deb to let apt-get know that libopencv[-dev/-python] is already installed. Im going to try to contact the package manager for opencv4tegra, and see if he knows of a simple way to get this done.

like i said, the cv-bridge fix is really only a fix for only the cv-bridge package. Any other packages relying on libopencv will want to install the native opencv as well. Should have a better fix in next day or two…

@L0g1x : Today, you sir, are my hero. And thank you @Myzhar for your input and everybody else! I would really like to see a permanent fix for this. Then, maybe then, they can fix the ROS Answers page:

http://answers.ros.org/question/196194/ros-indigo-installation-for-ubuntu-arm-jetson-tk1-ubuntu-1404/

But for now, I agree, this is a good temporary fix, and it works great! I can at least compile my code now!!:-D

@jbrown : Good to hear the fix works for others :) Im really swamped this week with midterms at school, but i got pretty close the other day to making a fix without having to make a dummy package… Will hopefully have the perminent fix on the weekend

I hear ya! I’m taking some pretty nasty courses this semester too. I just got done with installing ros on my own jetson board. The other one that I have issues with is the university’s board, so doing my own
(with grinch kernel 21.2.1 and installing ros myself) will help me to debug issues (hopefully). Our code is pretty terrible, so that probably doesn’t help either. Haha.

@jbrown if you want to debug ROS code easily you can use the QtCreator IDE.

You can follow my guide to install it:
http://myzharbot.robot-home.it/blog/software/myzharbot-ros/qtcreator-ros/

@_L0g1x any news about the final solution to OpenCV issue? :-)

Thanks @Myzhar! @L0g1x , have you made any headway with the permanent fix? I am having a problem with videostab.so, but I has a look at your deb and it should have installed it in the /user/lib directory, but I am not seeing it there.

FYI, I added this guide link to the Jetson Links sticky. Seems like there is a lot of interest in ROS and it’s nice to have documentation.