Esempio n. 1
0
def run_sequence(seq: Sequence, tracker: Tracker, debug=False):
    """Runs a tracker on a sequence."""
    base_results_path = '{}/baseline/{}'.format(tracker.results_dir, seq.name)
    results_path = '{}.txt'.format(base_results_path)
    times_path = '{}_time.txt'.format(base_results_path)

    if os.path.isfile(results_path) and not debug:
        return

    print('Tracker: {} {} {} ,  Sequence: {}'.format(tracker.name,
                                                     tracker.parameter_name,
                                                     tracker.run_id, seq.name))

    if debug:
        tracked_bb, exec_times = tracker.run(seq, debug=debug)
    else:
        try:
            tracked_bb, exec_times = tracker.run(seq, debug=debug)
        except Exception as e:
            print(e)
            return
    path = base_results_path.split('/')
    path = path[-1]

    if not isdir(base_results_path): makedirs(base_results_path)
    results_path = join(base_results_path, '{:s}_001.txt').format(path)
    #'{}.txt'.format(base_results_path)
    with open(results_path, "w") as fin:
        for x in tracked_bb:
            fin.write("{:d}\n".format(x)) if isinstance(x, int) else \
                    fin.write(','.join([vot_float2str("%.4f", i) for i in x]) + '\n')
    # tracked_bb = np.array(tracked_bb).astype(int)
    exec_times = np.array(exec_times).astype(float)

    print('FPS: {}'.format(len(exec_times) / exec_times.sum()))
Esempio n. 2
0
def run_sequence(seq: Sequence,
                 tracker: Tracker,
                 debug=False,
                 visdom_info=None):
    """Runs a tracker on a sequence."""

    visdom_info = {} if visdom_info is None else visdom_info

    base_results_path = '{}/{}'.format(tracker.results_dir, seq.name)
    results_path = '{}.txt'.format(base_results_path)
    times_path = '{}_time.txt'.format(base_results_path)

    if os.path.isfile(results_path) and not debug:
        return

    print('Tracker: {} {} {} ,  Sequence: {}'.format(tracker.name,
                                                     tracker.parameter_name,
                                                     tracker.run_id, seq.name))

    if debug:
        output = tracker.run(seq, debug=debug, visdom_info=visdom_info)
    else:
        try:
            output = tracker.run(seq, debug=debug, visdom_info=visdom_info)
        except Exception as e:
            print(e)
            return

    tracked_bb = np.array(output['target_bbox']).astype(int)
    exec_times = np.array(output['time']).astype(float)

    print('FPS: {}'.format(len(exec_times) / exec_times.sum()))
    if not debug:
        np.savetxt(results_path, tracked_bb, delimiter='\t', fmt='%d')
        np.savetxt(times_path, exec_times, delimiter='\t', fmt='%f')
Esempio n. 3
0
def run_sequence(seq: Sequence, tracker: Tracker, debug=False):
    """Runs a tracker on a sequence."""

    base_results_path = '{}/{}'.format(tracker.results_dir, seq.name)
    results_path = '{}.txt'.format(base_results_path)
    times_path = '{}_time.txt'.format(base_results_path)

    if os.path.isfile(results_path) and not debug:
        return

    print('Tracker: {} {} {} ,  Sequence: {}'.format(tracker.name, tracker.parameter_name, tracker.run_id, seq.name))

    if debug:
        tracked_bb, exec_times = tracker.run(seq, debug=debug)
    else:
        try:
            tracked_bb, exec_times = tracker.run(seq, debug=debug)
        except Exception as e:
            print(e)
            return

    tracked_bb = np.array(tracked_bb).astype(float)
    exec_times = np.array(exec_times).astype(float)

    print('FPS: {}'.format(len(exec_times) / exec_times.sum()))
    if not debug:
        np.savetxt(results_path, tracked_bb, delimiter=',', fmt='%f')
        np.savetxt(times_path, exec_times, delimiter='\t', fmt='%f')
