-
Notifications
You must be signed in to change notification settings - Fork 0
/
amountMoney.m
56 lines (50 loc) · 2.31 KB
/
amountMoney.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
55
56
function amountMoney(t, inds, imageProps, coin1CentP, delta1Cent, ...
coin2CentP, delta2Cent, coin10CentP, delta10Cent, coin5CentP, ...
delta5Cent, coin20CentP, delta20Cent, coin1EurP, delta1Eur, ...
coin50CentP, delta50Cent, width, originalImage)
delete(t);
while (true)
%Total Value
value = 0.0;
for q=1:length(inds)
if (0.98 < imageProps(q).Circularity) && (imageProps(q).Circularity < 1.1)
if (coin1CentP - delta1Cent < imageProps(q).Area) && (imageProps(q).Area < coin1CentP + delta1Cent)
value = value + 0.01;
end
if (coin2CentP - delta2Cent < imageProps(q).Area) && (imageProps(q).Area < coin2CentP + delta2Cent)
value = value + 0.02;
end
if (coin10CentP - delta10Cent < imageProps(q).Area) && (imageProps(q).Area < coin10CentP + delta10Cent)
value = value + 0.10;
end
if (coin5CentP - delta5Cent < imageProps(q).Area) && (imageProps(q).Area < coin5CentP + delta5Cent)
value = value + 0.05;
end
if (coin20CentP - delta20Cent < imageProps(q).Area) && (imageProps(q).Area < coin20CentP + delta20Cent)
value = value + 0.20;
end
if (coin1EurP - delta1Eur < imageProps(q).Area) && (imageProps(q).Area < coin1EurP + delta1Eur)
value = value + 1.00;
end
if (coin50CentP - delta50Cent < imageProps(q).Area) && (imageProps(q).Area < coin50CentP + delta50Cent)
value = value + 0.50;
end
end
end
values = {num2str(value), char(8364)};
valueText = strjoin(values, ' ');
commandsA = {'Amount of money in image:', valueText, ' ', 'Press:', 'q - quit'};
commandsAText = strjoin(commandsA, '\n');
t = text(width + 50, 200, commandsAText, 'FontWeight', 'bold');
t.BackgroundColor = 'w';
t.Color = 'k';
t.FontSmoothing = 'on';
t.FontSize = 13;
t.Margin = 5;
[xo, yo, buttonA] = ginput(1);
if (buttonA == 113) % Press q to quit
delete(t);
imshow(originalImage);
break;
end
end