OpenCV编译错误:/usr/include/c++/5/bits/stl_algobase.h:604:58: ...

本文解决在Ubuntu16.04环境下使用Eclipse+CDT编译OpenCV4.0代码时遇到的编译错误,通过设置C++11特性支持,成功解决了与标准库和类型定义相关的编译问题。

环境:Ubuntu16.04
工具:Eclipse + cdt
opencv 4.0.0

错误描述

编写好的正常代码,在Build Project过程中出现类似于“标准库”错误:

/usr/local/opencv4/include/opencv4/opencv2/stitching/detail/seam_finders.hpp:250:29: error: field ‘impl_’ has incomplete type ‘cv::Ptr<cv::detail::PairwiseSeamFinder>’
     Ptr<PairwiseSeamFinder> impl_;
                             ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/core/cvstd.hpp:81:0,
                 from /usr/local/opencv4/include/opencv4/opencv2/core/base.hpp:58,
                 from /usr/local/opencv4/include/opencv4/opencv2/core.hpp:54,
                 from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:52,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/core/cvstd_wrapper.hpp:66:8: note: declaration of ‘struct cv::Ptr<cv::detail::PairwiseSeamFinder>’
 struct Ptr : public std::shared_ptr<T>
        ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/stitching.hpp:53:0,
                 from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:89,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/stitching/detail/blenders.hpp:108:30: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11
     void prepare(Rect dst_roi) CV_OVERRIDE;
                              ^
/usr/local/opencv4/include/opencv4/opencv2/stitching/detail/blenders.hpp:109:56: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11
     void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE;
                                                        ^
/usr/local/opencv4/include/opencv4/opencv2/stitching/detail/blenders.hpp:110:63: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11
     void blend(InputOutputArray dst, InputOutputArray dst_mask) CV_OVERRIDE;
                                                               ^
/usr/local/opencv4/include/opencv4/opencv2/stitching/detail/blenders.hpp:135:30: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11
     void prepare(Rect dst_roi) CV_OVERRIDE;
                              ^
/usr/local/opencv4/include/opencv4/opencv2/stitching/detail/blenders.hpp:136:56: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11
     void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE;
                                                        ^
/usr/local/opencv4/include/opencv4/opencv2/stitching/detail/blenders.hpp:137:63: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11
     void blend(InputOutputArray dst, InputOutputArray dst_mask) CV_OVERRIDE;
                                                               ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:89:0,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/stitching.hpp:145:12: error: ‘constexpr’ does not name a type
     static constexpr const double ORIG_RESOL = -1.0;
            ^
/usr/local/opencv4/include/opencv4/opencv2/stitching.hpp:145:12: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
/usr/local/opencv4/include/opencv4/opencv2/stitching.hpp:292:20: error: field ‘features_finder_’ has incomplete type ‘cv::Ptr<cv::Feature2D>’
     Ptr<Feature2D> features_finder_;
                    ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/core/cvstd.hpp:81:0,
                 from /usr/local/opencv4/include/opencv4/opencv2/core/base.hpp:58,
                 from /usr/local/opencv4/include/opencv4/opencv2/core.hpp:54,
                 from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:52,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/core/cvstd_wrapper.hpp:66:8: note: declaration of ‘struct cv::Ptr<cv::Feature2D>’
 struct Ptr : public std::shared_ptr<T>
        ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:89:0,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/stitching.hpp:293:34: error: field ‘features_matcher_’ has incomplete type ‘cv::Ptr<cv::detail::FeaturesMatcher>’
     Ptr<detail::FeaturesMatcher> features_matcher_;
                                  ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/core/cvstd.hpp:81:0,
                 from /usr/local/opencv4/include/opencv4/opencv2/core/base.hpp:58,
                 from /usr/local/opencv4/include/opencv4/opencv2/core.hpp:54,
                 from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:52,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/core/cvstd_wrapper.hpp:66:8: note: declaration of ‘struct cv::Ptr<cv::detail::FeaturesMatcher>’
 struct Ptr : public std::shared_ptr<T>
        ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:89:0,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/stitching.hpp:295:37: error: field ‘bundle_adjuster_’ has incomplete type ‘cv::Ptr<cv::detail::BundleAdjusterBase>’
     Ptr<detail::BundleAdjusterBase> bundle_adjuster_;
                                     ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/core/cvstd.hpp:81:0,
                 from /usr/local/opencv4/include/opencv4/opencv2/core/base.hpp:58,
                 from /usr/local/opencv4/include/opencv4/opencv2/core.hpp:54,
                 from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:52,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/core/cvstd_wrapper.hpp:66:8: note: declaration of ‘struct cv::Ptr<cv::detail::BundleAdjusterBase>’
 struct Ptr : public std::shared_ptr<T>
        ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:89:0,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/stitching.hpp:296:28: error: field ‘estimator_’ has incomplete type ‘cv::Ptr<cv::detail::Estimator>’
     Ptr<detail::Estimator> estimator_;
                            ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/core/cvstd.hpp:81:0,
                 from /usr/local/opencv4/include/opencv4/opencv2/core/base.hpp:58,
                 from /usr/local/opencv4/include/opencv4/opencv2/core.hpp:54,
                 from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:52,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/core/cvstd_wrapper.hpp:66:8: note: declaration of ‘struct cv::Ptr<cv::detail::Estimator>’
 struct Ptr : public std::shared_ptr<T>
        ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:89:0,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/stitching.hpp:299:24: error: field ‘warper_’ has incomplete type ‘cv::Ptr<cv::WarperCreator>’
     Ptr<WarperCreator> warper_;
                        ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/core/cvstd.hpp:81:0,
                 from /usr/local/opencv4/include/opencv4/opencv2/core/base.hpp:58,
                 from /usr/local/opencv4/include/opencv4/opencv2/core.hpp:54,
                 from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:52,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/core/cvstd_wrapper.hpp:66:8: note: declaration of ‘struct cv::Ptr<cv::WarperCreator>’
 struct Ptr : public std::shared_ptr<T>
        ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:89:0,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/stitching.hpp:300:38: error: field ‘exposure_comp_’ has incomplete type ‘cv::Ptr<cv::detail::ExposureCompensator>’
     Ptr<detail::ExposureCompensator> exposure_comp_;
                                      ^
