You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.8 KiB
Matlab
62 lines
1.8 KiB
Matlab
function accuracy_ism_carsScale
|
|
method{1}='Hough';method{2}='PC/BC-DIM';
|
|
spread=2
|
|
numTest=108;
|
|
scales=1.2.^[-1:4];
|
|
|
|
%DEFINE CODEBOOK
|
|
load('ISM_codebook_carsScale.mat');
|
|
Locations=postprocess_codebook(Locations,patchClassList,spread,scales);
|
|
[~,data_dir]=load_image_car(1,4);
|
|
|
|
%FOR EACH TEST IMAGE PERFORM ISM TO LOCATE CARS
|
|
disp(['Processing Images (',int2str(numTest),')'])
|
|
param{numTest}{length(method)}=[];%pre-allocate memory
|
|
for i=1:numTest
|
|
fprintf(1,'.%i.',i);
|
|
%load image and display
|
|
I = load_image_car(i-1,4);
|
|
figured(2),clf, imagesc(I), hold on, axis('equal','tight'); title(' ');
|
|
colormap('gray');
|
|
|
|
%APPLY METHODS
|
|
[param{i}{1},param{i}{2}]=ism_compare_methods(I,patches,patchClassList,Locations,similarityThres,scales);
|
|
end
|
|
|
|
%FOR EACH METHOD FIND ACCURACY WITH WHICH THE CAR POSITION IS LOCATED
|
|
for m=1:length(method)
|
|
disp(' ');
|
|
disp([method{m}]);
|
|
|
|
file=fopen([data_dir,'/trueLocations_Scale.txt'],'r');
|
|
dist=[];scaleError=[];
|
|
for i=1:numTest
|
|
%find coordinates which have the most votes
|
|
[votes,index]=max(param{i}{m}{1}(4,:));
|
|
coords=param{i}{m}{1}(1:2,index);
|
|
scale=param{i}{m}{1}(3,index);
|
|
[coords,width]=convert_car_coordinates(coords,scale);
|
|
|
|
%read true coordinates from ground truth data file
|
|
coordsTrue=read_result(i,file);
|
|
[dist(i),scaleError(i)]=ism_calc_min_param_distance([coords;width],coordsTrue);
|
|
end
|
|
median(dist)
|
|
median(scaleError)
|
|
fclose(file);
|
|
end
|
|
|
|
|
|
|
|
function pos=read_result(i,file)
|
|
fscanf(file,'%i: ');
|
|
pos=fscanf(file,'(%i,%i,%i) ');
|
|
pos=reshape(pos,3,length(pos)/3);
|
|
|
|
|
|
function [dist,scaleErr]=ism_calc_min_param_distance(paramsEst,paramsTrue)
|
|
for i=1:length(paramsEst)
|
|
paramsTrue(i,:)=paramsTrue(i,:)-paramsEst(i);
|
|
end
|
|
[dist,ind]=min(sqrt(sum(paramsTrue(1:2,:).^2)));
|
|
scaleErr=abs(paramsTrue(3,ind)); |