0

I have a ROS2 package and I create .deb packets from it. It worked perfectly until now: locally and in docker container in GitLab pipeline.

Now, after upgrading OpenCV to 4.6.0, I am trying to convert it into debian packet but bloom-generate rosdebian cannot find package in CMakeLists.txt in docker in GitLab. On local computer everything works as it did before.

#Problem description in detail:

Before: The ROS2 package used OpenCV 4.5.4 and cv_bridge. The opencv was installed from source and cv_bridge was installed with pip install. The ROS2 package could be build and the .deb packages could be created.

Now: I have upgraded Opencv to 4.6.0 and I am installing cv_bridge also from source now and not pip install. I can build and test the ROS2 package, but when I generate the .deb packages, it fails saying that it cannot find the OpenCVConfig.cmake and cv_bridgeConfig.cmake file. This failure to find packages happens only in GitLab docker, but not on local computer. Everything worked fine until I upgraded the opencv from 4.5.4 to 4.6.0.*

I can build and test the ROS2 package but cannot create .deb packet because 'bloom-generate` cannot find packages in CMakeLists.txt file.

I see this error.

CMake Error at CMakeLists.txt:56 (find_package):
  Could not find a package configuration file provided by "OpenCV" (requested
  version 4.6.0) with any of the following names:
    OpenCVConfig.cmake
    opencv-config.cmake
  Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
  "OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"
  provides a separate development package or SDK, be sure it has been
  installed.
-- Configuring incomplete, errors occurred!

The CMakeLists.txt file could not find the packages. I read the ROS2 and CMake documentations and tried all the following ways mentioned below but none works.

  • source the build directory, OpenCVConfig.cmake file, setup.bash file of the OpenCV and cv_bridge installation.

  • I have also tried installing the Opencv and cv_bridge at different locations.

  • I also tried creating a separate ROS2 workspace containing only OpenCV and cv_bridge and sourcing/adding the WS in the ROS2 packages.

  • find_package(OpenCV 4.6.0 REQUIRED)

  • find_package(cv_bridge REQUIRED)

  • set(CMAKE_PREFIX_PATH "/opt/build" ${CMAKE_PREFIX_PATH})

  • set(opencv_pkg "/opt/ros/humble/src/opencv_pkg")

  • include(/opt/build/OpenCVConfig.cmake)

  • set(cv_bridge_DIR /opt/vision_opencv)

  • set(OpenCV_DIR /usr/local/lib/cmake/opencv4)

  • set(OpenCV_CONFIG "${OpenCV_DIR}/OpenCVConfig.cmake")

  • include(${OpenCV_CONFIG})

  • include(/home/root/vision_opencv/build/cv_bridge/ament_cmake_core/cv_bridgeConfig.cmake)

  • include(/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake)

  • set(CMAKE_PREFIX_PATH "/usr/local/lib/cmake/opencv4;/home/root/vision_opencv/build/cv_bridge")

  • set(CMAKE_PREFIX_PATH /home/root/vision_opencv/build/cv_bridge ${CMAKE_PREFIX_PATH})

  • set(CMAKE_MODULE_PATH /usr/local/lib/cmake/opencv4 ${CMAKE_MODULE_PATH})

  • include_directories(${cv_bridge_INCLUDE_DIRS})

  • include_directories( include )

  • find_package(opencv_pkg REQUIRED PATHS "/opt/ros/humble/src/opencv_pkg" NO_DEFAULT_PATH)

  • find_package(OpenCV 4.6.0 CONFIG REQUIRED PATHS /usr/local/lib/cmake/opencv4)

  • find_package(OpenCV 4.6.0 QUIET)

  • find_package(OpenCV 4.6.0 REQUIRED PATHS /usr/local/lib/cmake/opencv4 NO_DEFAULT_PATH)

  • find_package(OpenCV 4.6.0 REQUIRED COMPONENTS opencv_core opencv_imgproc opencv_imgcodecs CONFIG )

  • target_link_libraries(libpsaf ${OpenCV_LIBS})

  • target_include_directories

  • So, do you have the file `OpenCVConfig.cmake` in docker? What is exact path to that file? – Tsyvarev Jun 23 '23 at 13:35
  • @Tsyvarev The file is here: `/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake`. Also, I gave paths to `OpenCVConfig.cmake` files which are present in the build folder after building opencv from source. When I use the ***path*** options, it cannot find the pacckages, because by default `bloom-generate` looks into this directory for `OpenCVConfig.cmake` file: `usr/lib/x68_64-linux-gnu.` – Dhruvin Vadgama Jun 23 '23 at 14:26
  • Also, the path `usr/lib/x68_64-linux-gnu` already contains an `opencv version 4.5.4 or 4.5d`, which I do not want to use. I think, it comes by defaults with `Ubuntu 22.04`. Then it gives rise to another problem: opencv conflict between two different versions. – Dhruvin Vadgama Jun 23 '23 at 14:28
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 23 '23 at 15:27
  • Oh, they decided to install CMake config files under `lib/cmake/opencv4`, where `find_package(OpenCV)` doesn't search... You could try `find_package(OpenCV NAMES OpenCV4 REQUIRED)` instead. You may also add `--debug-find` option to `cmake` invocation, so CMake will print paths which are searched during `find_package`. (But be ready to a LOT of output). – Tsyvarev Jun 23 '23 at 16:09

0 Answers0