コード例 #1
0
ファイル: benchmark.py プロジェクト: xingchenzhang/OpenTraj
def min_dist_plot(dataset: TrajDataset):
    frames = dataset.get_frames()
    min_dists = np.ones(len(frames)) * 1000  # a big number
    for ii, frame in enumerate(frames):
        N_t = len(frame)
        if N_t < 2: continue
        X_t = frame[["pos_x", "pos_y"]].to_numpy()
        # compute distance matrix between all pairs of agents
        DD_t = euclidean_distances(X_t)
        DD_t = DD_t[~np.eye(N_t, dtype=bool)].reshape(N_t, N_t - 1)
        min_DD_t = np.amin(DD_t)
        min_dists[ii] = min_DD_t

    bins = np.linspace(0, 4, 40)
    hist, bins, patches = plt.hist(min_dists,
                                   bins,
                                   color='green',
                                   density=True,
                                   alpha=0.7)

    plt.title(dataset.title)
    plt.ylabel('histogram of min distances')
    plt.xlabel('meter')
    plt.xlim([bins[0], bins[-1]])
    plt.ylim([0, 2])

    return hist
コード例 #2
0
ファイル: benchmark.py プロジェクト: xingchenzhang/OpenTraj
def density_vanilla_plot(
    dataset: TrajDataset
):  # over observed space of the dataset ([minx,maxx], [miny, maxy])
    space = (dataset.bbox['x']['max'] - dataset.bbox['x']['min']) * \
            (dataset.bbox['y']['max'] - dataset.bbox['y']['min'])
    density_t = []

    frames = dataset.get_frames()
    for frame in frames:
        density_t.append(len(frame) / space)

    bins = np.linspace(0, 1, 40)
    hist, bins, patches = plt.hist(density_t,
                                   bins=bins,
                                   color='red',
                                   density=True,
                                   alpha=0.7)

    plt.title(dataset.title)
    plt.ylabel('distribution of density')
    plt.xlabel('Person per m^2')
コード例 #3
0
ファイル: benchmark.py プロジェクト: xingchenzhang/OpenTraj
def pcf_plot(dataset: TrajDataset):
    frames = dataset.get_frames()
    # calc pcf on a dataset
    pcf_accum = []
    pcf_range = np.arange(
        0.2,  # starting radius
        8,  # end radius
        0.2)  # step size

    for frame in frames:
        pcf_values_t = pcf(frame[['pos_x', 'pos_y', 'pos_z']],
                           list(pcf_range),
                           sigma=0.25)
        if not len(pcf_accum):
            pcf_accum = pcf_values_t
        else:
            pcf_accum += pcf_values_t
    avg_pcf = pcf_accum / len(frames)

    plt.title(dataset.title)
    plt.ylabel('PCF')
    plt.xlabel('meter')
    plt.plot(avg_pcf, color='purple')