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
function cost_edges = computeSTpairCost(detections)
addpath(genpath('/BS/pedestrian-detection-tracking/work/project/3rd/liblinear-1.94/'));
%% pairwise logit model
load /BS/joint-multicut/work/MOT-data/models/pairwise/trainSeq_ADL-Rundle-6/logit_pairwise_position-scale_linear-quadratic_posIou-0.5_negExType-mixed-negIou-0.3_limit_1_L2_frameOffset_1.mat;
num_frame = length(detections);
cost_edges = cell(num_frame);
for i = 1:num_frame-1
fprintf('Compute pairwise cost for frame: %d ', i)
det_1 = detections{i};
% computing pairwise cost between frame i and frame j
j = i+1;
fprintf(' and %d', j)
det_2 = detections{j};
pairwise_prob = compute_pairwise_cost_block(det_1,det_2,model,normalize_ratio);
pairwise_cost = log((1-pairwise_prob)./pairwise_prob);
cost_edges{i,j} = pairwise_cost(:);
end
end
function pairwise_prob = compute_pairwise_cost_block(b1,b2,model,normalize_ratio)
num_det_1 = size(b1,1);
num_det_2 = size(b2,1);
pairwise_prob = zeros(num_det_2,num_det_1);
for d1 = 1 : num_det_1
xc_1 = (b1(d1,1)+b1(d1,3))/2;
yc_1 = (b1(d1,2)+b1(d1,4))/2;
h_1 = b1(d1,4)-b1(d1,2);
w_1 = b1(d1,3)-b1(d1,1);
idx = 1:num_det_2;
xc_list = (b2(idx,1) + b2(idx,3))/2;
yc_list = (b2(idx,2) + b2(idx,4))/2;
h_list = b2(idx,4) - b2(idx,2);
w_list = b2(idx,3) - b2(idx,1);
[~, ~, iou_n] = iou(xc_1, yc_1, h_1, w_1, xc_list, yc_list, h_list, w_list);
f = [];
ave_h = ((b2(idx,4) - b2(idx,2)) + h_1)/2;
offset_h = (h_list-h_1)./ave_h; % h' -h
x = (xc_list - xc_1)./ave_h; %x' - x
y = (yc_list - yc_1)./ave_h; %y' - y
f(:,1) = abs(x);
f(:,2) = abs(y);
f(:,3) = iou_n;
f(:,4) = abs(offset_h);
%% for quadratic kernel
[exp_num, dim] = size(f);
f_quad = zeros(exp_num, (dim-1)*dim/2);
dim_count = 1;
for m = 2:dim
for n = 2:dim
f_quad(:,dim_count) = f(:,m).*f(:,n);
dim_count = dim_count + 1;
end
end
f = [f f_quad];
%%
f = normalize_feature(f, normalize_ratio);
f = sparse(double(f));
label = ones(size(f,1),1);
[~, ~,pro_estimate] = predict(label, f, model, '-b 1 -q');
pairwise_prob(:,d1) = pro_estimate(:,1);
end
end
%