Hello,

At the beginning I would like to thank you very much for creating such a great library.

I’m trying to implement Zhang camera calibration algorithm and I would like to use your IMPROVED LEVENBERG-MARQUARDT METHOD FOR NON-LINEAR LEAST SQUARES OPTIMIZATION. But I don’t know if I’m using it right.

I need to minimize the sum of squares of such equation F = m – H*M

What gives me 3 equations:

x, y, z - are coordinates of projected point m on image

X, Y, Z - are coordinates of equivalent point M on the model.

a, b, c, d, e, f, g, h, j – are parameters of homography H that have to be optimized to make the difference in function F as small as possible.

I’m interested in using just function vector.

Should the function1_fvec look like this? (z and Z are always 1 so I made the equations shorter).

public static void function1_fvec(double[,] point_m, double[,] H, double[,] point_M, double[] fi, object obj)

{

fi[0] = point_m[0, 0] - H[0, 0] * point_M[0, 0] - H[0, 1] * point_M[1, 0] - H[0, 2];

fi[1] = point_m[1, 0] - H[1, 0] * point_M[0, 0] - H[1, 1] * point_M[1, 0] - H[1, 2];

fi[2] = point_m[2, 0] - H[2, 0] * point_M[0, 0] - H[2, 1] * point_M[1, 0] - H[2, 2];

}

Let say I have 100points m and 100pts M. Can you please show me steps of how can I minimize

sumOfSq = (m1 – HM1)^2 + (m2 – HM2)^2 + … + (m100 – HM100) ?

PS. let say the startin point is p=(400,300)

PS2. I read

http://www.alglib.net/translator/man/ma ... _minlm_d_v But it doesn’t work and I don’t know where is a mistake..