Skip to content

Commit

Permalink
ENH: Add Enums to MATLAB
Browse files Browse the repository at this point in the history
  • Loading branch information
NicerNewerCar committed Jul 27, 2023
1 parent ebcd91d commit 511ef47
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
35 changes: 28 additions & 7 deletions scripts/matlab/AutoscoperConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,25 @@ function optimizeFrame(obj, volNum, frameNum, repeats, max_itr, min_lim, max_lim
dframe = 1;
end
if nargin < 10
opt_method = 0;
opt_method = OptimizationMethod.PARTICLE_SWARM_OPTIMIZATION;
end
if nargin < 11
cf_model = 0;
cf_model = CostFunction.NORMALIZED_CROSS_CORRELATION;
end
if nargin < 12
opt_init_heuristic = 0;
opt_init_heuristic = OptimizationInitializationHeuristic.PREVIOUS_FRAME;
end

if ~isenum(opt_method)
opt_method = OptimizationMethod(opt_method);
end
if ~isenum(cf_model)
cf_model = CostFunction(cf_model);
end
if ~isenum(opt_init_heuristic)
opt_init_heuristic = OptimizationInitializationHeuristic(opt_init_heuristic);
end

fwrite(obj.socket_descriptor, [ ...
11 ...
typecast(int32(volNum), 'uint8') ...
Expand Down Expand Up @@ -421,13 +432,23 @@ function trackingDialog(obj, volNum, startframe, endframe, repeats, max_itr, min
dframe = 1;
end
if nargin < 11
opt_method = 0;
opt_method = OptimizationMethod.PARTICLE_SWARM_OPTIMIZATION;
end
if nargin < 12
cf_model = 0;
cf_model = CostFunction.NORMALIZED_CROSS_CORRELATION;
end
if nargin < 13
opt_init_heuristic = 0;
opt_init_heuristic = OptimizationInitializationHeuristic.PREVIOUS_FRAME;
end

if ~isenum(opt_method)
opt_method = OptimizationMethod(opt_method);
end
if ~isenum(cf_model)
cf_model = CostFunction(cf_model);
end
if ~isenum(opt_init_heuristic)
opt_init_heuristic = OptimizationInitializationHeuristic(opt_init_heuristic);
end

for i = startframe:endframe
Expand Down Expand Up @@ -494,4 +515,4 @@ function trackingDialog(obj, volNum, startframe, endframe, repeats, max_itr, min
end

end
end
end
6 changes: 6 additions & 0 deletions scripts/matlab/CostFunction.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
classdef CostFunction < int32
enumeration
NORMALIZED_CROSS_CORRELATION (0)
SUM_OF_ABSOLUTE_DIFFERENCES (1)
end
end
8 changes: 8 additions & 0 deletions scripts/matlab/OptimizationInitializationHeuristic.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
classdef OptimizationInitializationHeuristic < int32
enumeration
CURRENT_FRAME (0)
PREVIOUS_FRAME (1)
LINEAR_EXTRAPOLATION (2)
SPLINE_INTERPOLATION (3)
end
end
6 changes: 6 additions & 0 deletions scripts/matlab/OptimizationMethod.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
classdef OptimizationMethod < int32
enumeration
PARTICLE_SWARM_OPTIMIZATION (0)
DOWNHILL_SIMPLEX (1)
end
end

0 comments on commit 511ef47

Please sign in to comment.