pboyer / LilOpt

Non-linear least squares in C++, header-only, inspired by Ceres solver.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

issus on making the point number as a variable and extending the error function

shaozilong opened this issue · comments

Hi, Peter,

Thanks for sharing this small-size but powerful library for nonlinear least square problem, I tried it and tested it with other problems and with more points, it works fine to me. Howerever, not well in coding, I have trouble in developping some fonctions with 3D camera which capture point cloud of objets based on your code, mailly the following two:

First, in your framework, for exemple in the CircleTest exemple, I cannot use the number if Residuals as a variable, (const unsigned int type in your code), in fact, in my application, I want this number to be the point numbers given by the sensor, how should I do to realise this?

Second, sometimes for finding the cercle centers with three parameters in 2D (X, Y and R), it cames that the X can be specified in priori, for exemple the X of the cercle center can commes from another function and so takes a variable. In my application, I need to fit a cylinder with 3D points, and the axis of the cylinder can be obtained somewhere else, and the X ccordinate of a point of the axis can also be specified. To do this, I rewrote the IErrorFunction.h as the follwing

#ifndef LilLM_IErrorFunction_h
#define LilLM_IErrorFunction_h

#include "Eigen/Dense"

using namespace Eigen;

namespace LilOpt {

template<typename _Scalar, unsigned int _NumResiduals, double _Axe_X, double _Axe_Y, double _Axe_Z, double _PointOnAxe_X, unsigned int _NumParams, unsigned int _Dimension>
class IErrorFunction {

public:

    virtual bool Evaluate(  const Matrix<_Scalar, _NumResiduals, _Dimension>&    points, 
                            const Matrix<_Scalar, _NumParams, 1>&                parms,
							const double _Axe_X, const double _Axe_Y, const double _Axe_Z, const double _PointOnAxe_X,
                            Matrix<_Scalar, _NumResiduals, 1>&                   residuals ) const = 0;
};

}

#endif

but the error of Floating-point type model not standard on the "double", and I don't know how to make it works, do you have any idea?

Best regards
Zilong