Пример #1
0
def entropies_set(opentraj_root, datasets_name, M=30, replace=False):
    entropies_dir = os.path.join(opentraj_root, 'entropies')
    if not os.path.exists(entropies_dir): os.makedirs(entropies_dir)

    trajectories_set = get_trajlets(opentraj_root, datasets_name)

    entropy_values_set = {}
    maximum = []
    for name in trajectories_set:
        if replace == True: R = '-R'
        else: R = '-NR'
        trajlet_entropy_file = os.path.join(
            entropies_dir, name + str(M) + '-entropy' + R + '.npy')
        if os.path.exists(trajlet_entropy_file):
            entropy_values = np.load(trajlet_entropy_file)
            print("loading entropies from: ", trajlet_entropy_file)
        else:
            entropy_values = get_entropies(opentraj_root,
                                           trajectories_set[name],
                                           name,
                                           M,
                                           replace=replace)
            np.save(trajlet_entropy_file, entropy_values)
            print("writing entropies ndarray into: ", trajlet_entropy_file)
        entropy_values_set.update({name: entropy_values})
        if name in reference_folders:
            path = os.path.join(opentraj_root, reference_folders[name])
            #visualize_max_entropy(trajectories_set[name], np.argmax(entropy_values_set[name]),path,name,replace)
    return entropy_values_set
def entropies_set(opentraj_root, datasets_name, M = 30):
    entropies_dir = os.path.join(opentraj_root, 'entropies')
    if not os.path.exists(entropies_dir): os.makedirs(entropies_dir)
    
    trajectories_set = get_trajlets(opentraj_root,datasets_name)
    
    entropy_values_set = {}
    for name in trajectories_set:
        trajlet_entropy_file = os.path.join(entropies_dir, name + str(M) + '-entropy.npy')
        if os.path.exists(trajlet_entropy_file):
            entropy_values = np.load(trajlet_entropy_file)
            print("loading entropies from: ", trajlet_entropy_file)
        else:
                entropy_values = get_entropies(opentraj_root, trajectories_set[name],name, M)
                np.save(trajlet_entropy_file, entropy_values)
                print("writing entropies ndarray into: ", trajlet_entropy_file)
        entropy_values_set.update({name : entropy_values})
    return entropy_values_set
Пример #3
0
    dt = np.diff(trajlets_np[:, :, 4], axis=1)
    acc_values = np.diff(speed_values, axis=1) / dt
    # acc_values = np.abs(acc_values)  # FixMe
    return np.mean(np.abs(acc_values), axis=1), np.max(np.abs(acc_values), axis=1)


if __name__ == "__main__":
    from toolkit.benchmarking.load_all_datasets import get_trajlets, all_dataset_names

    opentraj_root = sys.argv[1]  # e.g. os.path.expanduser("~") + '/workspace2/OpenTraj'
    output_dir = sys.argv[2]  # e.g. os.path.expanduser("~") + '/Dropbox/OpenTraj-paper/exp/ver-0.2'

    dataset_names = all_dataset_names

    # datasets = get_datasets(opentraj_root, dataset_names)
    trajlets = get_trajlets(opentraj_root, dataset_names)

    print("calculating speed_var indicator ...")
    speed_mean_values, speed_var_values = [], []
    for ds_name in dataset_names:
        speed_mean_values.append(speed_avg_of_trajs(trajlets[ds_name]))
        speed_var_values.append(speed_var_of_trajs(trajlets[ds_name]))

    print("calculating acceleration indicator ...")
    acc_mean_values, acc_max_values = [], []
    for ds_name in dataset_names:
        acc_mean_values_i, acc_max_values_i = acceleration_of_tarjs(trajlets[ds_name])
        acc_mean_values.append(acc_mean_values_i)
        acc_max_values.append(acc_max_values_i)

    # down-sample values
Пример #4
0
import plotly.graph_objs as go
from toolkit.benchmarking.load_all_datasets import get_datasets, get_trajlets, all_dataset_names
from toolkit.benchmarking.indicators.motion_properties import speed_avg_of_trajs, acceleration_of_tarjs
from matplotlib import cm

if __name__ == '__main__':
    opentraj_root = sys.argv[1]
    datasets = get_datasets(opentraj_root, ['KITTI'])
    trajlet_sets = get_trajlets(
        opentraj_root,
        # all_dataset_names[:1]
        [
            # 'ETH-Univ',
            # 'ETH-Hotel',
            # 'UCY-Zara',
            # 'UCY-Univ',
            # 'SDD-coupa',
            # 'SDD-bookstore',
            # 'SDD-deathCircle',
            # 'WildTrack',
            # 'KITTI'
            'LCas-Minerva',
        ])

    colormap = cm.get_cmap('Reds', 10)

    for ds_name, trajlet_set in trajlet_sets.items():
        fig = go.Figure()

        speed_avg = speed_avg_of_trajs(trajlet_set)
        acc_avg, acc_max = acceleration_of_tarjs(trajlet_set)