CN跟踪算法的学习与MATLAB代码简介

        Adaptive Color Attributes for Real-Time Visual Tracking中介绍了一种color names(CN)的目标跟踪算法,主要的贡献就是将图片的颜色属性扩展到了CSK跟踪器中。文中将颜色分为11类,就是将RGB三种颜色细化为黑、蓝、棕、灰、绿、橙、粉、紫、红、白和黄共11种。通道数过多会使计算量过大,文中使用PCA降维的方法从11个通道选出2个主要的通道进行处理,这大概就是自适应的含义吧!

 这里主要介绍一下代码的流程。

(1)读取视频帧和groundtruth

%ask the user for the video
video_path = choose_video(base_path);
if isempty(video_path), return, end  %user cancelled
[img_files, pos, target_sz, ground_truth, video_path] = load_video_info(video_path);
(2)提取图片中目标区域2倍大小的non-PCA和PCA特征

function [out_npca, out_pca] = get_subwindow(im, pos, sz, non_pca_features, pca_features, w2c)

% [out_npca, out_pca] = get_subwindow(im, pos, sz, non_pca_features, pca_features, w2c)
%
% Extracts the non-PCA and PCA features from image im at position pos and
% window size sz. The features are given in non_pca_features and
% pca_features. out_npca is the window of non-PCA features and out_pca is
% the PCA-features reshaped to [prod(sz) num_pca_feature_dim]. w2c is the
% Color Names matrix if used.

if isscalar(sz),  %square sub-window
    sz = [sz, sz];
end

xs = floor(pos(2)) + (1:sz(2)) - floor(sz(2)/2);
ys = floor(pos(1)) + (1:sz(1)) - floor(sz(1)/2);

%check for out-of-bounds coordinates, and set them to the values at
%the borders
xs(xs < 1) = 1;
ys(ys < 1) = 1;
xs(xs > size(im,2)) = size(im,2);
ys(ys > size(im,1)) = size(im,1);

%extract image
im_patch = im(ys, xs, :);

% compute non-pca feature map
if ~isempty(non_pca_features)
    out_npca = get_feature_map(im_patch, non_pca_features, w2c);
else
    out_npca = [];
end

% compute pca feature map
if ~isempty(pca_features)
    temp_pca = get_feature_map(im_patch, pca_features, w2c);
    out_pca = reshape(temp_pca, [prod(sz), size(temp_pca, 3)]);
else
    out_pca = [];
end
end
(3)对PCA特征进行PCA降维并将其与non-PCA进行cat

        data_mean = mean(z_pca, 1);
        
        % substract the mean from the appearance to get the data matrix
        data_matrix = bsxfun(@minus, z_pca, data_mean);
        
        % calculate the covariance matrix
        cov_matrix = 1/(prod(sz) - 1) * (data_matrix' * data_matrix);
        
        % calculate the principal components (pca_basis) and corresponding variances
        if frame == 1
            [pca_basis, pca_variances, ~] = svd(cov_matrix);
        else
            [pca_basis, pca_variances, ~] = svd((1 - compression_learning_rate) * old_cov_matrix + compression_learning_rate * cov_matrix);
        end
        
        % calculate the projection matrix as the first principal
        % components and extract their corresponding variances
        projection_matrix = pca_basis(:, 1:num_compressed_dim);
        projection_variances = pca_variances(1:num_compressed_dim, 1:num_compressed_dim);
       x_proj_pca = reshape(x_pca * projection_matrix, [height, width, num_pca_out]);
       z = cat(3, x_npca, x_proj_pca);
(4)接下来的部分和CSK中好像是一样的,核矩阵的计算和响应的计算

        % calculate the response of the classifier
        kf = fft2(dense_gauss_kernel(sigma, x, zp));
        response = real(ifft2(alphaf_num .* kf ./ alphaf_den));
        
        % target location is at the maximum response
        [row, col] = find(response == max(response(:)), 1);
        pos = pos - floor(sz/2) + [row, col];
大概就是这么一个流程,对颜色的处理那块主要集中在PCA特征提取,具体的细节略过。





你可能感兴趣的:(CN跟踪算法的学习与MATLAB代码简介)