Transform the vot dataset into 4 corner format

Transform the vot dataset into 4 corner format

 

Matlab code to change the 8 value ground truth into 4 corner format: (x1, y1, width, height). 

 

clc;  close all;  clear all; 

path = '/Tracking_Benchmark/VOT2018/';
videoFiles = dir(path); 
videoFiles = videoFiles(3:end); 

for i =1:size(videoFiles, 1)
    videoName = videoFiles(i).name; 
    disp(videoName); 
    
    gt_path = [path videoName '/groundtruth.txt']; 
    gt = importdata(gt_path); 
    
    if size(gt, 2) >= 6
        x = gt(:,1:2:end);
        y = gt(:,2:2:end);
        gt = [min(x,[],2), min(y,[],2), max(x,[],2) - min(x,[],2), max(y,[],2) - min(y,[],2)];
    end
    
    imgFiles = dir([path videoName '/color/*.jpg']);  
    firstFrame = imread([path videoName '/color/' imgFiles(1).name]); 
    targetObject = imcrop(firstFrame, gt(1, :));
    
    imshow(targetObject);
    
    new_gt_path = [path videoName '/groundtruth_new.txt']; 
    fid = fopen(new_gt_path, 'w') ; 
    
    
    for j =1:size(gt, 1)
        fprintf(fid, '%s', num2str(gt(j, 1))); 
        fprintf(fid, '%s', ','); 
        fprintf(fid, '%s', num2str(gt(j, 2))); 
        fprintf(fid, '%s', ','); 
        fprintf(fid, '%s', num2str(gt(j, 3))); 
        fprintf(fid, '%s', ','); 
        fprintf(fid, '%s \n', num2str(gt(j, 4))); 
    end 
    
end 

 

上一篇:【大数据Java基础-JAVA 数据结构14】LIST(一)Java ArrayList


下一篇:无线自组网AODV路由机制仿真源码