In file included from /usr/local/opencv4/include/opencv4/opencv2/core/cvstd.hpp:81:0,
                 from /usr/local/opencv4/include/opencv4/opencv2/core/base.hpp:58,
                 from /usr/local/opencv4/include/opencv4/opencv2/core.hpp:54,
                 from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:52,
                 from ../src/testcv.cpp:1:
                   ^
...

In file included from /usr/local/opencv4/include/opencv4/opencv2/core.hpp:58:0,
                 from /usr/local/opencv4/include/opencv4/opencv2/opencv.hpp:52,
                 from ../src/testcv.cpp:1:
/usr/local/opencv4/include/opencv4/opencv2/core/types.hpp:1852:13: note: candidate: cv::Rect_<_Tp>& cv::Rect_<_Tp>::operator=(const cv::Rect_<_Tp>&) [with _Tp = int]
 Rect_<_Tp>& Rect_<_Tp>::operator = ( const Rect_<_Tp>& r )
             ^
/usr/local/opencv4/include/opencv4/opencv2/core/types.hpp:1862:13: note: candidate: cv::Rect_<_Tp>& cv::Rect_<_Tp>::operator=(cv::Rect_<_Tp>) [with _Tp = int]
 Rect_<_Tp>& Rect_<_Tp>::operator = ( Rect_<_Tp>&& r ) CV_NOEXCEPT
             ^
make: *** [src/testcv.o] Error 1

16:32:01 Build Finished (took 1s.585ms)

原因分析

Opencv 4.0需要C++11特性支持,所以必须对项目设置:

之后即可正常编译。

补充:如果正常gcc命令行编译出现相同错误,应使用:
g++ -c -std=c++11 -I/usr/loca/opencv4/include/opencv4 xxx.cpp
这里opencv的include路径根据各自环境调整。

/usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(cv::Ptr<Y>&&) [with Y = cv::detail::MercatorWarper; T = cv::WarperCreator]’: /usr/include/c++/13/bits/invoke.h:116:38: required from ‘constexpr std::enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> std::__invoke_r(_Callable&&, _Args&& ...) [with _Res = cv::Ptr<cv::WarperCreator>; _Callable = main(int, char**)::<lambda()>&; _Args = {}; enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> = cv::Ptr<cv::WarperCreator>]’ /usr/include/c++/13/bits/std_function.h:290:30: required from ‘static _Res std::_Function_handler<_Res(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res = cv::Ptr<cv::WarperCreator>; _Functor = main(int, char**)::<lambda()>; _ArgTypes = {}]’ /usr/include/c++/13/bits/std_function.h:451:21: required from ‘std::function<_Res(_ArgTypes ...)>::function(_Functor&&) [with _Functor = main(int, char**)::<lambda()>; _Constraints = void; _Res = cv::Ptr<cv::WarperCreator>; _ArgTypes = {}]’ /home/a/stitch/stitch_diff_warper.cpp:41:22: required from here /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: error: no matching function for call to ‘std::shared_ptr<cv::WarperCreator>::shared_ptr(std::remove_reference<cv::Ptr<cv::detail::MercatorWarper>&>::type)’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ In file included from /usr/include/c++/13/memory:80, from /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:11: /usr/include/c++/13/bits/shared_ptr.h:463:9: note: candidate: ‘template<class _Alloc, class ... _Args> std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Args = _Alloc; _Tp = cv::WarperCreator]’ 463 | shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:463:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: ‘cv::Ptr<cv::detail::MercatorWarper>’ is not derived from ‘std::_Sp_alloc_shared_tag<_Tp>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:395:9: note: candidate: ‘template<class _Yp, class _Del, class> std::shared_ptr<_Tp>::shared_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Del = _Yp; <template-parameter-2-3> = _Del; _Tp = cv::WarperCreator]’ 395 | shared_ptr(unique_ptr<_Yp, _Del>&& __r) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:395:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: ‘std::remove_reference<cv::Ptr<cv::detail::MercatorWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::MercatorWarper>’} is not derived from ‘std::unique_ptr<_Tp, _Dp>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:387:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Up>&&) [with _Yp = _Tp1; _Tp = cv::WarperCreator]’ 387 | shared_ptr(auto_ptr<_Yp>&& __r); | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:387:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: ‘std::remove_reference<cv::Ptr<cv::detail::MercatorWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::MercatorWarper>’} is not derived from ‘std::auto_ptr<_Up>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:380:18: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Yp>&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 380 | explicit shared_ptr(const weak_ptr<_Yp>& __r) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:380:18: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: ‘std::remove_reference<cv::Ptr<cv::detail::MercatorWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::MercatorWarper>’} is not derived from ‘const std::weak_ptr<_Tp>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:368:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Yp>&&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 368 | shared_ptr(shared_ptr<_Yp>&& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:368:9: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/shared_ptr.h: In substitution of ‘template<class _Tp> template<class ... _Args> using std::shared_ptr<_Tp>::_Constructible = typename std::enable_if<std::is_constructible<std::__shared_ptr<_Tp>, _Args ...>::value>::type [with _Args = {std::shared_ptr<cv::detail::MercatorWarper>}; _Tp = cv::WarperCreator]’: /usr/include/c++/13/bits/shared_ptr.h:367:30: required from ‘cv::Ptr<T>::Ptr(cv::Ptr<Y>&&) [with Y = cv::detail::MercatorWarper; T = cv::WarperCreator]’ /usr/include/c++/13/bits/invoke.h:116:38: required from ‘constexpr std::enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> std::__invoke_r(_Callable&&, _Args&& ...) [with _Res = cv::Ptr<cv::WarperCreator>; _Callable = main(int, char**)::<lambda()>&; _Args = {}; enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> = cv::Ptr<cv::WarperCreator>]’ /usr/include/c++/13/bits/std_function.h:290:30: required from ‘static _Res std::_Function_handler<_Res(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res = cv::Ptr<cv::WarperCreator>; _Functor = main(int, char**)::<lambda()>; _ArgTypes = {}]’ /usr/include/c++/13/bits/std_function.h:451:21: required from ‘std::function<_Res(_ArgTypes ...)>::function(_Functor&&) [with _Functor = main(int, char**)::<lambda()>; _Constraints = void; _Res = cv::Ptr<cv::WarperCreator>; _ArgTypes = {}]’ /home/a/stitch/stitch_diff_warper.cpp:41:22: required from here /usr/include/c++/13/bits/shared_ptr.h:178:15: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ 178 | using _Constructible = typename enable_if< | ^~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(cv::Ptr<Y>&&) [with Y = cv::detail::MercatorWarper; T = cv::WarperCreator]’: /usr/include/c++/13/bits/invoke.h:116:38: required from ‘constexpr std::enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> std::__invoke_r(_Callable&&, _Args&& ...) [with _Res = cv::Ptr<cv::WarperCreator>; _Callable = main(int, char**)::<lambda()>&; _Args = {}; enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> = cv::Ptr<cv::WarperCreator>]’ /usr/include/c++/13/bits/std_function.h:290:30: required from ‘static _Res std::_Function_handler<_Res(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res = cv::Ptr<cv::WarperCreator>; _Functor = main(int, char**)::<lambda()>; _ArgTypes = {}]’ /usr/include/c++/13/bits/std_function.h:451:21: required from ‘std::function<_Res(_ArgTypes ...)>::function(_Functor&&) [with _Functor = main(int, char**)::<lambda()>; _Constraints = void; _Res = cv::Ptr<cv::WarperCreator>; _ArgTypes = {}]’ /home/a/stitch/stitch_diff_warper.cpp:41:22: required from here /usr/include/c++/13/bits/shared_ptr.h:351:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Yp>&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 351 | shared_ptr(const shared_ptr<_Yp>& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:351:9: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/shared_ptr.h: In substitution of ‘template<class _Tp> template<class ... _Args> using std::shared_ptr<_Tp>::_Constructible = typename std::enable_if<std::is_constructible<std::__shared_ptr<_Tp>, _Args ...>::value>::type [with _Args = {const std::shared_ptr<cv::detail::MercatorWarper>&}; _Tp = cv::WarperCreator]’: /usr/include/c++/13/bits/shared_ptr.h:350:9: required from ‘cv::Ptr<T>::Ptr(cv::Ptr<Y>&&) [with Y = cv::detail::MercatorWarper; T = cv::WarperCreator]’ /usr/include/c++/13/bits/invoke.h:116:38: required from ‘constexpr std::enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> std::__invoke_r(_Callable&&, _Args&& ...) [with _Res = cv::Ptr<cv::WarperCreator>; _Callable = main(int, char**)::<lambda()>&; _Args = {}; enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> = cv::Ptr<cv::WarperCreator>]’ /usr/include/c++/13/bits/std_function.h:290:30: required from ‘static _Res std::_Function_handler<_Res(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res = cv::Ptr<cv::WarperCreator>; _Functor = main(int, char**)::<lambda()>; _ArgTypes = {}]’ /usr/include/c++/13/bits/std_function.h:451:21: required from ‘std::function<_Res(_ArgTypes ...)>::function(_Functor&&) [with _Functor = main(int, char**)::<lambda()>; _Constraints = void; _Res = cv::Ptr<cv::WarperCreator>; _ArgTypes = {}]’ /home/a/stitch/stitch_diff_warper.cpp:41:22: required from here /usr/include/c++/13/bits/shared_ptr.h:178:15: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ 178 | using _Constructible = typename enable_if< | ^~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(cv::Ptr<Y>&&) [with Y = cv::detail::MercatorWarper; T = cv::WarperCreator]’: /usr/include/c++/13/bits/invoke.h:116:38: required from ‘constexpr std::enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> std::__invoke_r(_Callable&&, _Args&& ...) [with _Res = cv::Ptr<cv::WarperCreator>; _Callable = main(int, char**)::<lambda()>&; _Args = {}; enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> = cv::Ptr<cv::WarperCreator>]’ /usr/include/c++/13/bits/std_function.h:290:30: required from ‘static _Res std::_Function_handler<_Res(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res = cv::Ptr<cv::WarperCreator>; _Functor = main(int, char**)::<lambda()>; _ArgTypes = {}]’ /usr/include/c++/13/bits/std_function.h:451:21: required from ‘std::function<_Res(_ArgTypes ...)>::function(_Functor&&) [with _Functor = main(int, char**)::<lambda()>; _Constraints = void; _Res = cv::Ptr<cv::WarperCreator>; _ArgTypes = {}]’ /home/a/stitch/stitch_diff_warper.cpp:41:22: required from here /usr/include/c++/13/bits/shared_ptr.h:311:9: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Yp>&, element_type*) [with _Tp = cv::WarperCreator]’ 311 | shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:311:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: candidate expects 2 arguments, 1 provided 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:287:9: note: candidate: ‘template<class _Deleter, class _Alloc> std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t, _Deleter, _Alloc) [with _Alloc = _Deleter; _Tp = cv::WarperCreator]’ 287 | shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:287:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: candidate expects 3 arguments, 1 provided 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:268:9: note: candidate: ‘template<class _Yp, class _Deleter, class _Alloc, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter, _Alloc) [with _Deleter = _Yp; _Alloc = _Deleter; <template-parameter-2-4> = _Alloc; _Tp = cv::WarperCreator]’ 268 | shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:268:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::MercatorWarper>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:248:9: note: candidate: ‘template<class _Deleter> std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t, _Deleter) [with _Tp = cv::WarperCreator]’ 248 | shared_ptr(nullptr_t __p, _Deleter __d) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:248:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: candidate expects 2 arguments, 1 provided 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:231:9: note: candidate: ‘template<class _Yp, class _Deleter, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter) [with _Deleter = _Yp; <template-parameter-2-3> = _Deleter; _Tp = cv::WarperCreator]’ 231 | shared_ptr(_Yp* __p, _Deleter __d) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:231:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::MercatorWarper>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:214:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 214 | shared_ptr(_Yp* __p) : __shared_ptr<_Tp>(__p) { } | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:214:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::MercatorWarper>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:535:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Tp>&, std::nothrow_t) [with _Tp = cv::WarperCreator]’ 535 | shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:535:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/13/bits/shared_ptr.h:412:17: note: candidate: ‘constexpr std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t) [with _Tp = cv::WarperCreator; std::nullptr_t = std::nullptr_t]’ 412 | constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { } | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:412:28: note: no known conversion for argument 1 from ‘std::remove_reference<cv::Ptr<cv::detail::MercatorWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::MercatorWarper>’} to ‘std::nullptr_t’ 412 | constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { } | ^~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:359:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Tp>&&) [with _Tp = cv::WarperCreator]’ 359 | shared_ptr(shared_ptr&& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:359:31: note: no known conversion for argument 1 from ‘std::remove_reference<cv::Ptr<cv::detail::MercatorWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::MercatorWarper>’} to ‘std::shared_ptr<cv::WarperCreator>&&’ 359 | shared_ptr(shared_ptr&& __r) noexcept | ~~~~~~~~~~~~~^~~ /usr/include/c++/13/bits/shared_ptr.h:204:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Tp>&) [with _Tp = cv::WarperCreator]’ 204 | shared_ptr(const shared_ptr&) noexcept = default; ///< Copy constructor | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:204:18: note: no known conversion for argument 1 from ‘std::remove_reference<cv::Ptr<cv::detail::MercatorWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::MercatorWarper>’} to ‘const std::shared_ptr<cv::WarperCreator>&’ 204 | shared_ptr(const shared_ptr&) noexcept = default; ///< Copy constructor | ^~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:202:17: note: candidate: ‘constexpr std::shared_ptr<_Tp>::shared_ptr() [with _Tp = cv::WarperCreator]’ 202 | constexpr shared_ptr() noexcept : __shared_ptr<_Tp>() { } | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:202:17: note: candidate expects 0 arguments, 1 provided In file included from /usr/include/c++/13/bits/stl_tempbuf.h:61, from /usr/include/c++/13/bits/stl_algo.h:69, from /usr/include/c++/13/algorithm:61, from /usr/local/include/opencv4/opencv2/core/base.hpp:55: /usr/include/c++/13/bits/stl_construct.h: In instantiation of ‘void std::_Construct(_Tp*, _Args&& ...) [with _Tp = cv::detail::MercatorWarper; _Args = {}]’: /usr/include/c++/13/bits/alloc_traits.h:661:19: required from ‘static void std::allocator_traits<std::allocator<void> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = cv::detail::MercatorWarper; _Args = {}; allocator_type = std::allocator<void>]’ /usr/include/c++/13/bits/shared_ptr_base.h:604:39: required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {}; _Tp = cv::detail::MercatorWarper; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/13/bits/shared_ptr_base.h:971:16: required from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = cv::detail::MercatorWarper; _Alloc = std::allocator<void>; _Args = {}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/13/bits/shared_ptr_base.h:1712:14: required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {}; _Tp = cv::detail::MercatorWarper; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/13/bits/shared_ptr.h:464:59: required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {}; _Tp = cv::detail::MercatorWarper]’ /usr/include/c++/13/bits/shared_ptr.h:1009:14: required from ‘std::shared_ptr<typename std::enable_if<(! std::is_array< <template-parameter-1-1> >::value), _Tp>::type> std::make_shared(_Args&& ...) [with _Tp = cv::detail::MercatorWarper; _Args = {}; typename enable_if<(! is_array< <template-parameter-1-1> >::value), _Tp>::type = cv::detail::MercatorWarper]’ /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:146:43: required from ‘cv::Ptr<_Tp> cv::makePtr(const A1& ...) [with _Tp = detail::MercatorWarper; A1 = {}]’ /home/a/stitch/stitch_diff_warper.cpp:41:70: required from here /usr/include/c++/13/bits/stl_construct.h:119:7: error: no matching function for call to ‘cv::detail::MercatorWarper::MercatorWarper()’ 119 | ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/local/include/opencv4/opencv2/stitching/warpers.hpp:46, from /usr/local/include/opencv4/opencv2/stitching.hpp:48, from /usr/local/include/opencv4/opencv2/opencv.hpp:86: /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:483:5: note: candidate: ‘cv::detail::MercatorWarper::MercatorWarper(float)’ 483 | MercatorWarper(float scale) { projector_.scale = scale; } | ^~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:483:5: note: candidate expects 1 argument, 0 provided /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:480:18: note: candidate: ‘constexpr cv::detail::MercatorWarper::MercatorWarper(const cv::detail::MercatorWarper&)’ 480 | class CV_EXPORTS MercatorWarper : public RotationWarperBase<MercatorProjector> | ^~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:480:18: note: candidate expects 1 argument, 0 provided /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:480:18: note: candidate: ‘constexpr cv::detail::MercatorWarper::MercatorWarper(cv::detail::MercatorWarper&&)’ /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:480:18: note: candidate expects 1 argument, 0 provided make[2]: *** [CMakeFiles/stitch_diff_warper.out.dir/build.make:76:CMakeFiles/stitch_diff_warper.out.dir/stitch_diff_warper.cpp.o] 错误 1 make[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/stitch_diff_warper.out.dir/all] 错误 2 make: *** [Makefile:91:all] 错误 2
07-11
/usr/include/c++/13/bits/stl_construct.h: In instantiation of ‘void std::_Construct(_Tp*, _Args&& ...) [with _Tp = cv::CylindricalWarper; _Args = {const float&}]’: /usr/include/c++/13/bits/alloc_traits.h:661:19: required from ‘static void std::allocator_traits<std::allocator<void> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = cv::CylindricalWarper; _Args = {const float&}; allocator_type = std::allocator<void>]’ /usr/include/c++/13/bits/shared_ptr_base.h:604:39: required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {const float&}; _Tp = cv::CylindricalWarper; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/13/bits/shared_ptr_base.h:971:16: required from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = cv::CylindricalWarper; _Alloc = std::allocator<void>; _Args = {const float&}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/13/bits/shared_ptr_base.h:1712:14: required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {const float&}; _Tp = cv::CylindricalWarper; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/13/bits/shared_ptr.h:464:59: required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {const float&}; _Tp = cv::CylindricalWarper]’ /usr/include/c++/13/bits/shared_ptr.h:1009:14: required from ‘std::shared_ptr<typename std::enable_if<(! std::is_array< <template-parameter-1-1> >::value), _Tp>::type> std::make_shared(_Args&& ...) [with _Tp = cv::CylindricalWarper; _Args = {const float&}; typename enable_if<(! is_array< <template-parameter-1-1> >::value), _Tp>::type = cv::CylindricalWarper]’ /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:146:43: required from ‘cv::Ptr<_Tp> cv::makePtr(const A1& ...) [with _Tp = CylindricalWarper; A1 = {float}]’ /home/a/stitch/stitch_diff_warper.cpp:33:68: required from here /usr/include/c++/13/bits/stl_construct.h:119:7: error: no matching function for call to ‘cv::CylindricalWarper::CylindricalWarper(const float&)’ 119 | ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/local/include/opencv4/opencv2/stitching.hpp:48, from /usr/local/include/opencv4/opencv2/opencv.hpp:86: /usr/local/include/opencv4/opencv2/stitching/warpers.hpp:168:18: note: candidate: ‘constexpr cv::CylindricalWarper::CylindricalWarper()’ 168 | class CV_EXPORTS CylindricalWarper: public WarperCreator | ^~~~~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/stitching/warpers.hpp:168:18: note: candidate expects 0 arguments, 1 provided /usr/local/include/opencv4/opencv2/stitching/warpers.hpp:168:18: note: candidate: ‘constexpr cv::CylindricalWarper::CylindricalWarper(const cv::CylindricalWarper&)’ /usr/local/include/opencv4/opencv2/stitching/warpers.hpp:168:18: note: no known conversion for argument 1 from ‘const float’ to ‘const cv::CylindricalWarper&’ /usr/local/include/opencv4/opencv2/stitching/warpers.hpp:168:18: note: candidate: ‘constexpr cv::CylindricalWarper::CylindricalWarper(cv::CylindricalWarper&&)’ /usr/local/include/opencv4/opencv2/stitching/warpers.hpp:168:18: note: no known conversion for argument 1 from ‘const float’ to ‘cv::CylindricalWarper&&’ make[2]: *** [CMakeFiles/stitch_diff_warper.out.dir/build.make:76:CMakeFiles/stitch_diff_warper.out.dir/stitch_diff_warper.cpp.o] 错误 1 make[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/stitch_diff_warper.out.dir/all] 错误 2 make: *** [Makefile:91:all] 错误 2
最新发布
07-11
/usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:348:5: note: candidate: ‘cv::detail::CylindricalWarper::CylindricalWarper(float)’ 348 | CylindricalWarper(float scale) { projector_.scale = scale; } | ^~~~~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:348:5: note: candidate expects 1 argument, 0 provided /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:341:18: note: candidate: ‘constexpr cv::detail::CylindricalWarper::CylindricalWarper(const cv::detail::CylindricalWarper&)’ 341 | class CV_EXPORTS CylindricalWarper : public RotationWarperBase<CylindricalProjector> | ^~~~~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:341:18: note: candidate expects 1 argument, 0 provided /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:341:18: note: candidate: ‘constexpr cv::detail::CylindricalWarper::CylindricalWarper(cv::detail::CylindricalWarper&&)’ /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:341:18: note: candidate expects 1 argument, 0 provided /usr/include/c++/13/bits/stl_construct.h: In instantiation of ‘void std::_Construct(_Tp*, _Args&& ...) [with _Tp = cv::detail::PaniniWarper; _Args = {}]’: /usr/include/c++/13/bits/alloc_traits.h:661:19: required from ‘static void std::allocator_traits<std::allocator<void> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = cv::detail::PaniniWarper; _Args = {}; allocator_type = std::allocator<void>]’ /usr/include/c++/13/bits/shared_ptr_base.h:604:39: required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {}; _Tp = cv::detail::PaniniWarper; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/13/bits/shared_ptr_base.h:971:16: required from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = cv::detail::PaniniWarper; _Alloc = std::allocator<void>; _Args = {}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/13/bits/shared_ptr_base.h:1712:14: required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {}; _Tp = cv::detail::PaniniWarper; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/13/bits/shared_ptr.h:464:59: required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {}; _Tp = cv::detail::PaniniWarper]’ /usr/include/c++/13/bits/shared_ptr.h:1009:14: required from ‘std::shared_ptr<typename std::enable_if<(! std::is_array< <template-parameter-1-1> >::value), _Tp>::type> std::make_shared(_Args&& ...) [with _Tp = cv::detail::PaniniWarper; _Args = {}; typename enable_if<(! is_array< <template-parameter-1-1> >::value), _Tp>::type = cv::detail::PaniniWarper]’ /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:146:43: required from ‘cv::Ptr<_Tp> cv::makePtr(const A1& ...) [with _Tp = detail::PaniniWarper; A1 = {}]’ /home/a/stitch/stitch_diff_warper.cpp:41:68: required from here /usr/include/c++/13/bits/stl_construct.h:119:7: error: no matching function for call to ‘cv::detail::PaniniWarper::PaniniWarper()’ 119 | ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:442:4: note: candidate: ‘cv::detail::PaniniWarper::PaniniWarper(float, float, float)’ 442 | PaniniWarper(float scale, float A = 1, float B = 1) | ^~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:442:4: note: candidate expects 3 arguments, 0 provided /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:439:18: note: candidate: ‘constexpr cv::detail::PaniniWarper::PaniniWarper(const cv::detail::PaniniWarper&)’ 439 | class CV_EXPORTS PaniniWarper : public RotationWarperBase<PaniniProjector> | ^~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:439:18: note: candidate expects 1 argument, 0 provided /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:439:18: note: candidate: ‘constexpr cv::detail::PaniniWarper::PaniniWarper(cv::detail::PaniniWarper&&)’ /usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp:439:18: note: candidate expects 1 argument, 0 provided make[2]: *** [CMakeFiles/stitch_diff_warper.out.dir/build.make:76:CMakeFiles/stitch_diff_warper.out.dir/stitch_diff_warper.cpp.o] 错误 1 make[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/stitch_diff_warper.out.dir/all] 错误 2 make: *** [Makefile:91:all] 错误 2
07-11
<think>我们正在处理一个编译错误:`fatalerror:opencv2/opencv_modules.hpp:没有那个文件或目录`。根据引用[1][2][3][5]中的信息,这个问题通常是由于OpenCV的头文件路径中包含了一个额外的`opencv4`目录层,导致编译器在默认的包含路径中找不到`opencv2`目录。引用[2]和[3]指出,在Ubuntu系统上安装OpenCV4后,头文件可能位于`/usr/include/opencv4/opencv2`或`/usr/local/include/opencv4/opencv2`,而不是直接位于`/usr/include/opencv2`。因此,编译器在查找`opencv2/opencv_modules.hpp`时,实际上需要去`opencv4/opencv2`下寻找。解决方案有以下几种:1.**在编译命令中添加包含路径**(推荐,特别是对于单个文件编译):使用`-I`选项指定额外的头文件路径。例如:```bashg++-I/usr/include/opencv4your_code.cpp-ooutput`pkg-config--cflags--libsopencv4````这里,`-I/usr/include/opencv4`告诉编译器在该目录下查找头文件,这样`#include<opencv2/opencv_modules.hpp>`就会在`/usr/include/opencv4/opencv2/opencv_modules.hpp`找到文件。2.**创建符号链接**(系统级修改,可能需要管理员权限):如引用[3]所述,创建一个从`/usr/include/opencv2`到`/usr/include/opencv4/opencv2`的符号链接:```bashsudoln-s/usr/include/opencv4/opencv2/usr/include/opencv2```或者,如果头文件在`/usr/local/include/opencv4/opencv2`:```bashsudoln-s/usr/local/include/opencv4/opencv2/usr/local/include/opencv2```这样,编译器在查找`opencv2`目录时就会通过符号链接找到正确的路径。3.**复制头文件目录**(不推荐,因为可能导致版本冲突):如引用[2]和[5]所述,将`opencv2`目录复制到上一级目录(即去掉`opencv4`这一层):```bashsudocp-r/usr/include/opencv4/opencv2/usr/include/```或者```bashsudocp-r/usr/local/include/opencv4/opencv2/usr/local/include/```这种方法可能会在升级OpenCV时出现问题,因为复制的文件不会自动更新。4.**使用pkg-config**(推荐,自动化管理包含路径和库):确保你的系统正确配置了`pkg-config`。首先检查:```bashpkg-config--cflagsopencv4```如果返回为空,可能需要安装OpenCV的开发包(如`libopencv-dev`)或者配置环境变量。然后在编译命令中直接使用:```bashg++your_code.cpp-ooutput`pkg-config--cflags--libsopencv4`````pkg-config--cflags`会自动输出正确的包含路径(如`-I/usr/include/opencv4`)。5.**在CMake项目中解决**(如果使用CMake):在`CMakeLists.txt`中,使用`find_package`来定位OpenCV,并自动设置包含路径:```cmakecmake_minimum_required(VERSION3.10)project(YourProject)find_package(OpenCVREQUIRED)include_directories(${OpenCV_INCLUDE_DIRS})add_executable(your_executableyour_code.cpp)target_link_libraries(your_executable${OpenCV_LIBS})```根据引用[1]和[4],如果错误是关于`opencv2/xfeatures2d/cuda.hpp`,可能需要确保在编译时包含了opencv_contrib模块的路径。但当前错误是`opencv_modules.hpp`,这是OpenCV核心模块的一部分,因此通常只需要正确设置核心头文件路径。总结:优先推荐方法1(在编译命令中添加包含路径)或方法4(使用pkg-config),因为它们不会改变系统文件结构。如果项目较大,使用方法5(CMake)更合适。如果以上方法都不行,请检查OpenCV是否安装正确,以及头文件是否确实存在。可以使用以下命令查找:```bashsudofind/-nameopencv_modules.hpp2>/dev/null```根据查找结果调整包含路径。注意:不同的Linux发行版和安装方式(源码编译安装还是包管理器安装)可能导致路径不同,请根据实际情况调整。相关问题:1.如何在不同Linux发行版中正确安装OpenCV开发包?2.CMake项目中如何自动检测多个版本的OpenCV?3.使用`pkg-config`时出现"Packageopencv4notfound"错误如何解决?4.OpenCV头文件结构与版本升级有哪些兼容性注意事项?</think>### 解决 `fatal error: opencv2/opencv_modules.hpp: 没有那个文件或目录` 的完整方案 #### 根本原因分析 该错误表明编译器找不到 OpenCV 的核心头文件,通常由以下原因导致: 1. **头文件路径不匹配**:OpenCV4 头文件默认安装在 `opencv4/opencv2` 子目录中,但代码直接引用 `opencv2`[^2][^3][^5] 2. **编译环境未配置**:缺少正确的包含路径设置或符号链接 3. **版本冲突**:多个 OpenCV 版本共存导致路径混乱 --- ### 三种解决方案(按推荐顺序) #### 方案1:添加编译参数(推荐) **适用场景**:临时编译或简单项目 ```bash # 查找实际头文件路径 sudo find /usr -name opencv_modules.hpp 2>/dev/null # 示例输出:/usr/include/opencv4/opencv2/opencv_modules.hpp g++ -I/usr/include/opencv4 your_code.cpp -o output \ `pkg-config --cflags --libs opencv4` ``` - `-I/usr/include/opencv4`:显式指定OpenCV头文件路径 - `` `pkg-config ...` ``:自动获取库链接参数 - **优点**:无需系统级修改,不影响其他项目 #### 方案2:创建符号链接(系统级) **适用场景**:需要长期解决多个项目编译问题 ```bash # 创建系统级符号链接 sudo ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2 # 验证链接 ls -l /usr/include/opencv2 # 应指向 opencv4/opencv2 ``` - **原理**:建立 `opencv2 -> opencv4/opencv2` 的软链接[^3] - **效果**:使 `#include <opencv2/...>` 能正确解析路径 - **注意**:可能需要重启终端或执行 `sudo ldconfig` #### 方案3:调整头文件位置(备选) **适用场景**:前两种方案无效时 ```bash # 移动头文件(以Ubuntu为例) sudo cp -r /usr/include/opencv4/opencv2 /usr/include/ # 验证 ls /usr/include/opencv2 # 应显示所有OpenCV头文件 ``` - **警告**:可能影响OpenCV后续升级[^2][^5] - **恢复方式**:`sudo rm -rf /usr/include/opencv2` --- ### 验证解决方案 ```bash # 测试包含路径 echo '#include <opencv2/opencv_modules.hpp>' | g++ -I/usr/include/opencv4 -xc++ -E - 2>/dev/null # 成功时输出包含路径,失败无输出 ``` ### 预防措施 1. **CMake最佳实践** (`CMakeLists.txt`): ```cmake find_package(OpenCV REQUIRED) include_directories(${OpenCV_INCLUDE_DIRS}) # 自动处理路径差异 ``` 2. **环境配置** (`~/.bashrc`): ```bash export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" ``` 3. **版本检查**: ```bash # 确认安装版本 pkg-config --modversion opencv4 ``` --- ### 不同场景处理建议 | 场景 | 推荐方案 | 注意事项 | |---------------------|---------------|----------------------------| | 单文件编译 | 方案1 | 添加`-I`参数 | | CMake项目 | CMake配置 | 用`find_package`自动处理 | | 多用户系统 | 方案2 | 需管理员权限 | | 容器环境/Dockerfile | 方案2+方案1 | 构建时创建链接并设置路径 | > **重要提示**:如果使用源码编译安装的OpenCV,需确保安装时执行了 `sudo make install` 完整流程[^3]。
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值