Ceres-Solver学习记录(一):HelloWorld

1. Introduction

利用Ceres-Solver求解带有边界约束的非线性最小二乘问题
如下形式:

应用场景从数理统计中的曲线拟合到计算摄影学中的三维重建,都会涉及到类似上式的优化。
本教程将会学习如何利用ceres-solver来求解上式优化问题。

上式中:

  • \(ρ_i(||f_i(x_{i1},...,x_{ik})||^2)\) 为一个残差块(Residual Block),\(ρ_i(·)\) 为代价函数,其输入通常为small group of scalars(一小组数)
  • \(ρ_i(·)\) 为损失函数 LossFunction, 用于减弱外点(即outliers)对Problem整体cost的影响;也可以是带有scaled的函数

2. HelloWorld

https://ceres-solver.googlesource.com/ceres-solver/+/master/examples/helloworld.cc

3. Call Ceres Optimization

ceres::Problem problem;

ceres::Solver::Options options;
options.max_num_iterations = 5;
options.linear_solver_type = ceres::DENSE_SCHUR;
// options.minimizer_progress_to_stdout = true;

ceres::Solver::Summary summary;
ceres::Solve(options, &problem, &summary);
// std::cout << summary.FullReport() << std::endl;
// std::cout << summary.BriefReport() << std::endl;
  • problem和option (定义问题+设定优化选项), summary为优化过程的verbose
  • 需要注意:优化返回的final_cost为上式Σ累加得到的误差值,并不代表每个样本的误差值。

参考链接

posted @ 2023-02-14 17:24  梦一场6688  阅读(305)  评论(0)    收藏  举报