码迷,mamicode.com
首页 > 其他好文 > 详细

Transform the vot dataset into 4 corner format

时间:2019-10-06 13:41:19      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:txt   family   print   corn   col   into   int   center   orm   

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 

 

Transform the vot dataset into 4 corner format

标签:txt   family   print   corn   col   into   int   center   orm   

原文地址:https://www.cnblogs.com/wangxiaocvpr/p/11627022.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!