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

Upload New File

parent f02f9e5a
No related branches found
No related tags found
No related merge requests found
function [Coord,corners_cam] = retrieve_marker_coord(calibname)
% This function opens a DaVis 'MarkPositionTable.xml' file and retrieves the
% the position of markers. In raw image coordinate system (Image plane),
% [X,Y] coordinates are given in pixels while in the world coordinate system
% (Object plane), [x,y,z] coordinates are in mm. This is then returned in
% two matrices corresponding to each camera. This script uses 'xml2struct'.
% It must be searchable in the MATLAB path [Download link:
% https://uk.mathworks.com/matlabcentral/fileexchange/28518-xml2struct]
%
% INPUT VARIABLES:
% filename = pathname of xml file
%
% OUTPUT VARIABLES:
% Coord = Image and object plane coordinates for left and right camera
% Format: 1st column - image plane x coordinates [in pixels]
% 2nd column - image plane y coordinates [in pixels]
% 3rd column - object plane x coordinates [in mm]
% 4th column - object plane y coordinates [in mm]
% 5th column - objetc plane z coordinates [in mm]
% corners_cam = The pixels of the camera's corners
%
%--------------------------------------------------------------------------
% Version 1.0
% Girish K. Jankee (26 January 2018)
%
% Version 2.0
% Eduardo Rodriguez-Lopez (24 April 2018)
% Determination of distance between 2 z-planes is now automated.
%
% Version 2.1
% Girish K. Jankee (26 April 2018)
% Added feature extracts the coordinates of the camera's corners.
%--------------------------------------------------------------------------
%% MAIN CODE
a = xml2struct(calibname);
for i = 1:2
if i == 1
cam_L = cell2mat(a.MarkTable(1).Camera{1,i}.View(1,1).Mark);
else
cam_R = cell2mat(a.MarkTable(1).Camera{1,i}.View(1,1).Mark);
end
end
% Left Camera
posL = zeros(length(cam_L),5);
for j = 1:length(cam_L)
posL(j,1) = str2num(cam_L(j).RawPos(1).Attributes(1).x);
posL(j,2) = str2num(cam_L(j).RawPos(1).Attributes(1).y);
posL(j,3) = str2num(cam_L(j).WorldPos(1).Attributes(1).x);
posL(j,4) = str2num(cam_L(j).WorldPos(1).Attributes(1).y);
posL(j,5) = str2num(cam_L(j).WorldPos(1).Attributes(1).z);
end
% keyboard
thickL=abs(mean(posL( posL(:,5)~=0, 5 )));
posL( abs(posL(:,5)+thickL)<1e-10, 5 ) = -thickL/2 ;
posL( abs(posL(:,5)-0 )<1e-10, 5 ) = thickL/2 ;
% Right Camera
posR = zeros(length(cam_R),5);
for j = 1:length(cam_R)
posR(j,1) = str2num(cam_R(j).RawPos(1).Attributes(1).x);
posR(j,2) = str2num(cam_R(j).RawPos(1).Attributes(1).y);
posR(j,3) = str2num(cam_R(j).WorldPos(1).Attributes(1).x);
posR(j,4) = str2num(cam_R(j).WorldPos(1).Attributes(1).y);
posR(j,5) = str2num(cam_R(j).WorldPos(1).Attributes(1).z);
end
thickR=abs(mean(posR( posR(:,5)~=0, 5 )));
posR( abs(posR(:,5)+thickR)<1e-10, 5 ) = -thickR/2 ;
posR( abs(posR(:,5)-0 )<1e-10, 5 ) = thickR/2 ;
if thickR~=thickL
error('thickness are not the same!!!')
end
Coord.Left = posL;
Coord.Right = posR;
height = str2num(a.MarkTable(1).Camera{1,1}.Attributes.Height);
width = str2num(a.MarkTable(1).Camera{1,1}.Attributes.Width);
corners_cam = [0 width width 0
0 0 height height]; % the pixels of the camera's corners
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment