Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Compilation errors with g++-8 for OpenCV 4.3.0 with opencv_contrib (xfeatures2d namespace conflict)

I initially created an issue here, but it seems it is the good place here:

System information (version) - OpenCV => 4.3.0 - Opencv_contrib => 4.3.0 - Operating System / Platform => Ubuntu 18.04 - Compiler => g++-8

Detailed description

Compilation errors occured when building OpenCV 4.3.0 with opencv_contrib 4.3.0. The problem is a conflict for type SIFT which is defined into two different namespaces. The code was built with the following options: -DWITH_OPENCL=ON -DWITH_V4L=ON -DOPENCV_EXTRA_MODULES_PATH=../../../src/OpenCV4/opencv_contrib/modules -DBUILD_EXAMPLES=ON

Note: I built it using catkin (from ROS) in a catkin isolated workspace as plain C-Make, so the same erros should occur without catkin build (which simply call make command for plain-cmake projects)

Errors occured when compiling generated files:

  • modules/python_bindings_generator/pyopencv_generated_types_content.h

In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:1904: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h: In function ‘PyObject* pyopencv_cv_xfeatures2d_xfeatures2d_SIFT_create_static(PyObject*, PyObject*, PyObject*)’: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h:74083:13: error: template argument 1 is invalid Ptr<SIFT> retval; ^ /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h:74093:56: error: invalid user-defined conversion from ‘cv::Ptr<cv::xfeatures2d::SIFT>’ to ‘int’ [-fpermissive] ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:159:5: note: in definition of macro ‘ERRWRAP2’ expr; \ ^~~~ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd.hpp:81, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/utils/configuration.private.hpp:8, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:35: /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: candidate is: ‘cv::Ptr<T>::operator T*() const [with T = cv::xfeatures2d::SIFT]’ <near match> inline operator T* () const { return std::shared_ptr<T>::get(); } ^~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: no known conversion from ‘cv::xfeatures2d::SIFT*’ to ‘int’ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:1904: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h: In function ‘PyObject* pyopencv_cv_xfeatures2d_xfeatures2d_SIFT_create_static(PyObject*, PyObject*, PyObject*)’: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h:74083:13: error: template argument 1 is invalid Ptr<SIFT> retval; ^ /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h:74093:56: error: invalid user-defined conversion from ‘cv::Ptr<cv::xfeatures2d::SIFT>’ to ‘int’ [-fpermissive] ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:159:5: note: in definition of macro ‘ERRWRAP2’ expr; \ ^~~~ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd.hpp:81, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/utils/configuration.private.hpp:8, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:35: /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: candidate is: ‘cv::Ptr<T>::operator T*() const [with T = cv::xfeatures2d::SIFT]’ <near match> inline operator T* () const { return std::shared_ptr<T>::get(); } ^~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: no known conversion from ‘cv::xfeatures2d::SIFT*’ to ‘int’

  • modules/python_bindings_generator/pyopencv_generated_funcs.h:

In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:1905: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h: In function ‘PyObject* pyopencv_cv_xfeatures2d_SIFT_create(PyObject*, PyObject*, PyObject*)’: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h:34421:13: error: template argument 1 is invalid Ptr<SIFT> retval; ^ /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h:34431:56: error: invalid user-defined conversion from ‘cv::Ptr<cv::xfeatures2d::SIFT>’ to ‘int’ [-fpermissive] ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:159:5: note: in definition of macro ‘ERRWRAP2’ expr; \ ^~~~ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd.hpp:81, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/utils/configuration.private.hpp:8, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:35: /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: candidate is: ‘cv::Ptr<T>::operator T*() const [with T = cv::xfeatures2d::SIFT]’ <near match> inline operator T* () const { return std::shared_ptr<T>::get(); } ^~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: no known conversion from ‘cv::xfeatures2d::SIFT*’ to ‘int’ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:1905: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h: In function ‘PyObject* pyopencv_cv_xfeatures2d_SIFT_create(PyObject*, PyObject*, PyObject*)’: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h:34421:13: error: template argument 1 is invalid Ptr<SIFT> retval; ^ /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h:34431:56: error: invalid user-defined conversion from ‘cv::Ptr<cv::xfeatures2d::SIFT>’ to ‘int’ [-fpermissive] ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:159:5: note: in definition of macro ‘ERRWRAP2’ expr; \ ^~~~ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd.hpp:81, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/utils/configuration.private.hpp:8, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:35: /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: candidate is: ‘cv::Ptr<T>::operator T*() const [with T = cv::xfeatures2d::SIFT]’ <near match> inline operator T* () const { return std::shared_ptr<T>::get(); } ^~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: no known conversion from ‘cv::xfeatures2d::SIFT*’ to ‘int’

  • Steps to reproduce

