-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualizeSpaces.m
More file actions
40 lines (33 loc) · 1.45 KB
/
visualizeSpaces.m
File metadata and controls
40 lines (33 loc) · 1.45 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
function [parked, avail] = visualizeSpaces(rgbTestImage, props, centroids, percentageFilled)
hFig2 = figure(1);
imshow(rgbTestImage);
hFig2.WindowState = 'maximized';
hFig2.Name = 'Available Parking with Counter';
hold on;
parkedCount = 0;
freeCount = 0;
parked = [];
avail = [];
for k = 1 : length(props)
x = centroids(k, 1);
y = centroids(k, 2);
if props(k).Area > 100
if percentageFilled(k) > 0.40
parked = [parked k];
parkedCount = parkedCount + 1;
parkedLabel = sprintf('%d',k);
text(x, y + 20, parkedLabel, 'Color', 'r', 'FontSize', 15, 'FontWeight', 'bold');
rectangle('Position', props(k).BoundingBox, 'EdgeColor', 'r','LineWidth',1);
else
avail = [avail k];
freeCount = freeCount + 1;
freeLabel = sprintf('%d',k);
text(x, y + 20, freeLabel, 'Color', 'g', 'FontSize', 15, 'FontWeight', 'bold');
rectangle('Position', props(k).BoundingBox, 'EdgeColor', 'g','LineWidth',1);
end
end
end
text(25, 15, strcat("Available: ",sprintf('%d',freeCount)), 'Color', 'g', 'FontSize', 24, 'FontWeight', 'bold');
text(25, 28, strcat("Taken: ",sprintf('%d',parkedCount)), 'Color', 'r', 'FontSize', 24, 'FontWeight', 'bold');
title('Marked Spaces. Green Spot = Available. Red = Taken.', 'FontSize', 12);
end