Esempio n. 4
0
def run_sequence_vot(seq: Sequence, tracker: Tracker, debug=False):
    """Runs a tracker on a sequence."""

    base_results_path = '{}/{}/{}/{}'.format(tracker.results_dir, 'baseline',
                                             seq.name, seq.name)
    results_path = '{}_001.txt'.format(base_results_path)
    times_path = '{}_time.txt'.format(base_results_path)

    if not os.path.exists('{}/{}'.format(tracker.results_dir, 'baseline')):
        os.mkdir('{}/{}'.format(tracker.results_dir, 'baseline'))

    if not os.path.exists('{}/{}/{}'.format(tracker.results_dir, 'baseline',
                                            seq.name)):
        os.mkdir('{}/{}/{}'.format(tracker.results_dir, 'baseline', seq.name))

    if os.path.isfile(results_path) and not debug:
        return

    print('Tracker: {} {} {} ,  Sequence: {}'.format(tracker.name,
                                                     tracker.parameter_name,
                                                     tracker.run_id, seq.name))

    if debug:
        tracked_bb, exec_times = tracker.run(seq, debug=debug)
    else:
        try:
            tracked_bb, exec_times = tracker.run(seq, debug=debug)
        except Exception as e:
            print(e)
            return

    #tracked_bb = np.array(tracked_bb).astype(int)
    exec_times = np.array(exec_times).astype(float)

    with open(results_path, "w") as fin:
        for x in tracked_bb:
            if isinstance(x, int):
                fin.write("{:d}\n".format(x))
            else:
                p_bbox = x.copy()
                fin.write(','.join([str(i) for i in x]) + '\n')

    print('FPS: {}'.format(len(exec_times) / exec_times.sum()))
    if not debug:
        #np.savetxt(results_path, tracked_bb, delimiter='\t', fmt='%d')
        np.savetxt(times_path, exec_times, delimiter='\t', fmt='%f')
Esempio n. 5
0
def run_sequence(seq: Sequence, tracker: Tracker, debug=False):
    """Runs a tracker on a sequence."""
    base_results_path = '{}/{}'.format(tracker.results_dir, 'baseline')
    if not os.path.isdir(base_results_path):
        os.makedirs(base_results_path)
    base_results_path = '{}/{}'.format(base_results_path, seq.name)
    results_path = '{}.txt'.format(base_results_path)
    times_path = '{}_time.txt'.format(base_results_path)

    if os.path.isfile(results_path) and not debug:
        return

    print('Tracker: {} {} {} ,  Sequence: {}'.format(tracker.name,
                                                     tracker.parameter_name,
                                                     tracker.run_id, seq.name))

    if debug:
        tracked_bb, exec_times = tracker.run(seq, debug=debug)
    else:
        try:
            tracked_bb, exec_times = tracker.run(seq, debug=debug)
        except Exception as e:
            print(e)
            return

    # tracked_bb = np.array(tracked_bb).astype(int)
    exec_times = np.array(exec_times).astype(float)

    print('FPS: {}'.format(len(exec_times) / exec_times.sum()))
    # if not debug:
    #     np.savetxt(results_path, tracked_bb, delimiter='\t', fmt='%d')
    #     np.savetxt(times_path, exec_times, delimiter='\t', fmt='%f')
    video_path = base_results_path
    if not os.path.isdir(video_path):
        os.makedirs(video_path)
    result_path = os.path.join(video_path, '{}_001.txt'.format(seq.name))
    with open(result_path, 'w') as f:
        for x in tracked_bb:
            if isinstance(x, int):
                f.write("{:d}\n".format(x))
            else:
                f.write(','.join([vot_float2str("%.4f", i) for i in x]) + '\n')
Esempio n. 6
0
def run_sequence(seq: Sequence, tracker: Tracker,dataset_name, debug=False):
    """Runs a tracker on a sequence."""
    print(dataset_name)
    if (dataset_name=="vot"):
        file_dir= os.path.join(tracker.results_dir,"baseline",seq.name)
        mkdir(file_dir)
    else:
        file_dir=tracker.results_dir
    base_results_path = '{}/{}'.format(file_dir, seq.name)
    results_path = '{}_001.txt'.format(base_results_path)
    times_path = '{}_time.txt'.format(base_results_path)
    print(results_path)
    print(os.path.isfile(results_path))
    if os.path.isfile(results_path) and not debug:
        return

    print('Tracker: {} {} {} ,  Sequence: {}'.format(tracker.name, tracker.parameter_name, tracker.run_id, seq.name))
    print(tracker)
    if debug:

        tracked_bb, exec_times = tracker.run(seq,debug=debug)
    else:
        try:
            tracked_bb, exec_times = tracker.run(seq,debug=debug)
        except Exception as e:
            print(e)
            return

    tracked_bb = np.array(tracked_bb).astype(int)
    exec_times = np.array(exec_times).astype(float)
    torch.cuda.empty_cache()
    print('FPS: {}'.format(len(exec_times) / exec_times.sum()))
    #input()
    
    if not debug:
        if (dataset_name=="vot"):
            np.savetxt(results_path, tracked_bb, delimiter=',', fmt='%d')
            np.savetxt(times_path, exec_times, delimiter=',', fmt='%f')
        else:
            np.savetxt(results_path, tracked_bb, delimiter='\t', fmt='%d')
            np.savetxt(times_path, exec_times, delimiter='\t', fmt='%f')