VOT 数据集 groundtruth 8个维度 转成 4个维度的方法

VOT数据集由于加入了带旋转角度的boundingbox,使得其groundtruth的维度达到了8个

如下:
VOT 数据集 groundtruth 8个维度 转成 4个维度的方法_第1张图片
8个维度就代表boundingbox的4个点,比如VOT16中,bag数据序列的groundtruth第一行:

334.02,128.36,438.19,188.78,396.39,260.83,292.23,200.41

代表框的4个角点:
(334.02,128.36),(438.19,188.78),(396.39,260.83),(292.23,200.41)

但是很多跟踪算法都是用的4个维度的groundtruth 即我们所熟知的(x,y,w,h),那么怎么转换呢?用下代码:

function [x, y, w, h] = getAxisAlignedBB1(region)
% GETAXISALIGNEDBB extracts an axis aligned bbox from the ground truth REGION with same area as the rotated one
    cx = mean(region(1:2:end));
    cy = mean(region(2:2:end));
    x1 = min(region(1:2:end));
    x2 = max(region(1:2:end));
    y1 = min(region(2:2:end));
    y2 = max(region(2:2:end));
    A1 = norm(region(1:2) - region(3:4)) * norm(region(3:4) - region(5:6));
    A2 = (x2 - x1) * (y2 - y1);
    s = sqrt(A1/A2);
    w = s * (x2 - x1) + 1;
    h = s * (y2 - y1) + 1;
    x=cx-w/2;
    y=cy-h/2;
end
clear all
I = importdata('./wiper.txt'); %输入8维度框的txt文件
[h,w]=size(I);
for i=1:h
    [O(i,1),O(i,2),O(i,3),O(i,4)]=getAxisAlignedBB(I(i,:));
end

dlmwrite('wiper.txt', O); %输出4维度框的txt文件

你可能感兴趣的:(目标跟踪,目标跟踪,计算机视觉,图像处理)