其他分享
首页 > 其他分享> > Transform the vot dataset into 4 corner format

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 

 

标签:videoName,gt,end,format,into,Transform,fprintf,fid,path
来源: https://www.cnblogs.com/wangxiaocvpr/p/11627022.html