diff --git a/tracking/getScalePatch.m b/tracking/getScalePatch.m index 03149bd..f7ea495 100644 --- a/tracking/getScalePatch.m +++ b/tracking/getScalePatch.m @@ -1,24 +1,26 @@ +function out = getScalePatch(img, pos, target_size, search_size, scale_window, scale_model_sz, hog_scale_cell_size) % KCC: Kernel Cross-Correlator % Visual Tracking Using KCC % % Copyright (C) 2017 % Author: Wang Chen wang.chen@zoho.com Nanyang Technological University % Zhang Le zhang.le@adsc.com Advanced Digital Sciences Center -% This program is free software: you can redistribute it and/or modify +% +% This file is part of KCC. +% +% KCC is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. -% This program is distributed in the hope that it will be useful, +% +% KCC is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. +% % You should have received a copy of the GNU General Public License -% along with this program. If not, see . - - -function out = getScalePatch(img, pos, target_size, search_size, scale_window, scale_model_sz, hog_scale_cell_size) +% along with KCC. If not, see . -% code from DSST padding=0; if size(img,3)>1 img= single(rgb2gray(img))/255.0; diff --git a/tracking/getScaleSubwindow.m b/tracking/getScaleSubwindow.m index 3113105..85013ec 100644 --- a/tracking/getScaleSubwindow.m +++ b/tracking/getScaleSubwindow.m @@ -1,7 +1,26 @@ function out = getScaleSubwindow(im, pos, base_target_sz, scale_factors, scale_window, scale_model_sz, hog_scale_cell_size) -% code from DSST - +% KCC: Kernel Cross-Correlator +% Visual Tracking Using KCC +% +% Copyright (C) 2017 +% Author: Wang Chen wang.chen@zoho.com Nanyang Technological University +% Zhang Le zhang.le@adsc.com Advanced Digital Sciences Center +% +% This file is part of KCC. +% +% KCC is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% KCC is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with KCC. If not, see . num_scales = length(scale_factors); for s = 1:num_scales diff --git a/tracking/getScaleSubwindow_v1.m b/tracking/getScaleSubwindow_v1.m index c116e27..8ce4094 100644 --- a/tracking/getScaleSubwindow_v1.m +++ b/tracking/getScaleSubwindow_v1.m @@ -1,6 +1,25 @@ function out = getScaleSubwindow_v1(img, pos, target_size, search_size, scale_window, scale_model_sz, hog_scale_cell_size) - -% code from DSST +% KCC: Kernel Cross-Correlator +% Visual Tracking Using KCC +% +% Copyright (C) 2017 +% Author: Wang Chen wang.chen@zoho.com Nanyang Technological University +% Zhang Le zhang.le@adsc.com Advanced Digital Sciences Center +% +% This file is part of KCC. +% +% KCC is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% KCC is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with KCC. If not, see . padding=0; num_scales = length(search_size); if size(img,3)>1 diff --git a/tracking/run_KCC.m b/tracking/run_KCC.m index a87068f..c1912dd 100644 --- a/tracking/run_KCC.m +++ b/tracking/run_KCC.m @@ -1,5 +1,25 @@ function results = run_KCC(seq, res_path, bSaveImage) -% Entry point for the Wu - CVPR2013 benchmark +% KCC: Kernel Cross-Correlator +% Visual Tracking Using KCC +% +% Copyright (C) 2017 +% Author: Wang Chen wang.chen@zoho.com Nanyang Technological University +% Zhang Le zhang.le@adsc.com Advanced Digital Sciences Center +% +% This file is part of KCC. +% +% KCC is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% KCC is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with KCC. If not, see . %% Read params.txt params = readParams('params.txt'); diff --git a/tracking/trackerMain_otb_wangchen.m b/tracking/trackerMain_otb_wangchen.m index a1671af..1d33e16 100644 --- a/tracking/trackerMain_otb_wangchen.m +++ b/tracking/trackerMain_otb_wangchen.m @@ -1,5 +1,26 @@ function [results] = trackerMain_otb_wangchen(p, im, bg_area, fg_area, area_resize_factor) -%TRACKERMAIN contains the main loop of the tracker, P contains all the parameters set in runTracker +% KCC: Kernel Cross-Correlator +% Visual Tracking Using KCC +% +% Copyright (C) 2017 +% Author: Wang Chen wang.chen@zoho.com Nanyang Technological University +% Zhang Le zhang.le@adsc.com Advanced Digital Sciences Center +% +% This file is part of KCC. +% +% KCC is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% KCC is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with KCC. If not, see . + %% INITIALIZATION num_frames = numel(p.img_files); % used for OTB-13 benchmark diff --git a/tracking/utility/affparam2geom.m b/tracking/utility/affparam2geom.m index ec965d9..16b20b8 100644 --- a/tracking/utility/affparam2geom.m +++ b/tracking/utility/affparam2geom.m @@ -1,45 +1,18 @@ function q = affparam2geom(p) -% function q = affparam2geom(p) -% -% 输入 : p,原始参数矩阵; -% 输出 : q,具有几何意义的参数; -% The functions affparam2geom and affparam2mat convert a 'geometric' -% affine parameter to/from a matrix form (2x3 matrix). -% -% affparam2geom converts a 2x3 matrix to 6 affine parameters -% (x, y, th, scale, aspect, skew), and affparam2mat does the inverse. -% -% p(6) : [p(1) p(3) p(4); p(2) p(5) p(6)] -% -% x' p(3) p(4) p(1) x -% y' = p(5) p(6) p(2) * y -% 1 0 0 1 1 -% -% p(3) p(4) -% A = -% p(5) p(6) -% -% q(6) : [dx dy sc th sr phi] -% dx,dy : 平移变换 -% sc,sr : 尺度变换 -% th : 旋转变换 -% phi : 错切变换 -% -% Reference "Multiple View Geometry in Computer Vision" by Richard -% Hartley and Andrew Zisserman. % Copyright (C) Jongwoo Lim and David Ross. All rights reserved. A = [ p(3), p(4); p(5), p(6) ]; -%% A = USVt = (UVt)(VSVt) = R(th)R(-phi)SR(phi) + [U,S,V] = svd(A); if (det(U) < 0) U = U(:,2:-1:1); V = V(:,2:-1:1); S = S(2:-1:1,2:-1:1); end -%%*******平移变换*******%% + + q(1) = p(1); q(2) = p(2); -%%*******平移变换*******%% + q(4) = atan2(U(2,1)*V(1,1)+U(2,2)*V(1,2), U(1,1)*V(1,1)+U(1,2)*V(1,2)); @@ -53,10 +26,10 @@ R = [c -s; s c]; V = V * R; S = R'*S*R; end -%%*******尺度变换*******%% + q(3) = S(1,1); q(5) = S(2,2)/S(1,1); -%%*******尺度变换*******%% + q(6) = atan2(V(1,2),V(1,1)); q = reshape(q, size(p)); diff --git a/tracking/utility/affparam2mat.m b/tracking/utility/affparam2mat.m index 74d0b64..9ef163a 100644 --- a/tracking/utility/affparam2mat.m +++ b/tracking/utility/affparam2mat.m @@ -1,20 +1,4 @@ function q = affparam2mat(p) -% function q = affparam2mat(p) -% -% The functions affparam2geom and affparam2mat convert a 'geometric' -% affine parameter to/from a matrix form (2x3 matrix). -% -% 输入 : q,具有几何意义的参数; -% 输出 : p,原始参数矩阵; -% -% affparam2geom converts a 2x3 matrix to 6 affine parameters -% (x, y, th, scale, aspect, skew), and affparam2mat does the inverse. -% -% p(6,n) : [dx dy sc th sr phi]' -% q(6,n) : [q(1) q(3) q(4); q(2) q(5) q(6)] -% -% Reference "Multiple View Geometry in Computer Vision" by Richard -% Hartley and Andrew Zisserman. % Copyright (C) Jongwoo Lim and David Ross. All rights reserved. diff --git a/tracking/utility/box_to_p.m b/tracking/utility/box_to_p.m index cfcee01..07717c9 100644 --- a/tracking/utility/box_to_p.m +++ b/tracking/utility/box_to_p.m @@ -17,14 +17,14 @@ [w,h] = deal(varargin{1:2}); varargin(1:2) = []; end -%%***********获得宽,高***********%% + if (length(varargin) < 1 )%|| any(length(varargin{1}) ~= 2)) M = [0,1,0; 0,0,1]; else corners = cell2mat(varargin{1}); varargin(1) = []; -% M = [p(1) p(3) p(4); p(2) p(5) p(6)]; %%affine变换参数 +% M = [p(1) p(3) p(4); p(2) p(5) p(6)]; end %---------------------------------------------------------- @@ -33,7 +33,7 @@ W = [ 1,-w/2,-h/2; 1,w/2,-h/2; 1,w/2,h/2; 1,-w/2,h/2; 1,-w/2,-h/2 ]'; M = corners/W; -p = [M(1,1), M(2,1),M(1,2),M(1,3),M(2,2),M(2,3) ]; %%中心 +p = [M(1,1), M(2,1),M(1,2),M(1,3),M(2,2),M(2,3) ]; end diff --git a/tracking/utility/p_to_box.m b/tracking/utility/p_to_box.m index 20989c3..370b092 100644 --- a/tracking/utility/p_to_box.m +++ b/tracking/utility/p_to_box.m @@ -15,7 +15,7 @@ [w,h] = deal(varargin{1:2}); varargin(1:2) = []; end -%%***********获得宽,高***********%% + if (length(varargin) < 1 || any(length(varargin{1}) ~= 6)) M = [0,1,0; 0,0,1]; @@ -27,12 +27,12 @@ else varargin(1) = []; end - M = [p(1) p(3) p(4); p(2) p(5) p(6)]; %%affine变换参数 + M = [p(1) p(3) p(4); p(2) p(5) p(6)]; end %---------------------------------------------------------- % Draw the box. %---------------------------------------------------------- corners = [ 1,-w/2,-h/2; 1,w/2,-h/2; 1,w/2,h/2; 1,-w/2,h/2; 1,-w/2,-h/2 ]'; -corners = M * corners; %%顶点 -center = mean(corners(:,1:4),2); %%中心 +corners = M * corners; +center = mean(corners(:,1:4),2); diff --git a/tracking/utility/warpimg.m b/tracking/utility/warpimg.m index c47b210..52bddcb 100644 --- a/tracking/utility/warpimg.m +++ b/tracking/utility/warpimg.m @@ -1,11 +1,4 @@ function wimg = warpimg(img, p, sz) -% function wimg = warpimg(img, p, sz) -% -% img(h,w) : 原始图像 -% p(6,n) : 仿射参数 mat format -% sz(th,tw) : 提取块大小 -% - %% Copyright (C) 2005 Jongwoo Lim and David Ross. %% All rights reserved. @@ -20,9 +13,9 @@ pos = reshape(cat(2, ones(h*w,1),x(:),y(:)) ... * [p(1,:) p(2,:); p(3:4,:) p(5:6,:)], [h,w,n,2]); wimg = squeeze(interp2(img, pos(:,:,:,1), pos(:,:,:,2))); - %%pos(:,:,:,1) : x坐标矩阵 - %%pos(:,:,:,2) : y坐标矩阵 -wimg(find(isnan(wimg))) = 0; %%去掉个别坏点 + + +wimg(find(isnan(wimg))) = 0; % B = SQUEEZE(A) returns an array B with the same elements as % A but with all the singleton dimensions removed. A singleton