將Temple Color數據集標註轉換爲tracker benchmark所需格式

寫論文對比試驗需要在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')) 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章