-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.m
54 lines (44 loc) · 1.52 KB
/
test.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
% Feel free changing any thing in this script except the interface of
% pokemon_stats and the name of "model.mat". The final test script will be
% almost the same as this. The only thing you need to submit is
% pokemon_stats.m and model.mat.
clear all; clc; close all;
img_path = './val/';
img_dir = dir([img_path,'*CP*']);
img_num = length(img_dir);
model1=load ('./model.mat');
ID_gt = zeros(img_num,1);
CP_gt = zeros(img_num,1);
HP_gt = zeros(img_num,1);
stardust_gt = zeros(img_num,1);
ID = zeros(img_num,1);
CP = zeros(img_num,1);
HP = zeros(img_num,1);
stardust = zeros(img_num,1);
for i = 1:img_num
close all;
img = imread([img_path,img_dir(i).name]);
% get ground truth annotation from image name
name = img_dir(i).name;
ul_idx = findstr(name,'_');
ID_gt(i) = str2num(name(1:ul_idx(1)-1));
CP_gt(i) = str2num(name(ul_idx(1)+3:ul_idx(2)-1));
HP_gt(i) = str2num(name(ul_idx(2)+3:ul_idx(3)-1));
stardust_gt(i) = str2num(name(ul_idx(3)+3:ul_idx(4)-1));
[ID(i), CP(i), HP(i), stardust(i), level, cir_center] = pokemon_stats (img, model1);
imshow(img); hold on;
plot(level(1),level(2),'b*');
plot(cir_center(1),cir_center(2),'g^');
end
accuracy_ID = sum(ID_gt==ID) / img_num;
accuracy_CP = sum(CP_gt==CP) / img_num;
accuracy_HP = sum(HP_gt==HP) / img_num;
accuracy_stardust = sum(stardust_gt==stardust) / img_num;
disp(' accuracy_ID')
disp(accuracy_ID)
disp(' accuracy_CP')
disp(accuracy_CP)
disp(' accuracy_HP')
disp(accuracy_HP)
disp(' accuracy_stardust')
disp(accuracy_stardust)