OTB 数据集

OTB 数据集

一个是OTB50,这是一个精简版,另一个是OTB100,OTB100中包含OTB50.

该数据集是由人工标注的数据集,并且包含25%的灰度数据集。

有的一个视频有多个目标所以gt也有多个,但是多个gt有时一个gt没东西,如Human4这个视频,有两个gt但是,第一个gt里面没东西

gt是 topleftx,toplefty,w,h

gt的分隔符有的视频是','有的是'空格',还有的是'\t'.

草,什么沙雕gt

官方下载地址:

http://cvlab.hanyang.ac.kr/tracker_benchmark/datasets.html

我由于懒得写代码处理特殊情况,所以直接删除了那些有多个目标的,gt不包含所有帧的。

删除的有:David, Football1, Freeman3, Freeman4, Human4, Jogging, Skating2,Diving,Doll,Girl2,Human3

给出我的dataset代码:

import os
import numpy as np
import random
from paint.paint_fuc import paint_rectangle
from data.bbox_func import ltxywh2center, center2corner
import cv2

OTB_dataset_path = "E:/dataset/OTB"

class Video:

    def __init__(self, video_path):
        '''
        获取视频文件夹地址
        获取该视频每一帧的路径
        获取该视频的gt
        存储视频的帧数
        :param video_path:
        '''
        self.video_path = video_path
        self.image_path = self.video_path + "/img"
        self.gt = []
        self.get_frames_path()
        self.get_gt()
        self.size = len(self.gt)

    def get_frames_path(self):
        self.frames_path = [self.image_path+'/'+f for f in os.listdir(self.image_path) if f.endswith('jpg')]

    def get_gt(self):
        gt_path = self.video_path+'/groundtruth_rect.txt'
        gt_file = open(gt_path, "r")
        lines = gt_file.readlines()
        gt_file.close()
        for i in range(len(lines)):
            line = lines[i]
            line_split = line[:-1].replace(",", " ").replace("\t", " ").split(" ")
            ltx, lty, w, h = line_split
            t_gt = [float(ltx), float(lty), float(w), float(h)]
            cx, cy, w, h = ltxywh2center(t_gt)
            self.gt.append([cx, cy, w, h])


class MyDataSet:

    def __init__(self, dataset_path):
        '''
        获取数据集文件夹路径
        创建存放所有视频的list
        保存该数据集帧数的总量
        获取所有视频
        :param dataset_path:
        '''
        self.dataset_path = dataset_path
        self.videos = []
        self.size = 0
        self.get_videos()

    def get_videos(self):
        '''
        获取本数据集的所有视频
        并打乱视频顺序
        :return:
        '''
        videos_path = [self.dataset_path+'/'+f for f in os.listdir(self.dataset_path)
                            if os.path.isdir(self.dataset_path+'/'+f)]

        for path in videos_path:
            video = Video(path)
            self.size += video.size
            self.videos.append(video)

        # self.shuffle_video()

    def shuffle_video(self):
        '''
        打乱视频的顺序,保证了每次训练使用的视频顺序不同
        :return:
        '''
        np.random.shuffle(self.videos)

if __name__ == '__main__':
    mydataset = MyDataSet(OTB_dataset_path)
    for video in mydataset.videos:

        for i in range(video.size):
            image = cv2.imread(video.frames_path[i])
            gt = video.gt[i]
            corner = center2corner(gt)
            x1, y1, x2, y2 = corner
            paint_rectangle(image, x1, y1, x2, y2)
            # cv2.imshow(f"{i}", image)
            cv2.imshow(f"{video.video_path}", image)
            cv2.waitKey(1)
            # cv2.waitKey()
            # break

文章目录