コード例 #1
0
ファイル: siamrpn.py プロジェクト: songheony/A3T
class SiamRPN(BaseTracker):
    def __init__(self):
        super(SiamRPN, self).__init__("SiamRPN")
        self.net_file = path_config.SIAMRPN_MODEL
        self.tracker = TrackerSiamRPN(net_path=self.net_file)

    def initialize(self, image_file, box):
        image = Image.open(image_file).convert("RGB")
        self.tracker.init(image, box)

    def track(self, image_file):
        image = Image.open(image_file).convert("RGB")
        return self.tracker.update(image)
コード例 #2
0
from __future__ import absolute_import

from got10k.experiments import *

from siamrpn import TrackerSiamRPN

if __name__ == '__main__':
    # setup tracker
    net_path = 'pretrained/siamrpn/model.pth'
    tracker = TrackerSiamRPN(net_path=net_path)

    # setup experiments
    # 7 datasets with different versions
    experiments = [
        ExperimentGOT10k('data/GOT-10k', subset='test'),
        ExperimentOTB('data/OTB', version=2015),
        ExperimentOTB('data/OTB', version=2013),
        ExperimentVOT('data/vot2018', version=2018),
        ExperimentUAV123('data/UAV123', version='UAV123'),
        ExperimentUAV123('data/UAV123', version='UAV20L'),
        ExperimentDTB70('data/DTB70'),
        ExperimentTColor128('data/Temple-color-128'),
        ExperimentNfS('data/nfs', fps=30),
        ExperimentNfS('data/nfs', fps=240),
    ]

    # run experiments
    for e in experiments:
        e.run(tracker, visualize=True)
        e.report([tracker.name])
コード例 #3
0
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

from got10k.datasets import *
from got10k.experiments import *

from siamrpn import TrackerSiamRPN

# fitlog.commit(__file__ , fit_msg="这里是SiamRPN测试过程, 师兄改版(siamrpn_master)")

if __name__ == '__main__':
    net_path = 'pretrained/siamrpn_e'
    iters = 1
    tracker = TrackerSiamRPN(net_path=net_path + str(iters) + ".pth",
                             fit_log=True)

    experiments = [
        ExperimentGOT10k('/data2/data_zyp/GOT-10k', subset='test'),
        ExperimentOTB('/data2/data_zyp/OTB', version=2015),
        ExperimentVOT('/data/zyp/data/VOT2019', version=2019),
        # ExperimentGOT10k('data/GOT-10k', subset='test'),
        # ExperimentOTB('data/OTB', version=2015),
        # ExperimentOTB('data/OTB', version=2013),
        # ExperimentVOT('data/vot2018', version=2018),
        # ExperimentUAV123('data/UAV123', version='UAV123'),
        # ExperimentUAV123('data/UAV123', version='UAV20L'),
        # ExperimentDTB70('data/DTB70'),
        # ExperimentTColor128('data/Temple-color-128'),
        # ExperimentNfS('data/nfs', fps=30),
        # ExperimentNfS('data/nfs', fps=240),
コード例 #4
0
    nw = np.arange(int(tw/f/2), w - int(tw/f/2), int(tw/f))
    x = [crop_and_resize(img, np.array([p, q]), np.sqrt(th * tw),
                         out_size=271,
                         border_value=np.mean(img, axis=(0, 1))) for p in nh.flatten() for q in nw.flatten()]
    for i, xx in enumerate(x):
        cv2.imwrite('test2/%d.png' % (i), xx)

    return x, (len(nh), len(nw))


if __name__ == '__main__':
    # setup tracker
    name = 5
    name = str(name).zfill(2)
    net_path = 'pretrained/siamrpn/model.pth'
    tracker = TrackerSiamRPN(net_path=net_path)

    ori_img = cv2.imread('/DATA2/wxr/pacman/data-png/%s.png'%(name))[:, :, :]
    # ori_img = cv2.imread('/home/wxr/projects/siamrpn-pytorch/test2/17.png')[:, :, :]
    h, w, c = ori_img.shape
    template = cv2.imread('/DATA2/wxr/pacman/template.png')
    template = cv2.resize(template, (127, 127),
                          interpolation=cv2.INTER_NEAREST)
    template = cv2.copyMakeBorder(template, 72, 72, 72, 72, cv2.BORDER_CONSTANT)
    cv2.imwrite('template.png', template)
    imgs, (nh, nw) = crop_image(ori_img, f = 1)
    print(len(imgs), (nh, nw))

    tracker.init(template, None)
    # box, response = tracker.update(ori_img)
    # print(box, response)
コード例 #5
0
ファイル: siamrpn.py プロジェクト: songheony/A3T
 def __init__(self):
     super(SiamRPN, self).__init__("SiamRPN")
     self.net_file = path_config.SIAMRPN_MODEL
     self.tracker = TrackerSiamRPN(net_path=self.net_file)
コード例 #6
0
from __future__ import absolute_import

# import fitlog
import os
import sys
sys.path.append('..')

from got10k.datasets import *

from siamrpn import TrackerSiamRPN

# fitlog.commit(__file__ , fit_msg="这里是SiamRPN训练过程, 师兄改版(siamrpn_master)")

root_dir = '/data2/data_zyp/GOT-10k'
# root_dir = os.path.expanduser('~/data/GOT-10k')
train_seqs = GOT10k(root_dir, subset='train', return_meta=True)
# using val
val_seqs = GOT10k(root_dir, subset='val', return_meta=True)
tracker = TrackerSiamRPN(fit_log=True)
tracker.train_over(seqs=train_seqs, val_seqs=val_seqs)

# fitlog.finish()
コード例 #7
0
parser.add_argument('--region', nargs='*',action="store",help='set alarm region')
parser.add_argument('-v','--video',type = str, default = 'ARENA-W1-11_03_ENV_RGB_3.mp4', help='video name')
parser.add_argument('--type', type = int, default = 0, help = 'tracker type')
parser.add_argument('--boxnum', type = int, default = 1, help = 'box number')

args = parser.parse_args()

if __name__ == '__main__':
    # Setup device
    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
    #torch.backends.cudnn.benchmark = True

    # Setup Model

    ### init model ###
    tracker = TrackerSiamRPN(net_path=args.net_path)

    # Parse Image file
   # cap = cv2.VideoCapture(args.video)
    #if (cap.isOpened() == False):
   #     print('error opening video file')
   # ret, frame = cap.read()

    img_files = natural_sort(glob.glob(args.base_path + '*.jpg'))
    ims = [cv2.imread(imf) for imf in img_files]

    # Select ROI
    cv2.namedWindow("SiamRPN_Tracking", cv2.WND_PROP_AUTOSIZE)

    ### init the region
    region, object = SelectRoi(args.region, args.object, ims[0], number = args.boxnum)