Skip to content

Commit

Permalink
Parameterize weight
Browse files Browse the repository at this point in the history
  • Loading branch information
servantftechnicolor committed Jan 17, 2025
1 parent d0ed530 commit 6e2cdf2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ ceres::CostFunction* createConstraintsCostFunctionFromIntrinsics(std::shared_ptr

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

costFunction->AddParameterBlock(3);
costFunction->SetNumResiduals(1);
Expand Down
7 changes: 4 additions & 3 deletions src/aliceVision/sfm/bundle/costfunctions/constraintPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace sfm {

struct ConstraintPointErrorFunctor
{
explicit ConstraintPointErrorFunctor(const Vec3 & normal, const Vec3 & point)
: _normal(normal)
explicit ConstraintPointErrorFunctor(const double weight, const Vec3 & normal, const Vec3 & point)
: _weight(weight), _normal(normal)
{
_constraintDistance = _normal.dot(point);
}
Expand All @@ -25,11 +25,12 @@ struct ConstraintPointErrorFunctor
const T* parameter_point = parameters[0];

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

return true;
}

double _weight;
Vec3 _normal;
double _constraintDistance;
};
Expand Down

0 comments on commit 6e2cdf2

Please sign in to comment.