I'm new to computer vision and graphics. I want to estimate exterior camera parameters using non-linear least square estimation as suggested by Lowe, David G. Fitting parameterized three-dimensional models to images. IEEE transactions on pattern analysis and machine intelligence 13.5 (1991): 441-450.. However, I'm stuck at the implementation of the same. So, my question is, is there a MATLAB implementation of the same?Update:The paper uses a notation for $d=u_m*Cos\theta -v_m*Sin\theta$ where $Cos\theta$ and $Sin\theta$ are derived from the XYZ coordinates using collinearity equations. Then it uses $d'=u_i*cos\theta -v_i*sin\theta$. Finally $D=d'-d$ is the distance of the end point of one image line.Hence, for one end point of an image line $D1=(u1_i*Sin\theta-v1_i*Cos\theta) - (u1_m*Sin\theta-v1_m*Cos\theta)$ and similarly $D2=(u2_i*Sin\theta-v2_i*Cos\theta) - (u2_m*Sin\theta-v2_m*Cos\theta)$.Hence, if I expand $u1_m, u2_m, v1_m, v2_m$ I come up with $D1=-f*Sin\theta*(R(1,1)*(X1-X_o)+R(1,2)*(Y1-Y_o)+R(1,3)*(Z1-Z_o)/(R(3,1)*(X1-X_o)+R(3,2)*(Y1-Y_o)+R(3,3)*(Z1-Z_o)) $$+ f*Cos\theta*(R(2,1)*(X1-X_o)+R(2,2)*(Y1-Y_o)+R(2,3)*(Z1-Z_o)/(R(3,1)*(X1-X_o)+R(3,2)*(Y1-Y_o)+R(3,3)*(Z1-Z_o)) - (u1_m*Sin\theta-v1_m*Cos\theta)$Similarly, $D2=-f*Sin\theta*(R(1,1)*(X2-X_o)+R(1,2)*(Y2-Y_o)+R(1,3)*(Z2-Z_o)/(R(3,1)*(X2-X_o)+R(3,2)*(Y2-Y_o)+R(3,3)*(Z2-Z_o)) $$+ f*Cos\theta*(R(2,1)*(X2-X_o)+R(2,2)*(Y2-Y_o)+R(2,3)*(Z2-Z_o)/(R(3,1)*(X2-X_o)+R(3,2)*(Y2-Y_o)+R(3,3)*(Z2-Z_o)) - (u2_m*Sin\theta-v2_m*Cos\theta)$Where $u1_i$ and $v1_i$ are the x,y coordinates of the first edge point on the image line, $u1_m$ and $v1_m$ are the x,y coordinates of the first edge point on the model line, $u2_i$ and $v2_i$ are the x,y coordinates of the second edge point on the image line, $u2_m$ and $v2_m$ are the x,y coordinates of the second edge point on the model line, $X1, Y1, Z1$ and $X2, Y2, Z2$ are the 3D coordinates of two points of in a model line, $X_o, Y_o, Z_o$ are the translation vector of camera center, $R(i,j)$ are the respective elements of the rotation matrix and f is the focal length of the camera. If I get it correctly, I've to calculate D and minimize it. I've come up with an equation from which jacobians will be calculated. $F1 = (X1-X_o)*((d1 - u1_i * Sin\theta + v1_i * Cos\theta)*R(3,1) - f*Sin\theta * R(1,1) + f*Cos\theta * R(2,1))$$ + (Y1-Y_o)*((d1 - u1_i * Sin\theta + v1_i * Cos\theta) * R(3,2) - f*Sin\theta * R(1,2) + f*Cos\theta * R(2,2))$$ + (Z1-Zc)*((d1 - u1_i * Sin\theta + v1_i * Cos\theta)*R(3,3) - f*Sin\theta * R(1,3) + f*cos\theta * R(2,3));$$F2 = (X2-X_o)*((d2 - u2_i * Sin\theta + v2_i * Cos\theta)*R(3,1) - f*Sin\theta * R(1,1) + f*Cos\theta * R(2,1))$$ + (Y2-Y_o)*((d2 - u2_i * Sin\theta + v2_i * Cos\theta) * R(3,2) - f*Sin\theta * R(1,2) + f*Cos\theta * R(2,2))$$ + (Z2-Zc)*((d2 - u2_i * Sin\theta + v2_i * Cos\theta)*R(3,3) - f*Sin\theta * R(1,3) + f*cos\theta * R(2,3));$Now I've calculated the partial derivatives w.r.t $\omega$  $\phi$  $\kappa$ using $R(i,j)$ and chain rule and partial derivatives w.r.t $X_o, Y_o$ and $Z_o$.But, my problem is for initial values the value of $F1$ and $F2$ are always equal to $0$ no matter how random initial parameters I use. Hence, I have a matrix $b=0$, where I've to calculate $AX=b$, $X$ being $deltaX$ and $A$ being the coefficients of the partial derivates after applying chain rule.Please let me know, where I'm wrong. Note: I've also posted it in computer science stack exchange and digital signal processing stack exchange.
Estimating exterior camera parameters by matching lines using least square estimations (Lowe, 1991)
error estimation;image processing;computer vision