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 80 lines (74 sloc) 2.8 KB
function [detections,edges ,cost_edges] = convertPair2GraphInfo(pairs)
% convert the pairs info to graph info (node, edges, costs of edges) with
% repect to the graph
% node info
node_1 = pairs.globalID1;node_2 = pairs.globalID2; node_all = [node_1;node_2]; edges_all = [node_1, node_2];
box1 = pairs.box1; box2 = pairs.box2; box_all = [box1;box2];
frame1 = pairs.frame1; frame2 = pairs.frame2; frame_all=[frame1; frame2];
det_all = double([box_all, frame_all]);
[~, ia, ~]= unique(node_all);
det_all = det_all(ia,:);
prob_edges = 1-pairs.dist;
num_frame = max(frame_all);
detections = cell(num_frame,1);
edges = cell(num_frame,num_frame);
cost_edges = cell(num_frame,num_frame);
for i = 1:num_frame
fprintf('converting pairs info to graph info for frame %d out of %d \n', i, num_frame);
list_i = find(frame1 == i);
if ~isempty(list_i)
for j = i:num_frame
list_j = find(frame2 == j);
if ~isempty(list_j)
idx = intersect(list_i,list_j);
if ~isempty(idx)
node_i = node_1(idx);
node_j = node_2(idx);
cur_pro = prob_edges(idx);
cost = log((1-cur_pro)./cur_pro);
edges{i,j} = [node_i, node_j] -1;
cost_edges{i,j} = cost;
end
end
end
end
det_list_i = find(det_all(:,end) == i);
if ~isempty(det_list_i)
det_i = det_all(det_list_i,:);
detections{i} = det_i;
end
end
% for i =1:num_frame
% fprintf('converting pairs info to graph info for frame %d out of %d \n', i, num_frame);
% list_i = find(det_all(:,end) == i);
% if ~isempty(list_i)
% det_i = det_all(list_i,:);
% for j = i:num_frame
% list_j = find(det_all(:,end) == j);
% if ~isempty(list_j)
% tmp_comb = [];
% if i==j % same person
% if size(det_i,1)~=1
% tmp_comb = nchoosek(list_i,2);
% end
% else % difference person
% tmp_comb = combvec(list_i',list_j')';
% end
% edges{i,j} = tmp_comb-1;
% cost = zeros(size(tmp_comb,1),1);
% for e = 1:size(tmp_comb,1)
% idx = intersect(find(node_1 == tmp_comb(e,1)),find(node_2 == tmp_comb(e,2)));
% if isempty(idx)
% cost(e) = 10^5; % same frame, assuming the pairs contains a full graph.
% else
% prob = prob_edges(idx);
% cost(e) = log((1-prob)/prob);
% end
% end
% cost_edges{i,j} = cost;
% end
% end
% detections{i} = det_i;
% end
% end
end