Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 84 lines (69 sloc) 2.56 KB
function main(pair_mat)
% Main function to cluster detections to tracks
% read mat info
[~,pair_name,~] = fileparts(pair_mat);
load(pair_mat);
% init param
problem_file = [pair_name '-problem.h5'];
solution_file = [pair_name '-solution.h5'];
solver = 'ILP'; % KL
SP = 1; % use spatio-temporal info
temporal_thr = 1;
% full graph
[detections, edges ,cost_edges] = convertPair2GraphInfo(pairs); % full graph
% use spatio-temporal info - temporal thr must be 1 and overwrite cost_edges;
if SP == 1
assert(temporal_thr ==1)
cost_edges = computeSTpairCost(detections);
end
% sparsify the graph
[cost_selected, edge_selected] = constructGraph(detections,edges,cost_edges,temporal_thr ); % sparsify the graph
% Graph info to h5
if strcmp(solver,'KL')
cost_selected = -cost_selected;
end
nodes = cat(1,detections{:});
costs_vertices = zeros(size(nodes,1),1) +0.5;
M_coordinates_vertices = nodes(:,[1:2 5]);
fprintf('writing problem to hdf5 file ... \n');
dataset_name = 'costs-vertices';
write_mode = 'overwrite';
marray_save(problem_file, dataset_name, costs_vertices, write_mode) % the saved file name, dataset name, saved value
write_mode = 'append';
dataset_name = 'edges';
marray_save(problem_file, dataset_name, edge_selected, write_mode);
dataset_name = 'costs-edges';
marray_save(problem_file, dataset_name, cost_selected, write_mode);
dataset_name = 'coordinates-vertices';
marray_save(problem_file, dataset_name, M_coordinates_vertices, write_mode);
dataset_name = 'edges-cut';
[~,cut_idx] = sort(cost_selected,'descend');
if strcmp(solver,'KL')
M_intra_cut = edge_selected(cut_idx(end-1:end),:);
else
M_intra_cut = edge_selected(cut_idx(1:2),:);
end
marray_save(problem_file, dataset_name,M_intra_cut, write_mode);
% call solver
if strcmp(solver,'KL')
solver= '/BS/multicut_tracking/work/test/people_tracking-build/track-multicut-kl';
elseif strcmp(solver,'ILP')
solver= '/BS/multicut_tracking/work/project/git-people-tracking-build/track-multicut-gurobi';
else
error('solver is not defined !');
end
cmd = [solver ' -p ' problem_file ' -s ' solution_file];
% unix(cmd);
% parse solution to cluster info.
dataset_name = 'labels-vertices';
labels_vertices = marray_load(solution_file, dataset_name);
dataset_name = 'labels-edges';
labels_edges = marray_load(solution_file, dataset_name);
if strcmp(solver,'KL')
labels_edges = -labels_edges;
end
link_matrix = label_link_matrix(edge_selected,labels_edges,length(nodes));
clusters = find_conn_comp(link_matrix);
save([pair_name '-clusters.mat'],'clusters');
cluster_vis(clusters,detections,img_list)
end