-
Notifications
You must be signed in to change notification settings - Fork 0
/
createCMSOJSON.m
24 lines (21 loc) · 1.04 KB
/
createCMSOJSON.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
function createCMSOJSON(imageId, saveResults, addTracksData)
imageId = num2str(imageId);
fileText = fileread('template.json');
jsonData = jsondecode(fileText);
jsonData.resources(1).path = ['objects_' imageId '.csv'];
jsonData.resources(2).path = ['links_' imageId '.csv'];
if addTracksData
jsonData.resources(3) = jsonData.resources(2);
jsonData.resources(3).name = 'cmso_tracks_table';
jsonData.resources(3).path = ['tracks_' imageId '.csv'];
jsonData.resources(3).schema.fields(1).name = 'cmso_track_id';
jsonData.resources(3).schema.fields(2).name = 'cmso_link_id';
jsonData.resources(3).schema.foreignKeys.fields = 'cmso_link_id';
jsonData.resources(3).schema.foreignKeys.reference(1).fields = 'cmso_link_id';
jsonData.resources(3).schema.foreignKeys.reference(1).resource = 'cmso_links_table';
end
%At the moment the JSON file is not indented and on one line only.
jsonOut = jsonencode(jsonData);
fid = fopen([saveResults.dir 'CMSO_' imageId '.json'], 'w');
fprintf(fid, '%s', jsonOut);
fclose(fid);