zoukankan      html  css  js  c++  java
  • 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 
    ', num2str(gt(j, 4))); 
        end 
        
    end 
  • 相关阅读:
    CSS3中新增的对文本和字体的设置
    PAT1107:Social Clusters
    Git的一些操作
    PAT1029:Median
    PAT1024:Palindromic Number
    PAT1028:List Sorting
    PAT1035: Password
    PAT1133:Splitting A Linked List
    PAT1017:Queueing at Bank
    PAT1105:Spiral Matrix
  • 原文地址:https://www.cnblogs.com/wangxiaocvpr/p/11627022.html
Copyright © 2011-2022 走看看