-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd854b6
commit 2b09e33
Showing
11 changed files
with
259 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from __future__ import absolute_import, print_function | ||
|
||
import os | ||
import glob | ||
import numpy as np | ||
import six | ||
|
||
|
||
class DTB70(object): | ||
"""`DTB70 <https://github.com/flyers/drone-tracking>`_ Dataset. | ||
Publication: | ||
``Visual object tracking for unmanned aerial vehicles: A benchmark and new motion models``, | ||
Y. Wu, J. Lim and M.-H. Yang, IEEE TPAMI 2015. | ||
Args: | ||
root_dir (string): Root directory of dataset where sequence | ||
folders exist. | ||
""" | ||
def __init__(self, root_dir): | ||
super(DTB70, self).__init__() | ||
self.root_dir = root_dir | ||
self._check_integrity(root_dir) | ||
|
||
self.anno_files = sorted(glob.glob( | ||
os.path.join(root_dir, '*/groundtruth_rect.txt'))) | ||
self.seq_dirs = [os.path.dirname(f) for f in self.anno_files] | ||
self.seq_names = [os.path.basename(d) for d in self.seq_dirs] | ||
|
||
def __getitem__(self, index): | ||
r""" | ||
Args: | ||
index (integer or string): Index or name of a sequence. | ||
Returns: | ||
tuple: (img_files, anno), where ``img_files`` is a list of | ||
file names and ``anno`` is a N x 4 (rectangles) numpy array. | ||
""" | ||
if isinstance(index, six.string_types): | ||
if not index in self.seq_names: | ||
raise Exception('Sequence {} not found.'.format(index)) | ||
index = self.seq_names.index(index) | ||
|
||
img_files = sorted(glob.glob( | ||
os.path.join(self.seq_dirs[index], 'img/*.jpg'))) | ||
anno = np.loadtxt(self.anno_files[index], delimiter=',') | ||
assert len(img_files) == len(anno) | ||
assert anno.shape[1] == 4 | ||
|
||
return img_files, anno | ||
|
||
def __len__(self): | ||
return len(self.seq_names) | ||
|
||
def _check_integrity(self, root_dir): | ||
seq_names = os.listdir(root_dir) | ||
seq_names = [n for n in seq_names if not n[0] == '.'] | ||
|
||
if os.path.isdir(root_dir) and len(seq_names) > 0: | ||
# check each sequence folder | ||
for seq_name in seq_names: | ||
seq_dir = os.path.join(root_dir, seq_name) | ||
if not os.path.isdir(seq_dir): | ||
print('Warning: sequence %s not exist.' % seq_name) | ||
else: | ||
# dataset not exist | ||
raise Exception('Dataset not found or corrupted. ' + | ||
'You can use download=True to download it.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from __future__ import absolute_import, print_function | ||
|
||
import os | ||
import glob | ||
import numpy as np | ||
import six | ||
|
||
from ..utils.ioutils import download, extract | ||
|
||
|
||
class TColor128(object): | ||
"""`TColor128 <http://www.dabi.temple.edu/~hbling/data/TColor-128/TColor-128.html>`_ Dataset. | ||
Publication: | ||
``Encoding color information for visual tracking: algorithms and benchmark``, | ||
P. Liang, E. Blasch and H. Ling, TIP, 2015. | ||
Args: | ||
root_dir (string): Root directory of dataset where sequence | ||
folders exist. | ||
""" | ||
def __init__(self, root_dir, download=True): | ||
super(TColor128, self).__init__() | ||
self.root_dir = root_dir | ||
if download: | ||
self._download(root_dir) | ||
self._check_integrity(root_dir) | ||
|
||
self.anno_files = sorted(glob.glob( | ||
os.path.join(root_dir, '*/*_gt.txt'))) | ||
self.seq_dirs = [os.path.dirname(f) for f in self.anno_files] | ||
self.seq_names = [os.path.basename(d) for d in self.seq_dirs] | ||
# valid frame range for each sequence | ||
self.range_files = [os.path.join( | ||
root_dir, '%s/%s_frames.txt' % (n, n)) | ||
for n in self.seq_names] | ||
|
||
def __getitem__(self, index): | ||
r""" | ||
Args: | ||
index (integer or string): Index or name of a sequence. | ||
Returns: | ||
tuple: (img_files, anno), where ``img_files`` is a list of | ||
file names and ``anno`` is a N x 4 (rectangles) numpy array. | ||
""" | ||
if isinstance(index, six.string_types): | ||
if not index in self.seq_names: | ||
raise Exception('Sequence {} not found.'.format(index)) | ||
index = self.seq_names.index(index) | ||
|
||
# load valid frame range | ||
frames = np.loadtxt( | ||
self.range_files[index], dtype=int, delimiter=',') | ||
img_files = [os.path.join( | ||
self.seq_dirs[index], 'img/%04d.jpg' % f) | ||
for f in range(frames[0], frames[1] + 1)] | ||
|
||
# load annotations | ||
anno = np.loadtxt(self.anno_files[index], delimiter=',') | ||
assert len(img_files) == len(anno) | ||
assert anno.shape[1] == 4 | ||
|
||
return img_files, anno | ||
|
||
def __len__(self): | ||
return len(self.seq_names) | ||
|
||
def _download(self, root_dir): | ||
if not os.path.isdir(root_dir): | ||
os.makedirs(root_dir) | ||
elif len(os.listdir(root_dir)) > 100: | ||
print('Files already downloaded.') | ||
return | ||
|
||
url = 'http://www.dabi.temple.edu/~hbling/data/TColor-128/Temple-color-128.zip' | ||
zip_file = os.path.join(root_dir, 'Temple-color-128.zip') | ||
print('Downloading to %s...' % zip_file) | ||
download(url, zip_file) | ||
print('\nExtracting to %s...' % root_dir) | ||
extract(zip_file, root_dir) | ||
|
||
return root_dir | ||
|
||
def _check_integrity(self, root_dir): | ||
seq_names = os.listdir(root_dir) | ||
seq_names = [n for n in seq_names if not n[0] == '.'] | ||
|
||
if os.path.isdir(root_dir) and len(seq_names) > 0: | ||
# check each sequence folder | ||
for seq_name in seq_names: | ||
seq_dir = os.path.join(root_dir, seq_name) | ||
if not os.path.isdir(seq_dir): | ||
print('Warning: sequence %s not exist.' % seq_name) | ||
else: | ||
# dataset not exist | ||
raise Exception('Dataset not found or corrupted. ' + | ||
'You can use download=True to download it.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from __future__ import absolute_import | ||
|
||
import os | ||
|
||
from .otb import ExperimentOTB | ||
from ..datasets import DTB70 | ||
|
||
|
||
class ExperimentDTB70(ExperimentOTB): | ||
r"""Experiment pipeline and evaluation toolkit for DTB70 dataset. | ||
Args: | ||
root_dir (string): Root directory of DTB70 dataset. | ||
result_dir (string, optional): Directory for storing tracking | ||
results. Default is ``./results``. | ||
report_dir (string, optional): Directory for storing performance | ||
evaluation results. Default is ``./reports``. | ||
""" | ||
def __init__(self, root_dir, | ||
result_dir='results', report_dir='reports'): | ||
self.dataset = DTB70(root_dir) | ||
self.result_dir = os.path.join(result_dir, 'DTB70') | ||
self.report_dir = os.path.join(report_dir, 'DTB70') | ||
# as nbins_iou increases, the success score | ||
# converges to the average overlap (AO) | ||
self.nbins_iou = 21 | ||
self.nbins_ce = 51 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from __future__ import absolute_import | ||
|
||
import os | ||
|
||
from .otb import ExperimentOTB | ||
from ..datasets import TColor128 | ||
|
||
|
||
class ExperimentTColor128(ExperimentOTB): | ||
r"""Experiment pipeline and evaluation toolkit for TColor128 dataset. | ||
Args: | ||
root_dir (string): Root directory of TColor128 dataset. | ||
result_dir (string, optional): Directory for storing tracking | ||
results. Default is ``./results``. | ||
report_dir (string, optional): Directory for storing performance | ||
evaluation results. Default is ``./reports``. | ||
""" | ||
def __init__(self, root_dir, | ||
result_dir='results', report_dir='reports'): | ||
self.dataset = TColor128(root_dir) | ||
self.result_dir = os.path.join(result_dir, 'TColor128') | ||
self.report_dir = os.path.join(report_dir, 'TColor128') | ||
# as nbins_iou increases, the success score | ||
# converges to the average overlap (AO) | ||
self.nbins_iou = 21 | ||
self.nbins_ce = 51 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters