SLAM十四讲 解决第10讲 num_linear_solver_threads找不到的问题

高博在github上的ceres_custombundle1的SetLinearSolver函数是这样写的:

void SetLinearSolver(ceres::Solver::Options* options, const BundleParams& params)
{
    CHECK(ceres::StringToLinearSolverType(params.linear_solver, &options->linear_solver_type));
    CHECK(ceres::StringToSparseLinearAlgebraLibraryType(params.sparse_linear_algebra_library, &options->sparse_linear_algebra_library_type));
    CHECK(ceres::StringToDenseLinearAlgebraLibraryType(params.dense_linear_algebra_library, &options->dense_linear_algebra_library_type));
    options->num_linear_solver_threads = params.num_threads;

}

用新版本的Ceres写到这里,num_linear_solver_threads会标红,显示找不到这个成员。思盖木木的解决方案2是将这行代码注释:

options->num_linear_solver_threads = params.num_threads;

而我在ceres-solver官网上看到了1.14.0版本做出如下改变3:

Solver::Options::num_linear_solver_threads is deprecated, Solver::Options::num_threads controls all parallelism in Ceres Solver now. Similarly, Solver::Summary::num_linear_solver_threads_given and Solver::Summary::num_linear_solver_threads_used are also deprecated.

也就是说,可以SetLinearSolver函数改成这样:

void SetLinearSolver(ceres::Solver::Options* options, const BundleParams& params)
{
    CHECK(ceres::StringToLinearSolverType(params.linear_solver, &options->linear_solver_type));
    CHECK(ceres::StringToSparseLinearAlgebraLibraryType(params.sparse_linear_algebra_library, &options->sparse_linear_algebra_library_type));
    CHECK(ceres::StringToDenseLinearAlgebraLibraryType(params.dense_linear_algebra_library, &options->dense_linear_algebra_library_type));
    options->num_threads = params.num_threads;

你可能感兴趣的:(SLAM学习)