opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.36k stars 5.75k forks source link

[Opencv Make Error]: ‘SolvePnPMethod’ does not name a type; did you mean ‘solvePnPRansac’? #3493

Open LightwishWONG opened 1 year ago

LightwishWONG commented 1 year ago

I'm trying to install opencv 3.4.6 on ubuntu 18.04. My CUDA toolkit version is 10.2 with nvidia driver 470. I downloaded opencv in https://opencv.org/releases/ and downloaded opencv_contrib by git clone https://github.com/opencv/opencv_contrib.git with git checkout 3.4. Then I ran cmake using

cmake -D CMAKE_INSTALL_PREFIX=/usr/local \
 -D CMAKE_BUILD_TYPE=Release \
 -D OPENCV_GENERATE_PKGCONFIG=ON \
 -D ENABLE_CXX11=1  \
 -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules \
 -D OPENCV_ENABLE_NONFREE=True \
 -D INSTALL_C_EXAMPLES=ON \
 -D WITH_CUDA=ON \
 -D WITH_TBB=ON \
 -D ENABLE_FAST_MATH=1 \
 -D WITH_OPENMP=ON \
 -D WITH_CUFFT=ON \
 -D WITH_CUBLAS=ON \
 -D BUILD_opencv_cudacodec=OFF \
 -D CUDA_nppicom_LIBRARY=stdc++ \
 -DCUDA_ARCH_NAME=Manual \ 
 -DCUDA_ARCH_BIN="86" ..

The cmake process ran smoothly. However, during make -j8 process, I encountered the following error: _‘SolvePnPMethod’ does not name a type; did you mean ‘solvePnPRansac’?; class ‘cv::aruco::EstimateParameters’ does not have any field named ‘solvePnPMethod’

[ 22%] Built target opencv_bgsegm_pch_dephelp
Scanning dependencies of target opencv_test_cudaobjdetect_pch_dephelp
In file included from /home/lightwish/Downloads/opencv-3.4.6/opencv_contrib/modules/aruco/test/test_precomp.hpp:10,
                 from /home/lightwish/Downloads/opencv-3.4.6/build/modules/aruco/opencv_test_aruco_pch_dephelp.cxx:1:
/home/lightwish/Downloads/opencv-3.4.6/opencv_contrib/modules/aruco/include/opencv2/aruco.hpp:263:16: error: ‘SolvePnPMethod’ does not name a type
  263 |     CV_PROP_RW SolvePnPMethod solvePnPMethod;
      |                ^~~~~~~~~~~~~~
/home/lightwish/Downloads/opencv-3.4.6/opencv_contrib/modules/aruco/include/opencv2/aruco.hpp: In constructor ‘cv::aruco::EstimateParameters::EstimateParameters()’:
/home/lightwish/Downloads/opencv-3.4.6/opencv_contrib/modules/aruco/include/opencv2/aruco.hpp:266:27: error: class ‘cv::aruco::EstimateParameters’ does not have any field named ‘solvePnPMethod’
  266 |                           solvePnPMethod(SOLVEPNP_ITERATIVE) {}
      |                           ^~~~~~~~~~~~~~
[ 22%] Building CXX object modules/cudaobjdetect/CMakeFiles/opencv_test_cudaobjdetect_pch_dephelp.dir/opencv_test_cudaobjdetect_pch_dephelp.cxx.o
make[2]: *** [modules/aruco/CMakeFiles/opencv_test_aruco_pch_dephelp.dir/build.make:63: modules/aruco/CMakeFiles/opencv_test_aruco_pch_dephelp.dir/opencv_test_aruco_pch_dephelp.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:14023: modules/aruco/CMakeFiles/opencv_test_aruco_pch_dephelp.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

I searched this error but didn't get the answer. I really appreciate your help!

Kumataro commented 1 year ago

Hi. As first, if you're not using the latest code, it's hard to fix bugs in previous versions. If possible, I would like you to apply 3.4.19.

This problem seems version mismatch problem between opencv(version 3.4.6) and opencv-contrib(3.4 branch = 3.4.19+).

3.4 branch is for latest code for 3.4.xx. Currently opencv 3.4.19 is released and there are some patches. So it is not same as 3.4.19 too.

I tried following script in Ubuntu 18.04. Compiling 3.4.6 is OK.

git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv
git checkout 3.4.6
cd ..
cd opencv_contrib
git checkout 3.4.6
cd ..
cmake opencv -DOPENCV_EXTRA_MODULES_PATH=opencv_contrib/modules
make -j 8
$ ./bin/opencv_version -v

General configuration for OpenCV 3.4.6 =====================================
  Version control:               3.4.6

  Extra modules:
    Location (extra):            /home/kmtr/work/tmp/opencv_contrib/modules
    Version control (extra):     3.4.6

  Platform:
    Timestamp:                   2023-05-18T08:49:34Z
    Host:                        Linux 4.15.0-200-generic x86_64
    CMake:                       3.10.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (14 files):         + SSSE3 SSE4_1
      SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (6 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (28 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (2 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX

  C/C++:
    Built as dynamic libs?:      YES
    C++11:                       YES
    C++ Compiler:                /usr/bin/c++  (ver 7.5.0)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,--gc-sections  
    Linker flags (Debug):        -Wl,--gc-sections  
    ccache:                      YES
    Precompiled headers:         NO
    Extra dependencies:          dl m pthread rt
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv hdf java js matlab ovis python3 sfm viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         NO

  GUI: 
    GTK+:                        YES (ver 2.24.32)
      GThread :                  YES (ver 2.56.4)
      GtkGlExt:                  NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.34)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES

  Video I/O:
    DC1394:                      YES (ver 2.2.5)
    FFMPEG:                      YES
      avcodec:                   YES (ver 57.107.100)
      avformat:                  YES (ver 57.83.100)
      avutil:                    YES (ver 55.78.100)
      swscale:                   YES (ver 4.8.100)
      avresample:                NO
    GStreamer:                   NO
    libv4l/libv4l2:              NO
    v4l/v4l2:                    linux/videodev2.h

  Parallel framework:            pthreads

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2019.0.0 Gold [2019.0.0]
           at:                   /home/kmtr/work/tmp/3rdparty/ippicv/ippicv_lnx/icv
    Intel IPP IW:                sources (2019.0.0)
              at:                /home/kmtr/work/tmp/3rdparty/ippicv/ippicv_lnx/iw
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  OpenCL:                        YES (no extra features)
    Include path:                /home/kmtr/work/tmp/opencv/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python 2:
    Interpreter:                 /usr/bin/python2.7 (ver 2.7.17)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.17)
    numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
    install path:                lib/python2.7/dist-packages/cv2/python-2.7

  Python (for build):            /usr/bin/python2.7

  Java:                          
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    /usr/local
-----------------------------------------------------------------