Hello there! I have made some progress in this topic. I managed to use the LeastSquaresOptim package without error messages, however, it seems that even though I get a number of iterations done, the minimizer is almost the same as the initial set of parameters. I will post here the error function i am trying to minimize and the results.
hom() and invhom() are functions to convert points to homogeneous and back to cartesian coordinates. XYworld are the world points positions and XYobs are the observed image points.
Am I doing something wrong?
function Eproj(h)
H = [h[1] h[2] h[3];h[4] h[5] h[6];h[7] h[8] h[9]]
Error = 0
for j in 1:nPoints
XYw = XYworld[j,:]
XYo = XYobs[j,:]
Error += norm(XYo - invhom(H*hom(XYw)))^2
end
return Error
end
h = [H[1,1];H[1,2];H[1,3];H[2,1];H[2,2];H[2,3];H[3,1];H[3,2];H[3,3]] #initial set of parameters
res = LeastSquaresOptim.optimize(Eproj,h,LeastSquaresOptim.LevenbergMarquardt())
The initial set of parameters:
julia> h
9-element Vector{Float64}:
0.5064311920323017
-0.029262951827130214
255.07130841748545
-0.1187228809135697
0.23194964095314136
194.75919975350502
7.778410652589481e-5
-0.0004114037953009441
0.5869894007853151
The results:
Results of Optimization Algorithm
* Algorithm: LevenbergMarquardt
* Minimizer: [0.5064311920323017,-0.029262951827130228,255.07130841748545,-0.11872288091356972,0.23194964095314136,194.75919975350502,7.778410652589478e-5,-0.0004114037953009441,0.5869894007853151]
* Sum of squares at Minimum: 0.004988
* Iterations: 9
* Convergence: true
* |x - x'| < 1.0e-08: false
* |f(x) - f(x')| / |f(x)| < 1.0e-08: true
* |g(x)| < 1.0e-08: false
* Function Calls: 10
* Gradient Calls: 1
* Multiplication Calls: 27