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.

50 lines
1.3 KiB
Matlab

function stats=lines_detection_accuracy(stats,theta_rho_est,theta_rho_true);
num_lines=size(theta_rho_true,2);
num_lines_est=size(theta_rho_est,2);
%sort so that closest points are matched first
if num_lines>1 && num_lines_est>0
for i=1:num_lines
dist(i)=min(sum(lines_calc_param_distance(theta_rho_est,theta_rho_true(:,i))));
end
[~,order]=sort(dist,'ascend');
theta_rho_true=theta_rho_true(:,order);
end
%calc errors
FN=0;
correctT=zeros(1,num_lines);
correctE=zeros(1,num_lines_est);
if num_lines_est==0
FN=num_lines;
else
for i=1:num_lines
dist=lines_calc_param_distance(theta_rho_est,theta_rho_true(:,i));
[~,order]=sort(sum(dist),'ascend');
matched=false;
for j=order
if dist(1,j)<=4 && dist(2,j)<=5 && correctE(j)==0
%disp([int2str(i),'<>',int2str(j),': ',num2str(dist(1,j)),', ',num2str(dist(2,j))])
correctT(i)=1;
correctE(j)=1;
matched=true;
break;
end
end
if ~matched
FN=FN+1;
end
end
end
%correctT
%correctE
TP=sum(correctT);
FP=length(correctE)-sum(correctE);
stats=stats+[TP,FP,FN];
function dist=lines_calc_param_distance(theta_rho1,theta_rho2)
dist(1,:)=min(abs(theta_rho1(1,:)-theta_rho2(1,:)),abs(-theta_rho1(1,:)-theta_rho2(1,:)));
dist(2,:)=min(abs(theta_rho1(2,:)-theta_rho2(2,:)),abs(-theta_rho1(2,:)-theta_rho2(2,:)));