forked from pxnguyen/videotext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_chardetSVM_exp.m
52 lines (47 loc) · 1.57 KB
/
run_chardetSVM_exp.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
% This script runs all the experiments for the chardet_exp
[dPath,ch]=globals;
clfPath=fullfile('data','models_real_nomixture.mat');
fmodel=load(clfPath);
models = fmodel.models;
test_dataset = fullfile(dPath,'icdar','test','images');
output_path = fullfile(dPath,'icdar','test','det_results_real');
%% Actually running the SVM
image_paths = dir(fullfile(test_dataset,'*.jpg'));
nImg = length(image_paths);
%ticId=ticStatus('Running PLEX on full images',1,30,1);
saveRes=@(f,bbs)save(f,'bbs');
parfor i=1:nImg
bbs = [];
current_image = image_paths(i).name;
fprintf('Working on index: %d, image: %s\n',i,current_image);
sF = fullfile(output_path,[current_image '.mat']);
if exist(sF,'file') > 0
fprintf('%s already exists. Skipped\n',sF);
continue
end
I = imread(fullfile(test_dataset,current_image));
try
bbs=charDetSVM(I,models,{});
catch e
fprintf('Error at index %d\n',i);
continue
end
% save the bbs
saveRes(sF,bbs);
%tocStatus(ticId,i/nImg);
end
%% Calculating the F-score for the characters
gtDir = fullfile(dPath,'icdar','test','charAnn');
fscores = zeros(length(ch),1);
ticId=ticStatus('Collecting Fscore',1,30,1);
for char_index = 11
[gt0,~] = bbGt('loadAll',gtDir,[],{'lbls',ch(char_index)});
dt0 = loadBB(output_path,char_index);
current_char = ch(char_index);
% filter out the groundtruth
[gt,dt] = bbGt( 'evalRes', gt0, dt0);
[xs,ys,sc]=bbGt('compRoc', gt, dt, 0);
fs = Fscore(xs,ys);
fscores(char_index) = fs;
tocStatus(ticId,char_index/(length(ch)));
end