-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_annotation_box_csv.m
More file actions
44 lines (43 loc) · 2 KB
/
make_annotation_box_csv.m
File metadata and controls
44 lines (43 loc) · 2 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
%F = 'OTZ_AR43_15Mar2020_001';
%F = 'OTZ_AR43_13Mar2020_013';
p = '\\vortex\share\otz-data\AR43_Stingray\AR43_ROI_adj\features\';
Fall = dir([p '*.mat']);
max_width = 2330;
max_height = 1750;
max_pixel = [max_width max_height max_width max_height];
for ii = 1:length(Fall) %8, 15
F = regexprep(Fall(ii).name, '.mat', '');
disp(F)
load(['\\vortex\share\otz-data\AR43_Stingray\AR43_ROI_adj\features\' F ])
disp('loading class results')
box_annotation = table;
f = ['\\vortex\share\otz-data\AR43_Stingray\run-output\v3\AR43_20220308_0\' F '_img_results.json'];
if exist(f, 'file')
S = jsondecode(fileread(f));
pid = regexprep(S.input_images, '.png', '');
temp = split(pid,'_');
frame = temp(:,8);
box_annotation.frame = str2num(char(frame));
[~,ib] = ismember(pid,Props.roiID);
box_annotation = [box_annotation array2table((Props.BoundingBox(ib,:)-[.5 .5 0 0])./max_pixel, 'VariableNames', {'x', 'y','width', 'height'})];
box_annotation.class = S.class_labels(S.output_classes+1);
end
%now get the small ones
disp('loading class results for small ROIs')
box_annotation2 = table;
f = ['\\vortex\share\otz-data\AR43_Stingray\run-output\v3\AR43_20220308_0\' F filesep 'small_img_results.json'];
if exist(f, 'file')
S = jsondecode(fileread(f));
pid = regexprep(S.input_images, '.png', '');
temp = split(pid,'_');
frame = temp(:,8);
box_annotation2.frame = str2num(char(frame));
[~,ib] = ismember(pid,Props.roiID);
box_annotation2 = [box_annotation2 array2table((Props.BoundingBox(ib,:)-[.5 .5 0 0])./max_pixel, 'VariableNames', {'x', 'y','width', 'height'})];
box_annotation2.class = S.class_labels(S.output_classes+1);
end
box_annotation = [box_annotation; box_annotation2];
disp('saving bounding box output')
writetable(box_annotation, ['\\vortex\share\otz-data\AR43_Stingray\AR43_ROI_adj\BoundingBox_csv\' F '.csv'])
clear box_annotation
end