Hi,大家好,我是编程小6,很荣幸遇见你,我把这些年在开发过程中遇到的问题或想法写出来,今天说一说
g2o报错修改_ug10.0初始化错误-15,希望能够帮助你!!!。
std::unique_ptr<Block::LinearSolverType> linearSolver(new g2o::LinearSolverDense<Block::PoseMatrixType>());
报错:
error: ‘LinearSolverDense’ in namespace ‘g2o’ does not name a template type; did you mean ‘LinearSolverCSparse’?
头文件中加入
#include <g2o/solvers/dense/linear_solver_dense.h>
error: ‘VertexSBAPointXYZ’ is not a member of ‘g2o’; did you mean ‘VertexPointXYZ’?
在ch7中出现的就以下几处(建议是自行搜索)
全部改成VertexPointXYZ
#报错中的这句是没毛病的 typedef g2o::BlockSolver< g2o::BlockSolverTraits<6,3> > Block #有毛病的是这两句 Block::LinearSolverType* linearSolver = new g2o::LinearSolverEigen<Block::PoseMatrixType>(); // 线性方程求解器 Block* solver_ptr = new Block( linearSolver );
改称
std::unique_ptr<Block::LinearSolverType> linearSolver(new g2o::LinearSolverDense<Block::PoseMatrixType>()); // 线性方程求解器 std::unique_ptr<Block> solver_ptr (new Block(std::move(linearSolver)));
#有毛病的是这句 g2o::OptimizationAlgorithmGaussNewton* solver = new g2o::OptimizationAlgorithmGaussNewton( solver_ptr );
改成
g2o::OptimizationAlgorithmGaussNewton* solver = new g2o::OptimizationAlgorithmGaussNewton(std::move(solver_ptr));
没有输入参数
按照课本输入
build/feature_extraction 1.png 2.png
报了个
usage: feature_extraction img1 img2
*** Failure: Exit code 1 ***
代表路径出问题了,建议是图片改成绝对路径,其次是不需要加build/feature_extraction
就像这样:
/home/evening/slam/slambook-master/ch7/1.png /home/evening/slam/slambook-master/ch7/2.png
至于3D-2D的参数就是:
/home/evening/slam/slambook-master/ch7/1.png /home/evening/slam/slambook-master/ch7/2.png /home/evening/slam/slambook-master/ch7/1_depth.png /home/evening/slam/slambook-master/ch7/2_depth.png
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: undefined reference to symbol ‘_ZTVN3g2o14VertexPointXYZE’
【参考文章】:SLAM十四讲ch7代码调整(undefined reference to symbol)
代码和课本的不一样但是不影响都是ok的
Ptr<FeatureDetector> detector = ORB::create(); Ptr<DescriptorExtractor> descriptor = ORB::create(); // Ptr<FeatureDetector> detector = FeatureDetector::create(detector_name); // Ptr<DescriptorExtractor> descriptor = DescriptorExtractor::create(descriptor_name); Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create ( "BruteForce-Hamming" ); //-- 第一步:检测 Oriented FAST 角点位置 detector->detect ( img_1,keypoints_1 ); detector->detect ( img_2,keypoints_2 ); //-- 第二步:根据角点位置计算 BRIEF 描述子 descriptor->compute ( img_1, keypoints_1, descriptors_1 ); descriptor->compute ( img_2, keypoints_2, descriptors_2 ); Mat outimg1; drawKeypoints( img_1, keypoints_1, outimg1, Scalar::all(-1), DrawMatchesFlags::DEFAULT ); imshow("ORB特征点",outimg1); //-- 第三步:对两幅图像中的BRIEF描述子进行匹配,使用 Hamming 距离 vector<DMatch> matches; //BFMatcher matcher ( NORM_HAMMING ); matcher->match ( descriptors_1, descriptors_2, matches );
课本部分代码:
Ptr<ORB> orb=ORB::create(500,1.2F,8,31,0,2,ORB::HARRIS_SCORE,31,20); orb->detect ( img_1,keypoints_1 ); orb->detect ( img_2,keypoints_2 ); //-- 第二步:根据角点位置计算 BRIEF 描述子 orb->compute ( img_1, keypoints_1, descriptors_1 ); orb->compute ( img_2, keypoints_2, descriptors_2 ); Mat outimg1; drawKeypoints( img_1, keypoints_1, outimg1, Scalar::all(-1), DrawMatchesFlags::DEFAULT ); imshow("ORB特征点",outimg1); //-- 第三步:对两幅图像中的BRIEF描述子进行匹配,使用 Hamming 距离 vector<DMatch> matches; BFMatcher matcher ( NORM_HAMMING ); matcher.match ( descriptors_1, descriptors_2, matches );
和ORB应该是乱七八糟的继承关系,但不是重点
代码部分:创建ORB检测子,描述子,匹配子的方式
Ptr<FeatureDetector> detector = ORB::create(); Ptr<DescriptorExtractor> descriptor = ORB::create(); Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create ( "BruteForce-Hamming" );
g2o::OptimizationAlgorithmGaussNewton* solver = new g2o::OptimizationAlgorithmGaussNewton(std::move(solver_ptr));
会报错!!
今天的分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。
上一篇
已是最后文章
下一篇
已是最新文章