Skip to content
Snippets Groups Projects
Commit f02f9e5a authored by gkj1g12's avatar gkj1g12
Browse files

Upload New File

parent 1aa0904e
No related branches found
No related tags found
No related merge requests found
function [calib_X,calib_Y,model] = poly_fit(Coord)
% This function opens a coordinates file for a camera, obtained from the
% function retrieve_marker_coord.m and computes a polynomial between
% image plane coordinates [in pixels] and object plane coordinates [in mm].
% The coefficients of the polynomial are then returned in 2 matrices corresponding
% to X and Y for the camera.
% The polynomial is 3rd order in x and y direction and linear in z
% direction
%
% 3rd order polynomial is in the form:
% x3 + y3 + x2 + y2 + x + y + x2y + xy2 + xy + z + constant
% Coefficients are given in the same order
%
% INPUT VARIABLES:
% Coord = Image and object plane coordinates for the camera
%
% OUTPUT VARIABLES:
% calib_X = Polynomial properties for X coord
% calib_Y = Polynomial properties for Y coord
%
%--------------------------------------------------------------------------
%
% Version 1.0
% Girish K. Jankee (28 January 2018)
%--------------------------------------------------------------------------
%% MAIN CODE
model = @(F,mat) F(1).*mat(:,1).^3 + F(2).*(mat(:,2).^3) + F(3).*mat(:,1).^2 + ...
F(4).*mat(:,2).^2 + F(5).*mat(:,1) + F(6).*mat(:,2) + F(7).*(mat(:,1).^2).*mat(:,2) +...
F(8).*mat(:,1).*(mat(:,2).^2) + F(9).*mat(:,1).*mat(:,2) + F(10).*mat(:,3) + F(11); % Model form of polynomial fit
% keyboard
ini = ones(1,11); % Initial conditions
X = zeros(1,11);
Y = zeros(1,11);
[X,Rx,Jx,COVBx,MSEx] = nlinfit(Coord(:,3:5),Coord(:,1), model, ini); % returns a vector of estimated coefficients for the nonlinear regression
[Y,Ry,Jy,COVBy,MSEy] = nlinfit(Coord(:,3:5),Coord(:,2), model, ini); % The coefficients are estimated using iterative least squares estimation
% disp(model(X,[0,0,100,0,0]))
% disp(std(Rx))
% disp(std(Ry))
calib_X = X;
calib_Y = Y;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment