-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathfetchExampleData.m
64 lines (42 loc) · 1.78 KB
/
fetchExampleData.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
57
58
59
60
61
62
63
function fetchExampleData(exampleName)
%fetchExampleData Download example data files.
% fetchExampleData(exampleName) downloads ZIP files for use with
% RVC Toolbox examples and extracts the data into the toolbox/examples
% folder. exampleName is a string corresponding to the example name.
% Valid options for exampleName string are: "Mosaicing" and
% "VisualOdometry".
% Copyright 2022-2023 Peter Corke, Witold Jachimczyk, Remo Pillat
arguments
exampleName (1,1) string {mustBeMember(exampleName,["Mosaicing","VisualOdometry"])}
end
switch exampleName
case "VisualOdometry"
fetchedFile = fetchFromWeb("bridge-l.zip");
outputFolder = fullfile("visodom", "left");
unpackFile(fetchedFile, outputFolder);
fetchedFile = fetchFromWeb("bridge-r.zip");
outputFolder = fullfile("visodom", "right");
unpackFile(fetchedFile, outputFolder);
case "Mosaicing"
fetchedFile = fetchFromWeb("mosaicml.zip");
outputFolder = "mosaic";
unpackFile(fetchedFile, outputFolder);
otherwise
error("Valid choices for exampleName are: VisualOdometry, Mosaicing");
end
end
function fetchedFile = fetchFromWeb(fetchThisFile)
rootUrlLocation = "https://petercorke.com/files/images/";
disp("Fetching " + fetchThisFile +". This can take a while...")
fileUrl = rootUrlLocation + fetchThisFile;
disp("File was downloaded.")
fetchedFile = fullfile(tempdir, fetchThisFile);
websave(fetchedFile, fileUrl);
end
function unpackFile(fetchedFile, outputFolder)
disp("Unpacking the ZIP file...")
examplesRootFolder = fullfile(rvctoolboxroot, "examples");
outputFullPathFolder = fullfile(examplesRootFolder, outputFolder);
unzip(fetchedFile, outputFullPathFolder);
disp("Done. Unpacked data is in " + outputFullPathFolder)
end