Skip to content

Commit 6e2cdf2

Browse files
author
Fabien Servant
committed
Parameterize weight
1 parent d0ed530 commit 6e2cdf2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ ceres::CostFunction* createConstraintsCostFunctionFromIntrinsics(std::shared_ptr
8989

9090
ceres::CostFunction* createCostFunctionFromContraintPoint(const sfmData::Landmark & landmark, const Vec3 & normal)
9191
{
92-
auto costFunction = new ceres::DynamicAutoDiffCostFunction<ConstraintPointErrorFunctor>(new ConstraintPointErrorFunctor(normal, landmark.X));
92+
const double weight = 100.0;
93+
auto costFunction = new ceres::DynamicAutoDiffCostFunction<ConstraintPointErrorFunctor>(new ConstraintPointErrorFunctor(weight, normal, landmark.X));
9394

9495
costFunction->AddParameterBlock(3);
9596
costFunction->SetNumResiduals(1);

src/aliceVision/sfm/bundle/costfunctions/constraintPoint.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace sfm {
1313

1414
struct ConstraintPointErrorFunctor
1515
{
16-
explicit ConstraintPointErrorFunctor(const Vec3 & normal, const Vec3 & point)
17-
: _normal(normal)
16+
explicit ConstraintPointErrorFunctor(const double weight, const Vec3 & normal, const Vec3 & point)
17+
: _weight(weight), _normal(normal)
1818
{
1919
_constraintDistance = _normal.dot(point);
2020
}
@@ -25,11 +25,12 @@ struct ConstraintPointErrorFunctor
2525
const T* parameter_point = parameters[0];
2626

2727
T distance = parameter_point[0] * _normal[0] + parameter_point[1] * _normal[1] + parameter_point[2] * _normal[2];
28-
residuals[0] = 100.0 * (distance - _constraintDistance);
28+
residuals[0] = _weight * (distance - _constraintDistance);
2929

3030
return true;
3131
}
3232

33+
double _weight;
3334
Vec3 _normal;
3435
double _constraintDistance;
3536
};

0 commit comments

Comments
 (0)