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.
58 lines
1.6 KiB
Matlab
58 lines
1.6 KiB
Matlab
function accuracy_ism_cars
|
|
method{1}='Hough';method{2}='PC/BC-DIM';
|
|
spread=2
|
|
numTest=170;
|
|
|
|
%DEFINE CODEBOOK
|
|
load('ISM_codebook_cars.mat');
|
|
Locations=postprocess_codebook(Locations,patchClassList,spread);
|
|
[~,data_dir]=load_image_car(1,3);
|
|
|
|
%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,3);
|
|
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);
|
|
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.txt'],'r');
|
|
dist=[];
|
|
for i=1:numTest
|
|
%find coordinates which have the most votes
|
|
[votes,index]=max(param{i}{m}{1}(3,:));
|
|
coords=param{i}{m}{1}(1:2,index);
|
|
coords=convert_car_coordinates(coords);
|
|
|
|
%read true coordinates from ground truth data file
|
|
coordsTrue=read_result(i,file);
|
|
dist(i)=ism_calc_min_param_distance(coords,coordsTrue);
|
|
end
|
|
median(dist)
|
|
fclose(file);
|
|
end
|
|
|
|
|
|
|
|
function pos=read_result(i,file)
|
|
fscanf(file,'%i: ');
|
|
pos=fscanf(file,'(%i,%i) ');
|
|
pos=reshape(pos,2,length(pos)/2);
|
|
|
|
|
|
function dist=ism_calc_min_param_distance(paramsEst,paramsTrue)
|
|
for i=1:length(paramsEst)
|
|
paramsTrue(i,:)=paramsTrue(i,:)-paramsEst(i);
|
|
end
|
|
dist=min(sqrt(sum(paramsTrue.^2))); |