forked from Cloud-CV/object-proposals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObjectProposals.m
70 lines (66 loc) · 2.49 KB
/
ObjectProposals.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
64
65
66
67
68
69
70
function varargout = ObjectProposals(varargin)
%if not inputs are provided, this will run for all images in the imageLocation of configjson
%first input should be the proposal name. If
global configjson;
varargout={};
if(~isempty(varargin))
if(nargin==1)
proposalName = varargin{1};
funcName = sprintf('calc%s', char(proposalName));
try
fh = makeHandle(funcName);
fh(configjson);
catch exc
fprintf('***************Error running %s*****************\n', funcName);
msgString = getReport(exc);
fprintf(msgString);
end
elseif(nargin==2)
proposalName = varargin{1};
imageInput=varargin{2};
funcName = sprintf('calc%sForIm', char(proposalName));
try
fh = makeHandle(funcName);
varargout{1} = fh( imageInput, configjson.(char(proposalName)));
catch exc
fprintf('***************Error running %s********************\n', funcName);
msgString = getReport(exc);
fprintf(msgString);
end
elseif(nargin==3)
proposalName = varargin{1};
imageInput=varargin{2};
numProposals=varargin{3};
%set numProposals in opts
configjson.(char(proposalName)).opts.numProposals=numProposals;
funcName = sprintf('calc%sForIm', char(proposalName));
try
fh = makeHandle(funcName);
varargout{1} = fh( imageInput, configjson.(char(proposalName)));
catch exc
fprintf('****Error running %s ********\n', funcName);
msgString = getReport(exc);
fprintf(msgString);
end
end
else
% if varargin is empty, run all proposals on all images in the image location with default proposals
proposalNames = fieldnames(configjson);
for i = 1:length(proposalNames)
if((strcmp(proposalNames(i), 'imageLocation')==1 || strcmp(proposalNames(i), 'outputLocation')==1 || strcmp(proposalNames(i), 'params')==1))
continue;
else
try
funcName = sprintf('calc%s', char(proposalNames(i)));
fh = makeHandle(funcName);
fh(configjson);
catch
fprintf('Error running %s\n', funcName);
end
end
end
end
end
function handle = makeHandle(funcName)
handle = str2func(funcName);
end