Skip to content
Snippets Groups Projects
Commit 25e95af0 authored by jml1g18's avatar jml1g18
Browse files

added missing back_project_1c.m from gigatrack repo

parent 41390195
No related branches found
No related tags found
No related merge requests found
function [gl_pos] = back_project_1c(cam, M, ij_pos, b_distort)
% Given a camera model and the equation of a plane
% back project a set of points in image space to object space
%
% Input:
% cam camera model structure
% M equation of plane. M(1:3).x + M(4) = 0
% ij_pos points in image space, pixels
% b_distort flag, if true, correct for radial distortion first
%% correct image coords for distortion
if nargin < 4
b_distort = true;
end
if b_distort
ic = cam.ic;
kr = cam.kr;
ij_pos = inverse_radial_distortion(ij_pos, ic, kr);
end
%% back project to find object space coords
% we simultaneously solve
% P*[X;Y;Z;1] = lambda * [x;y;1]
% M*[X;Y;Z;1] = 0
% so we form a matrix T = [P;M]
% and solve for x~ / lambda = T^-1 * [x;y;1;0]
P = cam.P;
T = [P; M(:)'];
N = size(ij_pos, 2);
ytilde = [ij_pos; ones(1,N); zeros(1,N)];
xtilde = T \ ytilde;
lambda = xtilde(4,:);
gl_pos = bsxfun(@rdivide, xtilde(1:3,:), lambda);
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment