-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraft.m
More file actions
81 lines (73 loc) · 2.8 KB
/
Copy pathdraft.m
File metadata and controls
81 lines (73 loc) · 2.8 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
clear cam
cam = webcam('USB2.0 Camera');
net = squeezenet;
sz = net.Layers(1).InputSize;
f = figure;
scoresIdx = 1;
ScoresIdxMax = 100;
scores = zeros([1,ScoresIdxMax]);
bug = true;
while isvalid(f)
img = snapshot(cam);
[Y, score] = classify(net, imresize(img, sz(1:2)), 'ExecutionEnvironment', 'gpu');
score = max(score)*100;
scores(scoresIdx) = mean([scores(mod(scoresIdx - (1:2) - 1,ScoresIdxMax)+1), score]);
disp(['I think it''s a ' char(Y) ' (' num2str(round(score)) '% sure)']);
if isvalid(f)
try
subplot(4,5,[2:4, 7:9, 12:14, 17:19]);
imshow(img);
title(['I think it''s a ' char(Y) ' (' num2str(round(score)) '% sure)']);
% subplot(4,5,17:19);
% yyaxis left
% plot(scores);
% hold on
% plot([scoresIdx, scoresIdx], [0, 100], 'k:');
% hold off
% ylim([0 100]);
% xlim([0 ScoresIdxMax]);
% xticks(scoresIdx);
% xticklabels({});
% ticks = 0:20:100;
% yticks(ticks);
% yticklabels(num2cell(ticks));
% ytickformat('percentage');
% grid on
% yyaxis right
% plot([0, ScoresIdxMax], [scores(scoresIdx), scores(scoresIdx)], 'r');
% ylim([0 100]);
% yticks(round(scores(scoresIdx)));
% yticklabels(num2str(round(scores(scoresIdx))));
% ytickformat('percentage');
subplot(8, 20, 20*(1:6)+3);
if bug
b = bar(0);
bug = false;
else
b = bar(scores(scoresIdx));
end
% b.FaceColor = [0.8500 0.3250 0.0980];
j = jet(64);
colormap(flip(j(32:58, :)));
c = colormap;
b.FaceColor = c(round(size(c,1)*scores(scoresIdx)/100), :);
% colorbar
ylim([0 100]);
xticks([]);
xticklabels({});
ticks = 0:20:100;
yticks(ticks);
yticklabels(num2cell(ticks));
ytickformat('percentage');
grid on
yyaxis right
ylim([0 100]);
yticks(round(scores(scoresIdx)));
yticklabels(num2str(round(scores(scoresIdx))));
ytickformat('percentage');
drawnow
catch ME
end
end
scoresIdx = mod(scoresIdx, ScoresIdxMax) + 1;
end