%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PROJECT: % Partical Filtering Course - Test Data % % BY: % Parthipan Siva % Assignment for SD 770-7: Topics in Particle Filtering % Systems Design Engineering % University of Waterloo % % DATE/Version: % Jan. 2005 - V 1.0 % % Description: getGroundTruth.m % Reads the ground truth text file for the PETS 2004 % benchmark test data. Only individual rectangles (iblst) % data are read. For the idividual rectangles only the % location, dimensions and direction of the rect is read. % % References: % http://www-prima.inrialpes.fr/PETS04/caviar_data.html % % Project file list: % getGroundTruth.m % drawEllipse.m % showVideo.m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % INPUTS: % fileName - the name of the ground truth txt file. Include .txt % extension and directory path if needed. % startFrame - the frame number at which to start reading data. % Note ground truth file starts frame numbers at 0. % endFrame - the frame number at whcih to stop reading data. % % OUTPUTS: % ListOfPoints - nx7 matrix containing [frameID rectID % col_rectCent row_rectCent widthRect heightRect % orientationRect]. n = endFrame-startFrame+1 % frameID is returned such that first frame in the % image sequence is 1 not 0. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [ListOfPoints] = getGroundTruth(fileName, startFrame, endFrame) fid = fopen(fileName, 'r'); % skip to the correct frame for i = 0:(startFrame-2) C = textscan(fid, '%*[^\n]', 1); end ListOfPoints = []; for i = startFrame:endFrame % read the 1st 4 string C = textscan(fid, '%s', 4); % the third of the 4 read string is the frame number. Ensure that the % frame numbering starts at 1 not 0. frameNum = str2num(C{1}{3}) + 1; % read all individual rectangles C1 = textscan(fid, 'ib %f %f %f %f %f %f %*[^e] %*s'); % store individual rectangle specs as well as frame num in an array ListOfPoints = [ListOfPoints; [frameNum*ones(size(C1{1})) C1{1} C1{2} C1{3} C1{4} C1{5} C1{6}]]; % ignore everything after individual rectangle list to the end of the % line C = textscan(fid, '%[^\n]',1); end fid = fclose(fid);