ubuntu18.04编译视觉SLAM十四讲slambook2/ch7

编译高博视觉SLAM教程时遇到两个主要问题。首先,由于找不到Sophus库的位置,导致编译错误,解决方法是修改CMakeLists中Sophus库的路径。其次,运行时出现错误,原因是缺少fmt库的链接,需在CMakeLists中添加fmt库。完成上述修改后,程序可以成功编译和运行。
摘要由CSDN通过智能技术生成

在编译高博视觉SLAM十四讲的第七章节的时候,遇到了一些error:

首先还是按照常规步骤来进行编译,打开ch7,在该文件夹下面打开终端:

mkdir build


cd build


cmake ..


make -j8

在编译的时候遇到了下面这些错误:

error1:

/usr/local/include/sophus/so2.hpp:106:40: error: ‘ScalarBinaryOpTraits’ in namespace ‘Eigen’ does not name a template type
   using ReturnScalar = typename Eigen::ScalarBinaryOpTraits<
                                        ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/sophus/so2.hpp:110:26: error: ‘ReturnScalar’ was not declared in this scope
   using SO2Product = SO2<ReturnScalar<OtherDerived>>;
                          ^~~~~~~~~~~~
/usr/local/include/sophus/so2.hpp:110:26: note: suggested alternative: ‘GetScalar’
   using SO2Product = SO2<ReturnScalar<OtherDerived>>;
                          ^~~~~~~~~~~~
                          GetScalar
/usr/local/include/sophus/so2.hpp:110:39: error: template argument 1 is invalid
   using SO2Product = SO2<ReturnScalar<OtherDerived>>;
                                       ^~~~~~~~~~~~
/usr/local/include/sophus/so2.hpp:113:32: error: ‘ReturnScalar’ was not declared in this scope
   using PointProduct = Vector2<ReturnScalar<PointDerived>>;
                                ^~~~~~~~~~~~
/usr/local/include/sophus/so2.hpp:113:32: note: suggested alternative: ‘GetScalar’
   using PointProduct = Vector2<ReturnScalar<PointDerived>>;
                                ^~~~~~~~~~~~
                                GetScalar
/usr/local/include/sophus/so2.hpp:113:45: error: template argument 1 is invalid
   using PointProduct = Vector2<ReturnScalar<PointDerived>>;
                                             ^~~~~~~~~~~~
/usr/local/include/sophus/so2.hpp:116:43: error: ‘ReturnScalar’ was not declared in this scope
   using HomogeneousPointProduct = Vector3<ReturnScalar<HPointDerived>>;
                                           ^~~~~~~~~~~~
/usr/local/include/sophus/so2.hpp:116:43: note: suggested alternative: ‘GetScalar’
   using HomogeneousPointProduct = Vector3<ReturnScalar<HPointDerived>>;
                                           ^~~~~~~~~~~~
                                           GetScalar
/usr/local/include/sophus/so2.hpp:116:56: error: template argument 1 is invalid
   using HomogeneousPointProduct = Vector3<ReturnScalar<HPointDerived>>;
                                                        ^~~~~~~~~~~~~
/usr/local/include/sophus/so2.hpp:210:15: error: ‘SO2Product’ does not name a type; did you mean ‘cvDotProduct’?
   SOPHUS_FUNC SO2Product<OtherDerived> operator*(
               ^~~~~~~~~~
               cvDotProduct
/usr/local/include/sophus/so2.hpp:245:15: error: ‘PointProduct’ does not name a type; did you mean ‘cvDotProduct’?
   SOPHUS_FUNC PointProduct<PointDerived> operator*(
               ^~~~~~~~~~~~
               cvDotProduct
/usr/local/include/sophus/so2.hpp:261:15: error: ‘HomogeneousPointProduct’ does not name a type; did you mean ‘HomogeneousPoint’?
   SOPHUS_FUNC HomogeneousPointProduct<HPointDerived> operator*(
               ^~~~~~~~~~~~~~~~~~~~~~~
               HomogeneousPoint
/usr/local/include/sophus/so2.hpp:300:38: error: ‘ReturnScalar’ was not declared in this scope
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                      ^~~~~~~~~~~~
/usr/local/include/sophus/so2.hpp:300:38: note: suggested alternative: ‘GetScalar’
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                      ^~~~~~~~~~~~
                                      GetScalar
/usr/local/include/sophus/so2.hpp:300:51: error: template argument 2 is invalid
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                                   ^~~~~~~~~~~~
/usr/local/include/sophus/so2.hpp:300:63: error: template argument 1 is invalid
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                                               ^~
/usr/local/include/sophus/so2.hpp:300:75: error: ‘type’ in namespace ‘::’ does not name a type
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                                                           ^~~~
In file included from /usr/local/include/sophus/se3.hpp:7:0,
                 from /home/liqiang/Music/slambook2/ch7/pose_estimation_3d2d.cpp:14:
/usr/local/include/sophus/so3.hpp:111:40: error: ‘ScalarBinaryOpTraits’ in namespace ‘Eigen’ does not name a template type
   using ReturnScalar = typename Eigen::ScalarBinaryOpTraits<
                                        ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/sophus/so3.hpp:115:26: error: ‘ReturnScalar’ was not declared in this scope
   using SO3Product = SO3<ReturnScalar<OtherDerived>>;
                          ^~~~~~~~~~~~
/usr/local/include/sophus/so3.hpp:115:26: note: suggested alternative: ‘GetScalar’
   using SO3Product = SO3<ReturnScalar<OtherDerived>>;
                          ^~~~~~~~~~~~
                          GetScalar
/usr/local/include/sophus/so3.hpp:115:39: error: template argument 1 is invalid
   using SO3Product = SO3<ReturnScalar<OtherDerived>>;
                                       ^~~~~~~~~~~~
/usr/local/include/sophus/so3.hpp:118:32: error: ‘ReturnScalar’ was not declared in this scope
   using PointProduct = Vector3<ReturnScalar<PointDerived>>;
                                ^~~~~~~~~~~~
/usr/local/include/sophus/so3.hpp:118:32: note: suggested alternative: ‘GetScalar’
   using PointProduct = Vector3<ReturnScalar<PointDerived>>;
                                ^~~~~~~~~~~~
                                GetScalar
/usr/local/include/sophus/so3.hpp:118:45: error: template argument 1 is invalid
   using PointProduct = Vector3<ReturnScalar<PointDerived>>;
                                             ^~~~~~~~~~~~
/usr/local/include/sophus/so3.hpp:121:43: error: ‘ReturnScalar’ was not declared in this scope
   using HomogeneousPointProduct = Vector4<ReturnScalar<HPointDerived>>;
                                           ^~~~~~~~~~~~
/usr/local/include/sophus/so3.hpp:121:43: note: suggested alternative: ‘GetScalar’
   using HomogeneousPointProduct = Vector4<ReturnScalar<HPointDerived>>;
                                           ^~~~~~~~~~~~
                                           GetScalar
/usr/local/include/sophus/so3.hpp:121:56: error: template argument 1 is invalid
   using HomogeneousPointProduct = Vector4<ReturnScalar<HPointDerived>>;
                                                        ^~~~~~~~~~~~~
/usr/local/include/sophus/so3.hpp:327:15: error: ‘SO3Product’ does not name a type; did you mean ‘cvDotProduct’?
   SOPHUS_FUNC SO3Product<OtherDerived> operator*(
               ^~~~~~~~~~
               cvDotProduct
/usr/local/include/sophus/so3.hpp:360:15: error: ‘PointProduct’ does not name a type; did you mean ‘cvDotProduct’?
   SOPHUS_FUNC PointProduct<PointDerived> operator*(
               ^~~~~~~~~~~~
               cvDotProduct
/usr/local/include/sophus/so3.hpp:375:15: error: ‘HomogeneousPointProduct’ does not name a type; did you mean ‘HomogeneousPoint’?
   SOPHUS_FUNC HomogeneousPointProduct<HPointDerived> operator*(
               ^~~~~~~~~~~~~~~~~~~~~~~
               HomogeneousPoint
/usr/local/include/sophus/so3.hpp:409:38: error: ‘ReturnScalar’ was not declared in this scope
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                      ^~~~~~~~~~~~
/usr/local/include/sophus/so3.hpp:409:38: note: suggested alternative: ‘GetScalar’
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                      ^~~~~~~~~~~~
                                      GetScalar
/usr/local/include/sophus/so3.hpp:409:51: error: template argument 2 is invalid
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                                   ^~~~~~~~~~~~
/usr/local/include/sophus/so3.hpp:409:63: error: template argument 1 is invalid
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                                               ^~
/usr/local/include/sophus/so3.hpp:409:75: error: ‘type’ in namespace ‘::’ does not name a type
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                                                           ^~~~
In file included from /home/liqiang/Music/slambook2/ch7/pose_estimation_3d2d.cpp:14:0:
/usr/local/include/sophus/se3.hpp:86:40: error: ‘ScalarBinaryOpTraits’ in namespace ‘Eigen’ does not name a template type
   using ReturnScalar = typename Eigen::ScalarBinaryOpTraits<
                                        ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/sophus/se3.hpp:90:26: error: ‘ReturnScalar’ was not declared in this scope
   using SE3Product = SE3<ReturnScalar<OtherDerived>>;
                          ^~~~~~~~~~~~
/usr/local/include/sophus/se3.hpp:90:26: note: suggested alternative: ‘GetScalar’
   using SE3Product = SE3<ReturnScalar<OtherDerived>>;
                          ^~~~~~~~~~~~
                          GetScalar
/usr/local/include/sophus/se3.hpp:90:39: error: template argument 1 is invalid
   using SE3Product = SE3<ReturnScalar<OtherDerived>>;
                                       ^~~~~~~~~~~~
/usr/local/include/sophus/se3.hpp:93:32: error: ‘ReturnScalar’ was not declared in this scope
   using PointProduct = Vector3<ReturnScalar<PointDerived>>;
                                ^~~~~~~~~~~~
/usr/local/include/sophus/se3.hpp:93:32: note: suggested alternative: ‘GetScalar’
   using PointProduct = Vector3<ReturnScalar<PointDerived>>;
                                ^~~~~~~~~~~~
                                GetScalar
/usr/local/include/sophus/se3.hpp:93:45: error: template argument 1 is invalid
   using PointProduct = Vector3<ReturnScalar<PointDerived>>;
                                             ^~~~~~~~~~~~
/usr/local/include/sophus/se3.hpp:96:43: error: ‘ReturnScalar’ was not declared in this scope
   using HomogeneousPointProduct = Vector4<ReturnScalar<HPointDerived>>;
                                           ^~~~~~~~~~~~
/usr/local/include/sophus/se3.hpp:96:43: note: suggested alternative: ‘GetScalar’
   using HomogeneousPointProduct = Vector4<ReturnScalar<HPointDerived>>;
                                           ^~~~~~~~~~~~
                                           GetScalar
/usr/local/include/sophus/se3.hpp:96:56: error: template argument 1 is invalid
   using HomogeneousPointProduct = Vector4<ReturnScalar<HPointDerived>>;
                                                        ^~~~~~~~~~~~~
/usr/local/include/sophus/se3.hpp:305:15: error: ‘SE3Product’ does not name a type; did you mean ‘cvDotProduct’?
   SOPHUS_FUNC SE3Product<OtherDerived> operator*(
               ^~~~~~~~~~
               cvDotProduct
/usr/local/include/sophus/se3.hpp:322:15: error: ‘PointProduct’ does not name a type; did you mean ‘cvDotProduct’?
   SOPHUS_FUNC PointProduct<PointDerived> operator*(
               ^~~~~~~~~~~~
               cvDotProduct
/usr/local/include/sophus/se3.hpp:332:15: error: ‘HomogeneousPointProduct’ does not name a type; did you mean ‘HomogeneousPoint’?
   SOPHUS_FUNC HomogeneousPointProduct<HPointDerived> operator*(
               ^~~~~~~~~~~~~~~~~~~~~~~
               HomogeneousPoint
/usr/local/include/sophus/se3.hpp:370:38: error: ‘ReturnScalar’ was not declared in this scope
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                      ^~~~~~~~~~~~
/usr/local/include/sophus/se3.hpp:370:38: note: suggested alternative: ‘GetScalar’
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                      ^~~~~~~~~~~~
                                      GetScalar
/usr/local/include/sophus/se3.hpp:370:51: error: template argument 2 is invalid
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                                   ^~~~~~~~~~~~
/usr/local/include/sophus/se3.hpp:370:63: error: template argument 1 is invalid
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                                               ^~
/usr/local/include/sophus/se3.hpp:370:75: error: ‘type’ in namespace ‘::’ does not name a type
                 std::is_same<Scalar, ReturnScalar<OtherDerived>>::value>::type>
                                                                           ^~~~
/home/liqiang/Music/slambook2/ch7/pose_estimation_3d2d.cpp: In function ‘void bundleAdjustmentGaussNewton(const VecVector3d&, const VecVector2d&, const cv::Mat&, Sophus::SE3d&)’:
/home/liqiang/Music/slambook2/ch7/pose_estimation_3d2d.cpp:192:33: error: no match for ‘operator*’ (operand types are ‘Sophus::SE3d {aka Sophus::SE3<double>}’ and ‘const value_type {aka const Eigen::Matrix<double, 3, 1>}’)
       Eigen::Vector3d pc = pose * points_3d[i];
In file included from /home/liqiang/Music/slambook2/ch7/pose_es

 

原因分析:

主要是因为找不到你的sophus库的位置,我本来是安装在usr/local/include/eigen3 的,但是CMakeLists文件里不是这样的。

把紫色部分路径修改一下就可以了:

" usr/local/include/eigen3/"

 error2:

CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `bundleAdjustmentGaussNewton(std::vector<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::aligned_allocator<Eigen::Matrix<double, 3, 1, 0, 3, 1> > > const&, std::vector<Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::aligned_allocator<Eigen::Matrix<double, 2, 1, 0, 2, 1> > > const&, cv::Mat const&, Sophus::SE3<double, 0>&)':
pose_estimation_3d2d.cpp:(.text+0x3803): undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `fmt::v8::appender fmt::v8::detail::write<char, fmt::v8::appender>(fmt::v8::appender, fmt::v8::basic_string_view<fmt::v8::type_identity<char>::type>, fmt::v8::basic_format_specs<char> const&, fmt::v8::detail::locale_ref) [clone .isra.1659]':
pose_estimation_3d2d.cpp:(.text+0x3f3f): undefined reference to `fmt::v8::detail::basic_data<void>::left_padding_shifts'
pose_estimation_3d2d.cpp:(.text+0x4247): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `Sophus::SO3Base<Sophus::SO3<double, 0> >::normalize() [clone .part.1375]':
pose_estimation_3d2d.cpp:(.text.unlikely+0x30): undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `fmt::v8::detail::throw_format_error(char const*)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail18throw_format_errorEPKc[_ZN3fmt2v86detail18throw_format_errorEPKc]+0x24): undefined reference to `fmt::v8::format_error::~format_error()'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail18throw_format_errorEPKc[_ZN3fmt2v86detail18throw_format_errorEPKc]+0x2b): undefined reference to `vtable for fmt::v8::format_error'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail18throw_format_errorEPKc[_ZN3fmt2v86detail18throw_format_errorEPKc]+0x32): undefined reference to `typeinfo for fmt::v8::format_error'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `void fmt::v8::detail::check_format_string<, Sophus::SO3<double, 0>::expAndTheta(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, double*)::{lambda()#1}::operator()() const::FMT_COMPILE_STRING, 0>(Sophus::SO3<double, 0>::expAndTheta(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, double*)::{lambda()#1}::operator()() const::FMT_COMPILE_STRING)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_[_ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_]+0xfb): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_[_ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_]+0x1c1): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_[_ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_]+0x20d): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_[_ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_]+0x24d): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_[_ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_]+0x25e): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o:pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_[_ZN3fmt2v86detail19check_format_stringIJEZZN6Sophus3SO3IdLi0EE11expAndThetaERKN5Eigen6MatrixIdLi3ELi1ELi0ELi3ELi1EEEPdENKUlvE_clEvE18FMT_COMPILE_STRINGLi0EEEvT0_]+0x26f): more undefined references to `fmt::v8::detail::error_handler::on_error(char const*)' follow
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `Sophus::SE3<double, 0>::exp(Eigen::Matrix<double, 6, 1, 0, 6, 1> const&)':
pose_estimation_3d2d.cpp:(.text._ZN6Sophus3SE3IdLi0EE3expERKN5Eigen6MatrixIdLi6ELi1ELi0ELi6ELi1EEE[_ZN6Sophus3SE3IdLi0EE3expERKN5Eigen6MatrixIdLi6ELi1ELi0ELi6ELi1EEE]+0x846): undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
pose_estimation_3d2d.cpp:(.text._ZN6Sophus3SE3IdLi0EE3expERKN5Eigen6MatrixIdLi6ELi1ELi0ELi6ELi1EEE[_ZN6Sophus3SE3IdLi0EE3expERKN5Eigen6MatrixIdLi6ELi1ELi0ELi6ELi1EEE]+0x870): undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `char const* fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > >&>(char const*, char const*, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > >&)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_[_ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_]+0x11f): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_[_ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_]+0x144): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_[_ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_]+0x18b): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_[_ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_]+0x19a): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_[_ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_]+0x1ae): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o:pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_[_ZN3fmt2v86detail23parse_replacement_fieldIcRNS1_21format_string_checkerIcNS1_13error_handlerEJN5Eigen9TransposeINS5_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEEEEEEEPKT_SE_SE_OT0_]+0x1bd): more undefined references to `fmt::v8::detail::error_handler::on_error(char const*)' follow
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `VertexPose::oplusImpl(double const*)':
pose_estimation_3d2d.cpp:(.text._ZN10VertexPose9oplusImplEPKd[_ZN10VertexPose9oplusImplEPKd]+0x2a1): undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `char const* fmt::v8::detail::parse_align<char, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler> > >&)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail11parse_alignIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS0_26basic_format_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SD_SD_OT0_[_ZN3fmt2v86detail11parse_alignIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS0_26basic_format_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SD_SD_OT0_]+0xe3): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `char const* fmt::v8::detail::do_parse_arg_id<char, fmt::v8::detail::parse_width<char, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler> > >&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler> > >&)::width_adapter&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler> > >&)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail15do_parse_arg_idIcRZNS1_11parse_widthIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS1_21compile_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SE_SE_OT0_E13width_adapterEESE_SE_SE_SG_[_ZN3fmt2v86detail15do_parse_arg_idIcRZNS1_11parse_widthIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS1_21compile_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SE_SE_OT0_E13width_adapterEESE_SE_SE_SG_]+0x117): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail15do_parse_arg_idIcRZNS1_11parse_widthIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS1_21compile_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SE_SE_OT0_E13width_adapterEESE_SE_SE_SG_[_ZN3fmt2v86detail15do_parse_arg_idIcRZNS1_11parse_widthIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS1_21compile_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SE_SE_OT0_E13width_adapterEESE_SE_SE_SG_]+0x123): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail15do_parse_arg_idIcRZNS1_11parse_widthIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS1_21compile_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SE_SE_OT0_E13width_adapterEESE_SE_SE_SG_[_ZN3fmt2v86detail15do_parse_arg_idIcRZNS1_11parse_widthIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS1_21compile_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SE_SE_OT0_E13width_adapterEESE_SE_SE_SG_]+0x12f): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `char const* fmt::v8::detail::do_parse_arg_id<char, fmt::v8::detail::parse_precision<char, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler> > >&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler> > >&)::precision_adapter&>(char const*, char const*, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler> > >&)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail15do_parse_arg_idIcRZNS1_15parse_precisionIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS1_21compile_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SE_SE_OT0_E17precision_adapterEESE_SE_SE_SG_[_ZN3fmt2v86detail15do_parse_arg_idIcRZNS1_15parse_precisionIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS1_21compile_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SE_SE_OT0_E17precision_adapterEESE_SE_SE_SG_]+0x117): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o:pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail15do_parse_arg_idIcRZNS1_15parse_precisionIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS1_21compile_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SE_SE_OT0_E17precision_adapterEESE_SE_SE_SG_[_ZN3fmt2v86detail15do_parse_arg_idIcRZNS1_15parse_precisionIcRNS1_13specs_checkerINS1_21dynamic_specs_handlerINS1_21compile_parse_contextIcNS1_13error_handlerEEEEEEEEEPKT_SE_SE_OT0_E17precision_adapterEESE_SE_SE_SG_]+0x123): more undefined references to `fmt::v8::detail::error_handler::on_error(char const*)' follow
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `void fmt::v8::detail::value<fmt::v8::basic_format_context<fmt::v8::appender, char> >::format_custom_arg<Eigen::Transpose<Eigen::Matrix<double, 3, 1, 0, 3, 1> const>, fmt::v8::detail::fallback_formatter<Eigen::Transpose<Eigen::Matrix<double, 3, 1, 0, 3, 1> const>, char, void> >(void*, fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler>&, fmt::v8::basic_format_context<fmt::v8::appender, char>&)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail5valueINS0_20basic_format_contextINS0_8appenderEcEEE17format_custom_argIN5Eigen9TransposeIKNS8_6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEENS1_18fallback_formatterISD_cvEEEEvPvRNS0_26basic_format_parse_contextIcNS1_13error_handlerEEERS5_[_ZN3fmt2v86detail5valueINS0_20basic_format_contextINS0_8appenderEcEEE17format_custom_argIN5Eigen9TransposeIKNS8_6MatrixIdLi3ELi1ELi0ELi3ELi1EEEEENS1_18fallback_formatterISD_cvEEEEvPvRNS0_26basic_format_parse_contextIcNS1_13error_handlerEEERS5_]+0x20d): undefined reference to `std::locale fmt::v8::detail::locale_ref::get<std::locale>() const'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `void fmt::v8::detail::value<fmt::v8::basic_format_context<fmt::v8::appender, char> >::format_custom_arg<Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> >, fmt::v8::detail::fallback_formatter<Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> >, char, void> >(void*, fmt::v8::basic_format_parse_context<char, fmt::v8::detail::error_handler>&, fmt::v8::basic_format_context<fmt::v8::appender, char>&)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt2v86detail5valueINS0_20basic_format_contextINS0_8appenderEcEEE17format_custom_argIN5Eigen9TransposeINS8_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEENS1_18fallback_formatterISC_cvEEEEvPvRNS0_26basic_format_parse_contextIcNS1_13error_handlerEEERS5_[_ZN3fmt2v86detail5valueINS0_20basic_format_contextINS0_8appenderEcEEE17format_custom_argIN5Eigen9TransposeINS8_6MatrixIdLi4ELi1ELi0ELi4ELi1EEEEENS1_18fallback_formatterISC_cvEEEEvPvRNS0_26basic_format_parse_contextIcNS1_13error_handlerEEERS5_]+0x20d): undefined reference to `std::locale fmt::v8::detail::locale_ref::get<std::locale>() const'
collect2: error: ld returned 1 exit status
CMakeFiles/pose_estimation_3d2d.dir/build.make:112: recipe for target 'pose_estimation_3d2d' failed
make[2]: *** [pose_estimation_3d2d] Error 1
CMakeFiles/Makefile2:215: recipe for target 'CMakeFiles/pose_estimation_3d2d.dir/all' failed
make[1]: *** [CMakeFiles/pose_estimation_3d2d.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

 原因分析:

主要是你没有链接到fmt:

修改CMakeLists,在每一个target_link_libraries中的${OpenCV_LIBS}后面家上fmt:

例如:

所以最后 CMakeLists文件如下:

cmake_minimum_required(VERSION 2.8)
project(vo1)

set(CMAKE_BUILD_TYPE "Release")
add_definitions("-DENABLE_SSE")
set(CMAKE_CXX_FLAGS "-std=c++11 -O2 ${SSE_FLAGS} -msse4")
#set(CMAKE_CXX_FLAGS "-std=c++14 -O2 ${SSE_FLAGS} -msse4") 

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

find_package(OpenCV 3 REQUIRED)
find_package(G2O REQUIRED)
find_package(Sophus REQUIRED)

include_directories(
        ${OpenCV_INCLUDE_DIRS}
        ${G2O_INCLUDE_DIRS}
        ${Sophus_INCLUDE_DIRS}
        "/usr/local/include/eigen3/"
)

add_executable(orb_cv orb_cv.cpp)
target_link_libraries(orb_cv ${OpenCV_LIBS} fmt)

add_executable(orb_self orb_self.cpp)
#target_link_libraries(orb_self ${OpenCV_LIBS})
target_link_libraries(orb_self ${OpenCV_LIBS} fmt)

# add_executable( pose_estimation_2d2d pose_estimation_2d2d.cpp extra.cpp ) # use this if in OpenCV2 
add_executable(pose_estimation_2d2d pose_estimation_2d2d.cpp)
target_link_libraries(pose_estimation_2d2d ${OpenCV_LIBS} fmt)

# # add_executable( triangulation triangulation.cpp extra.cpp) # use this if in opencv2
add_executable(triangulation triangulation.cpp)
target_link_libraries(triangulation ${OpenCV_LIBS} fmt)



add_executable(pose_estimation_3d2d pose_estimation_3d2d.cpp)
target_link_libraries(pose_estimation_3d2d
        g2o_core g2o_stuff
        ${OpenCV_LIBS} fmt)

add_executable(pose_estimation_3d3d pose_estimation_3d3d.cpp)
target_link_libraries(pose_estimation_3d3d
        g2o_core g2o_stuff
        ${OpenCV_LIBS} fmt)

error3:

执行

./orb_cv 1.png 2.png的时候出现:

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(3.4.6) /home/liqiang/Downloads/opencv-3.4.6/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

Aborted (core dumped)

原因分析:

主要是在当前文件夹build下面找不到1和2这两张png格式的图片

解决办法:

方法1:

将两张图片复制到build文件夹下面就可以解决!!!

方法2:

在有图片的文件夹下面,按住Ctrl+L键,复制上面的地址在后面加上两张图片的名称

例如:

./orb_cv /home/liqiang/Music/slambook2/ch7/1.png /home/liqiang/Music/slambook2/ch7/2.png 

最后的执行效果如图所示:

 

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

长沙有肥鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值