Weighting Observations

61 views
Skip to first unread message

Alan Buchanan

unread,
Dec 26, 2016, 7:00:54 AM12/26/16
to Ceres Solver
Hello,

I want to add weighting to my bundle adjustment.

My intent is to add extra observation types to my adjustment.
- Weighted Intrinsics (rather than holding fixed or constrained)
- Observations for the camera extreior orientation
- Ground control points
- Geometric constraints in the model 


Hello,

I want to add weighting to my bundle adjustment.

My intent is to add extra observation types to my adjustment.
- Weighted Intrinsics (rather than holding fixed or constrained)
- Observations for the camera extreior orientation
- Ground control points
- Geometric constraints in the model 

I have added weighting to the Reprojection Cost function and a cost function for adding Auxillary parameters (Intrinsics) with a weight (1/standard deviation) (see below)

However the results have the same effect as constraining the intrinsics. That is it is not pushing any of the errors onto the intrinsics.
I have experimented with very loose weighting for the Intrinsics with the same results.

Any advice is appreciated.

Alan



struct AuxillaryParameterError 
{
    AuxillaryParameterError(double f,double xp,double yp,double k1,double k2,double k3,double p1, double p2, double sd) :
            f(f),xp(xp),yp(yp),k1(k1),k2(k2),k3(k3),p1(p1),p2(p2), sd(sd)
{}
    template<typename T>
    bool operator()(  const T* const intrinsics,
 T* residuals) const 
{

const T& focal_length      = intrinsics[OFFSET_FOCAL_LENGTH];
const T& principal_point_x = intrinsics[OFFSET_PRINCIPAL_POINT_X];
const T& principal_point_y = intrinsics[OFFSET_PRINCIPAL_POINT_Y];
const T& kk1                = intrinsics[OFFSET_K1];
const T& kk2                = intrinsics[OFFSET_K2];
const T& kk3                = intrinsics[OFFSET_K3];
const T& pp1                = intrinsics[OFFSET_P1];
const T& pp2                = intrinsics[OFFSET_P2];

// The error is the difference between the predicted and observed position.
residuals[0] = (focal_length - T(f))/sd;
residuals[1] = (principal_point_x - T(xp))/sd;
residuals[2] = (principal_point_y - T(yp))/sd;
residuals[3] = (kk1 - T(k1))/sd;
residuals[4] = (kk2 - T(k2))/sd;
residuals[5] = (kk3 - T(k3))/sd;
residuals[6] = (pp1 - T(p1))/sd;
residuals[7] = (pp2 - T(p2))/sd;
        return true;
    }
    // Factory to hide the construction of the CostFunction object from
    // the client code.
    static ceres::CostFunction* Create(const double f,const double xp,const double yp,const double k1,const double k2,const double k3,const double p1,const double p2, const double sd) 
{
        return (new ceres::AutoDiffCostFunction<AuxillaryParameterError, 9, 8>(
                new AuxillaryParameterError(f,xp,yp,k1,k2,k3,p1,p2,sd)));
    }
    double f,xp,yp,k1,k2,k3,p1,p2;
double sd;
};

Alan Buchanan

unread,
Dec 27, 2016, 4:20:08 AM12/27/16
to Ceres Solver
I need to put my original post on hold.

My problem is associated with passing standard deviation to the cost function.

The standard deviation was being considered as a parameter to be solved and therefore was falling over.

I think I can work this out now without any input

Reply all
Reply to author
Forward
0 new messages