0

This is on Ubuntu 18.04 running ROS2 Dashing. I built OpenCV from source, and did the ldconfig thing. But colcon keeps trying to use a different version.

The error is "missing: opencv_cudaarithm opencv_cudafilters":

Whole error message:

robotos@jetson-agx:~/ros2_ws$ colcon build
Starting >>> opencv_demos
--- stderr: opencv_demos                         
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find OpenCV (missing: opencv_cudaarithm opencv_cudafilters)
  (found suitable version "4.1.1", minimum required is "4")
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/lib/aarch64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake:328 (find_package_handle_standard_args)
  CMakeLists.txt:29 (find_package)

And yet, there they are:

robotos@jetson-agx:~/ros2_ws$ ls /usr/local/lib
a.out                              libopencv_highgui.so.4.2.0
cmake                              libopencv_imgcodecs.so
...
...
libopencv_core.so                  libopencv_optflow.so
libopencv_core.so.4.2              libopencv_optflow.so.4.2
libopencv_core.so.4.2.0            libopencv_optflow.so.4.2.0
libopencv_cudaarithm.so            libopencv_phase_unwrapping.so
libopencv_cudaarithm.so.4.2        libopencv_phase_unwrapping.so.4.2
libopencv_cudaarithm.so.4.2.0      libopencv_phase_unwrapping.so.4.2.0
...
...
libopencv_cudafilters.so           libopencv_quality.so
libopencv_cudafilters.so.4.2       libopencv_quality.so.4.2
libopencv_cudafilters.so.4.2.0     libopencv_quality.so.4.2.0

4.1.1 is the version I installed through apt. 4.2 is built from source.

Interestingly, if I just run cmake instead of colcon, that'll run to completion, so I guess CMake alone can find it. Although I'm unsure what to do with the resulting files, so I'd like to get colcon working.

A different machine (also 18.04 with Dashing) has no problem finding the cudaarithm and cudafilters modules.

Oren Bell
  • 460
  • 1
  • 5
  • 13
  • What commands do you use to run CMake, and what files are generated from CMake? – Kevin Jun 24 '20 at 01:57
  • cmake src/opencv_demos And it just makes a bunch of folders that all say ament_stuffstuffstuff – Oren Bell Jun 24 '20 at 01:59
  • 1
    According to the log, CMake takes OpenCV installation described in the `/usr/lib/aarch64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake` script. If you want to use your own installation, you need to hint CMake for use its config file. E.g. you may pass `-DOpenCV_DIR=` option to `cmake`. – Tsyvarev Jun 24 '20 at 07:59

1 Answers1

0

Fixed thanks to Tsyvarev. Here's what they were suggesting, translated into a colcon-based perspective:

In your project's CMakeList.txt file, add the following

set(OpenCV_DIR /usr/local/lib/cmake/opencv)

Ideally before the "find_package(OpenCV..." line.

This forces colcon to use the correct OpenCV install, instead of wherever it was looking before. Unclear why some systems can figure it out and others need to be explicitly told.

Oren Bell
  • 460
  • 1
  • 5
  • 13