[OTB use introduction 3] How to add your own algorithm to Visual Tracker Benchmark v1.0, take KCF as an example

In [OTB Usage Introduction II], I briefly explained the three m files of OTB. This time I mainly explained how to add my own algorithm to OTB.

The original OTB does not include KCF, so here is an example of KCF to introduce how to add your own algorithm to OTB.
The source code of KCF can be downloaded from http://www.robots.ox.ac.uk/~joao/circulant/
KCF
Click on matlab code to download the matlab version of KCF.

After downloading, unzip the file and put the matlab source code of KCF into the benchmark folder trackers.
write picture description here
Then open configTrackers.m in the util folder, and add the KCF tracking algorithm to the trackers1 structure. The added form is as follows:

trackers1={ 
    struct('name','SRDCF','namePaper','SRDCF'),...
    struct('name','KCF','namePaper','KCF'),...
    struct('name','DSST','namePaper','DSST'),...
    struct('name','Struck','namePaper','Struck')};

Explain that all tracking algorithms are placed in the configTrackers.m file. The additions and deletions of algorithm comparisons are all done here.

The last and most important step

Just need to write a script run_tracker.m file that connects the input and output of KCF to the benchmark. When you open other algorithms in the trackers folder, you will find that each algorithm will have run_(here is the algorithm name).m file, such as CT run_CT.m in

Refer to other algorithms such as: run_CT.m to unify the input of the Runtracker.m file in the first line and the output of the last few lines,

function results=run_CT(seq, res_path, bSaveImage)

results.res=res;

results.type='rect';

results.fps=(seq.len-1)/duration;

disp(['fps: ' num2str(results.fps)])

In fact, the run_().m interface written is mainly to pay special attention to the above information. Among them, seq mainly contains various information of the test sequence.
res_path and bSaveImage are mainly saved pictures, that is, BB frame drawing frame.
Here is the run_KCF.m of the modified KCF. Removed some unnecessary information.

  function results = run_KCF(seq, res_path, bSaveImage)

    kernel_type = 'gaussian'; 
    kernel.type = kernel_type;

    padding = 1.5;  %extra area surrounding the target
    lambda = 1e-4;  %regularization
    output_sigma_factor = 0.1;  %spatial bandwidth (proportional to target)

    interp_factor = 0.02;
    kernel.sigma = 0.5; 
    kernel.poly_a = 1;
    kernel.poly_b = 9;  
    features.hog = true;
    features.hog_orientations = 9;
    cell_size = 4;  

    seq_KCF = seq;
    target_sz = seq_KCF.init_rect(1,[4,3]);
    pos = seq_KCF.init_rect(1,[2,1]) + floor(target_sz/2);
    img_files = seq_KCF.s_frames;
    video_path = [];

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    [positions , time] = tracker(video_path, img_files, pos, target_sz, ...
            padding, kernel, lambda, output_sigma_factor, interp_factor, ...
            cell_size, features);
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    
    if bSaveImage
        imwrite(frame2im(getframe(gcf)),[res_path num2str(frame) '.jpg']); 
    end

    %return results to benchmark, in a workspace variable
    rects = [positions(:,2) - target_sz(2)/2, positions(:,1) - target_sz(1)/2];
    rects(:,3) = target_sz(2);
    rects(:,4) = target_sz(1);

    fps = numel(img_files) / time;
    results.type = 'rect';
    results.res = rects;%each row is a rectangle
    results.fps = fps;

  end

Because the Gaussian kernel and the hog feature are selected during the test, if the error gray is not set, set the features.gray to false;

The last is to run the main_running.m function. After running the main_running.m function, the results obtained are results_SRE_CVPR13 and results_TRE_CVPR13 in the folder results. (The save location depends on the location you set yourself)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324926106&siteId=291194637
Recommended