我正在使用OpenCV_contrib在Linux上构建OpenCV,但我无法使其正常运行。 仅OpenCV即可构建而不会出错。
仅编译OpenCV时,可以正常工作。
cmake -D OPENCV_EXTRA_MODULES_PATH = .. / .. / opencv_contrib-3.4 / modules ..
$ make j5
在制作过程中,它以100%失败,
Scanning dependencies of target opencv_python2
[100%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o
[100%] Linking CXX executable ../../bin/opencv_perf_stitching
[100%] Built target opencv_perf_stitching
In file included from /home/habib/Documents/Projects/Packages/opencv-3.4.3/build/modules/python_bindings_generator/pyopencv_custom_headers.h:8:0,
from /home/habib/Documents/Projects/Packages/opencv-3.4.3/modules/python/src2/cv2.cpp:1816:
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:4:40: error: ‘linemod’ was not declared in this scope
template<> struct pyopencvVecConverter<linemod::Match>
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:4:54: error: template argument 1 is invalid
template<> struct pyopencvVecConverter<linemod::Match>
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:17:40: error: ‘linemod’ was not declared in this scope
template<> struct pyopencvVecConverter<linemod::Template>
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:17:57: error: template argument 1 is invalid
template<> struct pyopencvVecConverter<linemod::Template>
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:30:40: error: ‘linemod’ was not declared in this scope
template<> struct pyopencvVecConverter<linemod::Feature>
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:30:56: error: template argument 1 is invalid
template<> struct pyopencvVecConverter<linemod::Feature>
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:43:44: error: ‘linemod’ was not declared in this scope
template<> struct pyopencvVecConverter<Ptr<linemod::Modality> >
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:43:61: error: template argument 1 is invalid
template<> struct pyopencvVecConverter<Ptr<linemod::Modality> >
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:43:63: error: template argument 1 is invalid
template<> struct pyopencvVecConverter<Ptr<linemod::Modality> >
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:56:21: error: ‘linemod’ was not declared in this scope
typedef std::vector<linemod::Match> vector_Match;
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:56:35: error: template argument 1 is invalid
typedef std::vector<linemod::Match> vector_Match;
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:56:35: error: template argument 2 is invalid
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:57:21: error: ‘linemod’ was not declared in this scope
typedef std::vector<linemod::Template> vector_Template;
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:57:38: error: template argument 1 is invalid
typedef std::vector<linemod::Template> vector_Template;
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:57:38: error: template argument 2 is invalid
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:58:21: error: ‘linemod’ was not declared in this scope
typedef std::vector<linemod::Feature> vector_Feature;
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:58:37: error: template argument 1 is invalid
typedef std::vector<linemod::Feature> vector_Feature;
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:58:37: error: template argument 2 is invalid
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:59:25: error: ‘linemod’ was not declared in this scope
typedef std::vector<Ptr<linemod::Modality> > vector_Ptr_Modality;
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:59:42: error: template argument 1 is invalid
typedef std::vector<Ptr<linemod::Modality> > vector_Ptr_Modality;
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:59:44: error: template argument 1 is invalid
typedef std::vector<Ptr<linemod::Modality> > vector_Ptr_Modality;
^
/home/habib/Documents/Projects/Packages/opencv_contrib-3.4/modules/rgbd/misc/python/pyopencv_linemod.hpp:59:44: error: template argument 2 is invalid
[100%] Linking CXX executable ../../bin/opencv_perf_tracking
[100%] Built target opencv_perf_tracking
modules/python2/CMakeFiles/opencv_python2.dir/build.make:62: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o' failed
make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 1
CMakeFiles/Makefile2:15272: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/all' failed
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
答案 0 :(得分:1)
我从官方网站下载了opencv
源代码,并从Github克隆了opencv_contrib
。这不是一个好主意,我遇到了问题。
我从Github克隆了opencv
和opencv_contrib
的完全相同的版本,这次它运行良好。
git clone -b 3.4 https://github.com/opencv/opencv
git clone -b 3.4 https://github.com/opencv/opencv_contrib
答案 1 :(得分:-1)
在make clean
和cmake
之前运行make
应该可以解决问题。