g2o: A General Framework for Graph Optimization
3.1k
stars
1.11k
forks
source link
ERROR:void g2o::HyperGraph::Edge::setVertex(size_t, g2o::HyperGraph::Vertex*): Assertion `i < _vertices.size() && "index out of bounds"' failed. #585
Closed
wanghao-98 closed 1 year ago
bool poseEstimationDirect ( const vector< Measurement >& measurements, cv::Mat gray, Eigen::Matrix3f& K, Eigen::Isometry3d& Tcw ) { // 初始化g2o typedef g2o::BlockSolver<g2o::BlockSolverTraits<6,1>> DirectBlock; // 求解的向量是6*1的 DirectBlock::LinearSolverType linearSolver = new g2o::LinearSolverDense< DirectBlock::PoseMatrixType > (); DirectBlock solver_ptr = new DirectBlock ( unique_ptr(linearSolver) );
// g2o::OptimizationAlgorithmGaussNewton solver = new g2o::OptimizationAlgorithmGaussNewton( solver_ptr ); // G-N
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( unique_ptr(solver_ptr) ); // L-M
g2o::SparseOptimizer optimizer;
optimizer.setAlgorithm ( solver );
optimizer.setVerbose( true );
}