写论文对比试验需要在Temple Color 128数据集(http://www.dabi.temple.edu/~hbling/data/TColor-128/TColor-128.html)上跑,但其标注与OTB测评工具箱有所差别。
OTB工具箱所需的属性和跟踪框标注格式是这样的
而Temple Color 128提供的标注格式是这样的
编写脚本,轻松转换
import os
import shutil
CHALLENGE_ATTRIBUTE = ['IV','OPR','SV','OCC','DEF','MB','FM','IPR','OV','BC','LR']
if not os.path.exists('anno'):
os.makedirs('anno')
os.makedirs(os.path.join('anno','att'))
def process_att(att_filename):
ret = []
with open(att_filename) as f:
for l in f.readlines():
ret.append(l.strip())
return ret
videos = os.listdir('Temple-color-128')
for v in videos:
att_file = os.path.join('Temple-color-128',v,v+'_att.txt')
gt_file = os.path.join('Temple-color-128',v,v+'_gt.txt')
att_file_write = os.path.join('anno','att',v+'.txt')
att_str = ''
att = process_att(att_file)
for c in CHALLENGE_ATTRIBUTE:
if c in att:
att_str += '1'
else:
att_str += '0'
if c != 'LR':
att_str += ','
with open(att_file_write, 'w') as f:
f.write(att_str)
shutil.copy(gt_file, os.path.join('anno', v+'.txt'))