如何从谷神星求解器结果中检索异常值
How to retrieve outliers from ceres solver result?
我尝试使用类似于Features2D + Homgraphy的方法比较图像以查找已知对象,但用自写的findAffine()
函数替换findHomography()
。
我使用谷神星求解器来获得考虑异常值的最佳仿射矩阵。
double translation[] = {0, 0};
double angle = 0;
double scaleFactor = 1;
ceres::Problem problem;
for (size_t i = 0; i < points1.size(); ++i) {
problem.AddResidualBlock(
new ceres::AutoDiffCostFunction<AffineResidual, 1, 2, 1, 1>(
new AffineResidual(Eigen::Vector2d(points1[i].x, points1[i].y),
Eigen::Vector2d(points2[i].x, points2[i].y))),
new ceres::HuberLoss(1.0),
translation,
&angle,
&scaleFactor);
}
ceres::Solver::Options options;
options.linear_solver_type = ceres::DENSE_QR;
options.minimizer_progress_to_stdout = true;
ceres::Solver::Summary summary;
Solve(options, &problem, &summary);
Ceres 求解器提供 LossFunction:
损失函数可减少具有高残差的残差块(通常是与异常值对应的残差块)的影响。
当然,我可以通过获得的矩阵转换第一个图像的关键点坐标,与第二个图像进行比较并得到偏差。但是谷神星求解器在工作期间已经在里面完成了。
如何检索它?在文档中找不到它。
我也有类似的问题。在查看了Ceres库源代码(特别是ResidualBlock::Evaluate()方法)之后,我得出的结论是残差块没有明确的"异常值"状态。似乎损失函数只影响块的结果成本值(这与您引用的文档中的短语完全描述 - "损失函数减少了具有高残差的残差块的影响")。所以答案是您无法从谷神星检索异常值,没有这样的功能。
解决方法可能是使用求解结果计算数据的残差,并对其应用损失函数。来自 LossFunction::Evaluate() 的评论可能会有所帮助:
// For a residual vector with squared 2-norm 'sq_norm', this method
// is required to fill in the value and derivatives of the loss
// function (rho in this example):
//
// out[0] = rho(sq_norm),
// out[1] = rho'(sq_norm),
// out[2] = rho''(sq_norm),
//
// Here the convention is that the contribution of a term to the
// cost function is given by 1/2 rho(s), where
//
// s = ||residuals||^2.
//
// Calling the method with a negative value of 's' is an error and
// the implementations are not required to handle that case.
//
// Most sane choices of rho() satisfy:
//
// rho(0) = 0,
// rho'(0) = 1,
// rho'(s) < 1 in outlier region,
// rho''(s) < 0 in outlier region,
//
// so that they mimic the least squares cost for small residuals.
virtual void Evaluate(double sq_norm, double out[3]) const = 0;
相关文章:
- 为什么"do while"循环不断退出,即使条件计算结果为 false?
- valgrind-hellgrind与泄漏检查的结果不同
- 用C++20 fmt限制结果的总大小
- 如何返回一个类的两个对象相加的结果
- 使用VerQueryValue检索应用程序的文件描述
- 使用QProcess执行命令,并将结果存储在QStringList中
- 如果我std::dynamic_pointer_cast并且底层dynamic_cast的结果为null,那么返回的sh
- 在没有定义返回类型的函数中返回布尔值,并将结果保存在无错误的char编译中-为什么
- 序列化,没有库的整数,得到奇怪的结果
- 使用取消引用的指针的多态性会产生意外的结果.为什么?
- 在更改for循环的第三部分后,未使用for循环结果
- 永远不要从 std::p ackaged_task 中检索 std::future 的结果是否安全?
- 如何从谷神星求解器结果中检索异常值
- 在MFC中检索键盘中断结果
- 使用 search-ms: 或 search: 协议将搜索结果作为 IShellItem 进行检索
- 无法检索正则表达式匹配结果 - MFC / C++
- GLSL -从阴影立方体图中检索值时结果不正确
- 如何用Eigen::AutoDiffScalar检索微分结果
- 如何检索netstat命令的结果
- 检索用户选择的结果作为调用Qt中外部程序的输入