Search code examples
c++eye-trackingceres-solver

How to fit second-order multivariate polynomial (3D surface) using Ceres Solver library


I would like to find the following transfer function using nonlinear least square:

z = a + b*x + c*y + d*x*y + e*x^2*y + f*y^2*x + g*x^2*y^2

Where a, b, c, d, e, f, g are coefficients which we need to find. x, y, z are variable. In my experiment, x and y are the vertical and horizontal coordinates of pupil-glints vectors, respectively. Also, z is the vertical coordinates of given points at different distance.

I am not familiar with template programming, so I hope you can guide me how to use Ceres Solver library to fit the above second-order multivariate polynomial.

Thank you so much .^ ^.


Solution

  • There is a curve fitting example in the ceres tutorial, have a look at that.