To reproduce this, build opencv 4.3.0 (from github) with opencv_contrib 4.3.0 (for github) with g++-8. => Errors are due to ambiguous types "SIFT" that are defines both in cv:: and cv::xfeatures2d:: namespaces.

To fix this I simply specify the namespace to use. See working patches below: - pyopencv_generated_funcs.h.patch :

--- ./build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h 2020-06-11 09:47:42.958995206 +0200
+++ ./src/OpenCV4/patch/pyopencv_generated_funcs.h  2020-06-11 09:39:29.750997088 +0200
@@ -1945,7 +1945,7 @@
 double edgeThreshold=10;
 PyObject* pyobj_sigma = NULL;
 double sigma=1.6;
-    Ptr<SIFT> retval;
+    Ptr<cv::SIFT> retval;

 const char* keywords[] = { "nfeatures", "nOctaveLayers", "contrastThreshold", "edgeThreshold", "sigma", NULL };
 if( PyArg_ParseTupleAndKeywords(args, kw, "|OOOOO:SIFT_create", (char**)keywords, &pyobj_nfeatures, &pyobj_nOctaveLayers, &pyobj_contrastThreshold, &pyobj_edgeThreshold, &pyobj_sigma) &&
@@ -1955,7 +1955,7 @@
     pyopencv_to(pyobj_edgeThreshold, edgeThreshold, ArgInfo("edgeThreshold", 0)) &&
     pyopencv_to(pyobj_sigma, sigma, ArgInfo("sigma", 0)) )
 {
-        ERRWRAP2(retval = cv::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
+        ERRWRAP2(retval = (Ptr<cv::SIFT>)cv::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
     return pyopencv_from(retval);
 }

@@ -34399,7 +34399,7 @@
 double edgeThreshold=10;
 PyObject* pyobj_sigma = NULL;
 double sigma=1.6;
-    Ptr<SIFT> retval;
+    Ptr<cv::xfeatures2d::SIFT> retval;

 const char* keywords[] = { "nfeatures", "nOctaveLayers", "contrastThreshold", "edgeThreshold", "sigma", NULL };
 if( PyArg_ParseTupleAndKeywords(args, kw, "|OOOOO:SIFT_create", (char**)keywords, &pyobj_nfeatures, &pyobj_nOctaveLayers, &pyobj_contrastThreshold, &pyobj_edgeThreshold, &pyobj_sigma) &&
@@ -34409,7 +34409,7 @@
     pyopencv_to(pyobj_edgeThreshold, edgeThreshold, ArgInfo("edgeThreshold", 0)) &&
     pyopencv_to(pyobj_sigma, sigma, ArgInfo("sigma", 0)) )
 {
-        ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
+        ERRWRAP2(retval = (Ptr<cv::xfeatures2d::SIFT>)cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
     return pyopencv_from(retval);
 }
  • pyopencv_generated_types_content.h.patch :

    --- ./build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h 2020-06-11 09:47:43.035995206 +0200 +++ ./src/OpenCV4/patch/pyopencv_generated_types_content.h 2020-06-11 09:39:17.403997135 +0200 @@ -15717,7 +15717,7 @@ double edgeThreshold=10; PyObject* pyobj_sigma = NULL; double sigma=1.6;

    • Ptr<sift> retval;
    • Ptr<cv::sift> retval;

      const char* keywords[] = { "nfeatures", "nOctaveLayers", "contrastThreshold", "edgeThreshold", "sigma", NULL }; if( PyArg_ParseTupleAndKeywords(args, kw, "|OOOOO:SIFT.create", (char**)keywords, &pyobj_nfeatures, &pyobj_nOctaveLayers, &pyobj_contrastThreshold, &pyobj_edgeThreshold, &pyobj_sigma) && @@ -15727,7 +15727,7 @@ pyopencv_to(pyobj_edgeThreshold, edgeThreshold, ArgInfo("edgeThreshold", 0)) && pyopencv_to(pyobj_sigma, sigma, ArgInfo("sigma", 0)) ) {

    • ERRWRAP2(retval = cv::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
    • ERRWRAP2(retval = (Ptr<cv::sift>)cv::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); return pyopencv_from(retval); }

    @@ -72880,7 +72880,7 @@ double edgeThreshold=10; PyObject* pyobj_sigma = NULL; double sigma=1.6;

    • Ptr<sift> retval;
    • Ptr<cv::xfeatures2d::sift> retval;

      const char* keywords[] = { "nfeatures", "nOctaveLayers", "contrastThreshold", "edgeThreshold", "sigma", NULL }; if( PyArg_ParseTupleAndKeywords(args, kw, "|OOOOO:xfeatures2d_SIFT.create", (char**)keywords, &pyobj_nfeatures, &pyobj_nOctaveLayers, &pyobj_contrastThreshold, &pyobj_edgeThreshold, &pyobj_sigma) && @@ -72890,7 +72890,7 @@ pyopencv_to(pyobj_edgeThreshold, edgeThreshold, ArgInfo("edgeThreshold", 0)) && pyopencv_to(pyobj_sigma, sigma, ArgInfo("sigma", 0)) ) {

    • ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
    • ERRWRAP2(retval = (Ptr<cv::xfeatures2d::sift>)cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); return pyopencv_from(retval); }
click to hide/show revision 2
None

updated 2020-06-16 02:31:36 -0600

berak gravatar image

Compilation errors with g++-8 for OpenCV 4.3.0 with opencv_contrib (xfeatures2d namespace conflict)

I initially created an issue here, but it seems it is the good place here:

System information (version) - OpenCV => 4.3.0 - Opencv_contrib => 4.3.0 - Operating System / Platform => Ubuntu 18.04 - Compiler => g++-8

Detailed description

Compilation errors occured when building OpenCV 4.3.0 with opencv_contrib 4.3.0. The problem is a conflict for type SIFT which is defined into two different namespaces. The code was built with the following options: -DWITH_OPENCL=ON -DWITH_V4L=ON -DOPENCV_EXTRA_MODULES_PATH=../../../src/OpenCV4/opencv_contrib/modules -DBUILD_EXAMPLES=ON

Note: I built it using catkin (from ROS) in a catkin isolated workspace as plain C-Make, so the same erros should occur without catkin build (which simply call make command for plain-cmake projects)

Errors occured when compiling generated files:

  • modules/python_bindings_generator/pyopencv_generated_types_content.h

In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:1904: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h: In function ‘PyObject* pyopencv_cv_xfeatures2d_xfeatures2d_SIFT_create_static(PyObject*, PyObject*, PyObject*)’: pyopencv_cv_xfeatures2d_xfeatures2d_SIFT_create_static(PyObject, PyObject, PyObject)’: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h:74083:13: error: template argument 1 is invalid Ptr<SIFT> Ptr<sift> retval; ^ /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h:74093:56: error: invalid user-defined conversion from ‘cv::Ptr<cv::xfeatures2d::SIFT>’ ‘cv::Ptr<cv::xfeatures2d::sift>’ to ‘int’ [-fpermissive] ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:159:5: note: in definition of macro ‘ERRWRAP2’ expr; \ ^~~~ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd.hpp:81, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/utils/configuration.private.hpp:8, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:35: /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: candidate is: ‘cv::Ptr<T>::operator T*() ‘cv::Ptr<t>::operator T() const [with T = cv::xfeatures2d::SIFT]’ <near match> match=""> inline operator T* () const { return std::shared_ptr<T>::get(); std::shared_ptr<t>::get(); } ^~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: no known conversion from ‘cv::xfeatures2d::SIFT*’ ‘cv::xfeatures2d::SIFTto ‘int’ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:1904: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h: In function ‘PyObject* pyopencv_cv_xfeatures2d_xfeatures2d_SIFT_create_static(PyObject*, PyObject*, PyObject*)’: ‘PyObject pyopencv_cv_xfeatures2d_xfeatures2d_SIFT_create_static(PyObject, PyObject, PyObject)’: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h:74083:13: error: template argument 1 is invalid Ptr<SIFT> Ptr<sift> retval; ^ /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h:74093:56: error: invalid user-defined conversion from ‘cv::Ptr<cv::xfeatures2d::SIFT>’ ‘cv::Ptr<cv::xfeatures2d::sift>’ to ‘int’ [-fpermissive] ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:159:5: note: in definition of macro ‘ERRWRAP2’ expr; \ ^~~~ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd.hpp:81, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/utils/configuration.private.hpp:8, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:35: /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: candidate is: ‘cv::Ptr<T>::operator T*() ‘cv::Ptr<t>::operator T() const [with T = cv::xfeatures2d::SIFT]’ <near match> match=""> inline operator T* () const { return std::shared_ptr<T>::get(); std::shared_ptr<t>::get(); } ^~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: no known conversion from ‘cv::xfeatures2d::SIFT*’ to ‘int’ ```

  • modules/python_bindings_generator/pyopencv_generated_funcs.h:

``` In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:1905: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h: In function ‘PyObject* pyopencv_cv_xfeatures2d_SIFT_create(PyObject*, PyObject*, PyObject*)’: pyopencv_cv_xfeatures2d_SIFT_create(PyObject, PyObject, PyObject)’: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h:34421:13: error: template argument 1 is invalid Ptr<SIFT> Ptr<sift> retval; ^ /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h:34431:56: error: invalid user-defined conversion from ‘cv::Ptr<cv::xfeatures2d::SIFT>’ ‘cv::Ptr<cv::xfeatures2d::sift>’ to ‘int’ [-fpermissive] ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:159:5: note: in definition of macro ‘ERRWRAP2’ expr; \ ^~~~ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd.hpp:81, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/utils/configuration.private.hpp:8, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:35: /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: candidate is: ‘cv::Ptr<T>::operator T*() ‘cv::Ptr<t>::operator T() const [with T = cv::xfeatures2d::SIFT]’ <near match> match=""> inline operator T* () const { return std::shared_ptr<T>::get(); std::shared_ptr<t>::get(); } ^~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: no known conversion from ‘cv::xfeatures2d::SIFT*’ ‘cv::xfeatures2d::SIFTto ‘int’ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:1905: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h: In function ‘PyObject* pyopencv_cv_xfeatures2d_SIFT_create(PyObject*, PyObject*, PyObject*)’: ‘PyObject pyopencv_cv_xfeatures2d_SIFT_create(PyObject, PyObject, PyObject)’: /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h:34421:13: error: template argument 1 is invalid Ptr<SIFT> Ptr<sift> retval; ^ /home/gus/ressac/catkin_isolated_ws/build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h:34431:56: error: invalid user-defined conversion from ‘cv::Ptr<cv::xfeatures2d::SIFT>’ ‘cv::Ptr<cv::xfeatures2d::sift>’ to ‘int’ [-fpermissive] ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:159:5: note: in definition of macro ‘ERRWRAP2’ expr; \ ^~~~ In file included from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd.hpp:81, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/utils/configuration.private.hpp:8, from /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/python/src2/cv2.cpp:35: /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: candidate is: ‘cv::Ptr<T>::operator T*() ‘cv::Ptr<t>::operator T() const [with T = cv::xfeatures2d::SIFT]’ <near match> match=""> inline operator T* () const { return std::shared_ptr<T>::get(); std::shared_ptr<t>::get(); } ^~~~~~~~ /home/gus/ressac/catkin_isolated_ws/src/OpenCV4/modules/core/include/opencv2/core/cvstd_wrapper.hpp:129:12: note: no known conversion from ‘cv::xfeatures2d::SIFT*’ to ‘int’ ‘int’

  • Steps to reproduce

To reproduce this, build opencv 4.3.0 (from github) with opencv_contrib 4.3.0 (for github) with g++-8. => Errors are due to ambiguous types "SIFT" that are defines both in cv:: *cv::* and cv::xfeatures2d:: namespaces.

*cv::xfeatures2d::* namespaces. To fix this I simply specify the namespace to use. See working patches below: - pyopencv_generated_funcs.h.patch :

:
--- ./build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_funcs.h 2020-06-11 09:47:42.958995206 +0200
+++ ./src/OpenCV4/patch/pyopencv_generated_funcs.h  2020-06-11 09:39:29.750997088 +0200
@@ -1945,7 +1945,7 @@
 double edgeThreshold=10;
 PyObject* pyobj_sigma = NULL;
 double sigma=1.6;
-    Ptr<SIFT> retval;
+    Ptr<cv::SIFT> retval;

 const char* keywords[] = { "nfeatures", "nOctaveLayers", "contrastThreshold", "edgeThreshold", "sigma", NULL };
 if( PyArg_ParseTupleAndKeywords(args, kw, "|OOOOO:SIFT_create", (char**)keywords, &pyobj_nfeatures, &pyobj_nOctaveLayers, &pyobj_contrastThreshold, &pyobj_edgeThreshold, &pyobj_sigma) &&
@@ -1955,7 +1955,7 @@
     pyopencv_to(pyobj_edgeThreshold, edgeThreshold, ArgInfo("edgeThreshold", 0)) &&
     pyopencv_to(pyobj_sigma, sigma, ArgInfo("sigma", 0)) )
 {
-        ERRWRAP2(retval = cv::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
+        ERRWRAP2(retval = (Ptr<cv::SIFT>)cv::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
     return pyopencv_from(retval);
 }

@@ -34399,7 +34399,7 @@
 double edgeThreshold=10;
 PyObject* pyobj_sigma = NULL;
 double sigma=1.6;
-    Ptr<SIFT> retval;
+    Ptr<cv::xfeatures2d::SIFT> retval;

 const char* keywords[] = { "nfeatures", "nOctaveLayers", "contrastThreshold", "edgeThreshold", "sigma", NULL };
 if( PyArg_ParseTupleAndKeywords(args, kw, "|OOOOO:SIFT_create", (char**)keywords, &pyobj_nfeatures, &pyobj_nOctaveLayers, &pyobj_contrastThreshold, &pyobj_edgeThreshold, &pyobj_sigma) &&
@@ -34409,7 +34409,7 @@
     pyopencv_to(pyobj_edgeThreshold, edgeThreshold, ArgInfo("edgeThreshold", 0)) &&
     pyopencv_to(pyobj_sigma, sigma, ArgInfo("sigma", 0)) )
 {
-        ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
+        ERRWRAP2(retval = (Ptr<cv::xfeatures2d::SIFT>)cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
     return pyopencv_from(retval);
 }
  • pyopencv_generated_types_content.h.patch :

    --- ./build_isolated/OpenCV4/install/modules/python_bindings_generator/pyopencv_generated_types_content.h 2020-06-11 09:47:43.035995206 +0200 +++ ./src/OpenCV4/patch/pyopencv_generated_types_content.h 2020-06-11 09:39:17.403997135 +0200 @@ -15717,7 +15717,7 @@ double edgeThreshold=10; PyObject* pyobj_sigma = NULL; double sigma=1.6;

    • Ptr<sift> retval;
    • Ptr<cv::sift> retval;

      const char* keywords[] = { "nfeatures", "nOctaveLayers", "contrastThreshold", "edgeThreshold", "sigma", NULL }; if( PyArg_ParseTupleAndKeywords(args, kw, "|OOOOO:SIFT.create", (char**)keywords, &pyobj_nfeatures, &pyobj_nOctaveLayers, &pyobj_contrastThreshold, &pyobj_edgeThreshold, &pyobj_sigma) && @@ -15727,7 +15727,7 @@ pyopencv_to(pyobj_edgeThreshold, edgeThreshold, ArgInfo("edgeThreshold", 0)) && pyopencv_to(pyobj_sigma, sigma, ArgInfo("sigma", 0)) ) {

    • ERRWRAP2(retval = cv::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
    • ERRWRAP2(retval = (Ptr<cv::sift>)cv::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); return pyopencv_from(retval); }
    md5-dff2c0358ef886937f98eabe07c5187b

    @@ -72880,7 +72880,7 @@ double edgeThreshold=10; PyObject* pyobj_sigma = NULL; double sigma=1.6;

    • Ptr<sift> retval;
    • Ptr<cv::xfeatures2d::sift> retval;

      const char* keywords[] = { "nfeatures", "nOctaveLayers", "contrastThreshold", "edgeThreshold", "sigma", NULL }; if( PyArg_ParseTupleAndKeywords(args, kw, "|OOOOO:xfeatures2d_SIFT.create", (char**)keywords, &pyobj_nfeatures, &pyobj_nOctaveLayers, &pyobj_contrastThreshold, &pyobj_edgeThreshold, &pyobj_sigma) && @@ -72890,7 +72890,7 @@ pyopencv_to(pyobj_edgeThreshold, edgeThreshold, ArgInfo("edgeThreshold", 0)) && pyopencv_to(pyobj_sigma, sigma, ArgInfo("sigma", 0)) ) {

    • ERRWRAP2(retval = cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
    • ERRWRAP2(retval = (Ptr<cv::xfeatures2d::sift>)cv::xfeatures2d::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma)); return pyopencv_from(retval); }