rst-tu-dortmund / costmap_converter

A ros package that includes plugins and nodes to convert occupied costmap2d cells to primitive types
140 stars 107 forks source link

Opencv4 error #42

Open AxelCORNILLEAU opened 9 months ago

AxelCORNILLEAU commented 9 months ago

Ros Noetic Ubuntu 20.04 OpenCV4 with cuda 11.4 Cv_bridge from source built with the above OpenCV

Error with catkin_make :

/home/axel/catkin_ws/src/costmap_converter/src/costmap_to_dynamic_obstacles/blob_detector.cpp: In static member function ‘static cv::Ptr<BlobDetector> BlobDetector::create(const cv::SimpleBlobDetector::Params&)’:
/home/axel/catkin_ws/src/costmap_converter/src/costmap_to_dynamic_obstacles/blob_detector.cpp:9:56: error: invalid new-expression of abstract class type ‘BlobDetector’
    9 |   return cv::Ptr<BlobDetector> (new BlobDetector(params)); // compatibility with older versions
      |                                                        ^
In file included from /home/axel/catkin_ws/src/costmap_converter/src/costmap_to_dynamic_obstacles/blob_detector.cpp:1:
/home/axel/catkin_ws/src/costmap_converter/include/costmap_converter/costmap_to_dynamic_obstacles/blob_detector.h:60:7: note:   because the following virtual functions are pure within ‘BlobDetector’:
   60 | class BlobDetector : public cv::SimpleBlobDetector
      |       ^~~~~~~~~~~~
In file included from /usr/local/include/opencv4/opencv2/features2d/features2d.hpp:48,
                 from /home/axel/catkin_ws/src/costmap_converter/include/costmap_converter/costmap_to_dynamic_obstacles/blob_detector.h:48,
                 from /home/axel/catkin_ws/src/costmap_converter/src/costmap_to_dynamic_obstacles/blob_detector.cpp:1:
/usr/local/include/opencv4/opencv2/features2d.hpp:789:24: note:         ‘virtual void cv::SimpleBlobDetector::setParams(const cv::SimpleBlobDetector::Params&)’
  789 |   CV_WRAP virtual void setParams(const SimpleBlobDetector::Params& params ) = 0;
      |                        ^~~~~~~~~
/usr/local/include/opencv4/opencv2/features2d.hpp:790:46: note:         ‘virtual cv::SimpleBlobDetector::Params cv::SimpleBlobDetector::getParams() const’
  790 |   CV_WRAP virtual SimpleBlobDetector::Params getParams() const = 0;
      |                                              ^~~~~~~~~
make[2]: *** [costmap_converter/CMakeFiles/costmap_converter.dir/build.make:141: costmap_converter/CMakeFiles/costmap_converter.dir/src/costmap_to_dynamic_obstacles/blob_detector.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:31884: costmap_converter/CMakeFiles/costmap_converter.dir/all] Error 2

I also added in the CMakelist.txt just to be sure :

set(_opencv_version 4)
find_package(OpenCV 4 QUIET)
if(NOT OpenCV_FOUND)
  message(STATUS "Did not find OpenCV 4, trying OpenCV 3")
  set(_opencv_version 3)
endif()

find_package(OpenCV ${_opencv_version} REQUIRED
  COMPONENTS
    opencv_core
    opencv_imgproc
    opencv_imgcodecs
  CONFIG
)

which confirmed :

-- +++ processing catkin package: 'costmap_converter'
-- ==> add_subdirectory(costmap_converter)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Found OpenCV: /usr/local (found suitable version "4.8.0", minimum required is "4") found components: opencv_core opencv_imgproc opencv_imgcodecs 
-- costmap_converter: 2 messages, 0 services

Any hints for a fix ? Am I the only one who builds everything from source ?