提交 f1b02eb9 编写于 作者: M Marius Muja

Matlab bindings fixes in order to run on Octave. (Thanks Daniel Franke)

上级 a43cfd10
......@@ -70,7 +70,7 @@ elseif(OCT_CMD)
ADD_CUSTOM_COMMAND(
OUTPUT ${MEX_FILE}
COMMAND ${OCT_CMD}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp -I${PROJECT_SOURCE_DIR}/src/cpp -L${FLANN_LIB_PATH} -DFLANN_STATIC -lflann_s --mex
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp -I${PROJECT_SOURCE_DIR}/src/cpp -L${FLANN_LIB_PATH} -DFLANN_STATIC -lflann_s -lgomp --mex
DEPENDS flann_s ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp
COMMENT "Building MEX extension ${MEX_FILE}"
)
......
......@@ -9,19 +9,6 @@ function [index, params, speedup] = flann_build_index(dataset, build_params)
algos = struct( 'linear', 0, 'kdtree', 1, 'kmeans', 2, 'composite', 3, 'kdtree_single', 4, 'hierarchical', 5, 'lsh', 6, 'saved', 254, 'autotuned', 255 );
center_algos = struct('random', 0, 'gonzales', 1, 'kmeanspp', 2 );
log_levels = struct('none', 0, 'fatal', 1, 'error', 2, 'warning', 3, 'info', 4);
function value = id2value(map, id)
fields = fieldnames(map);
for i = 1:length(fields),
val = cell2mat(fields(i));
if map.(val) == id
value = val;
break;
end
end
end
function id = value2id(map,value)
id = map.(value);
end
default_params = struct('algorithm', 'kdtree' ,'checks', 32, 'eps', 0.0, 'sorted', 1, 'max_neighbors', -1, 'cores', 1, 'trees', 4, 'branching', 32, 'iterations', 5, 'centers_init', 'random', 'cb_index', 0.4, 'target_precision', 0.9,'build_weight', 0.01, 'memory_weight', 0, 'sample_fraction', 0.1, 'log_level', 'warning', 'random_seed', 0);
......@@ -54,3 +41,17 @@ function [index, params, speedup] = flann_build_index(dataset, build_params)
params.centers_init = id2value(center_algos,params.centers_init);
end
end
function value = id2value(map, id)
fields = fieldnames(map);
for i = 1:length(fields),
val = cell2mat(fields(i));
if map.(val) == id
value = val;
break;
end
end
end
function id = value2id(map,value)
id = map.(value);
end
......@@ -37,23 +37,9 @@ function [indices, dists] = flann_search(data, testset, n, search_params)
algos = struct( 'linear', 0, 'kdtree', 1, 'kmeans', 2, 'composite', 3, 'saved', 254, 'autotuned', 255 );
center_algos = struct('random', 0, 'gonzales', 1, 'kmeanspp', 2 );
log_levels = struct('none', 0, 'fatal', 1, 'error', 2, 'warning', 3, 'info', 4);
function value = id2value(map, id)
fields = fieldnames(map);
for i = 1:length(fields),
val = cell2mat(fields(i));
if map.(val) == id
value = val;
break;
end
end
end
function id = value2id(map,value)
id = map.(value);
end
default_params = struct('algorithm', 'kdtree' ,'checks', 32, 'eps', 0.0, 'sorted', 1, 'max_neighbors', -1, 'cores', 1, 'trees', 4, 'branching', 32, 'iterations', 5, 'centers_init', 'random', 'cb_index', 0.4, 'target_precision', 0.9,'build_weight', 0.01, 'memory_weight', 0, 'sample_fraction', 0.1, 'log_level', 'warning', 'random_seed', 0);
if ~isstruct(search_params)
error('The "search_params" argument must be a structure');
end
......@@ -82,3 +68,17 @@ function [indices, dists] = flann_search(data, testset, n, search_params)
[indices,dists] = nearest_neighbors('find_nn', data, testset, n, params);
end
end
function value = id2value(map, id)
fields = fieldnames(map);
for i = 1:length(fields),
val = cell2mat(fields(i));
if map.(val) == id
value = val;
break;
end
end
end
function id = value2id(map,value)
id = map.(value);
end
......@@ -30,10 +30,6 @@ function flann_set_distance_type(type, order)
% Marius Muja, March 2009
distances = struct('euclidean', 1, 'manhattan', 2, 'minkowski', 3, 'max_dist', 4, 'hik', 5, 'hellinger', 6, 'chi_square', 7, 'cs', 7, 'kullback_leibler', 8, 'kl', 8);
function id = value2id(map,value)
id = map.(value);
end
if ~isnumeric(type),
type = value2id(distances,type);
......@@ -43,3 +39,7 @@ function flann_set_distance_type(type, order)
end
nearest_neighbors('set_distance_type', type, order);
end
function id = value2id(map,value)
id = map.(value);
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册