-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathComparisonWithReal.m
42 lines (36 loc) · 1.09 KB
/
ComparisonWithReal.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
function [done] = ComparisonWithReal(IMG,NAME)
figure;
imshow(IMG);
hold on;
tmpName = extractBefore(NAME,'.jpg');
PATH_REAL = "Data/" + tmpName + ".txt";
fileID = fopen(PATH_REAL{1},'r');
formatSpec = ' %d ';
BoundingData = fscanf(fileID,formatSpec);
[realObjectCount,~] = size(BoundingData);
realObjectCount = (realObjectCount - 1)/4;
paintcolor = [0 1 0]; %rGreen
for i=1:realObjectCount
rtopX = BoundingData(1 + (4*(i-1)),1);
rtopY = BoundingData(2 + (4*(i-1)),1);
rlowX = BoundingData(3 + (4*(i-1)),1);
rlowY = BoundingData(4 + (4*(i-1)),1);
realWidth = 0;
if rlowX > rtopX
realWidth = rlowX-rtopX;
else
realWidth = rtopX-rlowX;
end
realHeight = 0;
if rlowY > rtopY
realHeight = rlowY-rtopY ;
else
realHeight = rtopY-rlowY;
end
rectangle('Position', [rtopX, rtopY, realWidth, realHeight], 'EdgeColor', paintcolor,'LineWidth',0.4);
end
Image = getframe(gcf);
FILENAME = sprintf('%s%s%s',"detection_",tmpName, ".png");
imwrite(Image.cdata, FILENAME);
done = true;
end