Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use the visualization code for result #16

Closed
moonseokha opened this issue Oct 3, 2022 · 5 comments
Closed

Can I use the visualization code for result #16

moonseokha opened this issue Oct 3, 2022 · 5 comments

Comments

@moonseokha
Copy link

Thank you so much for sharing the code.
I would like to use the result visualization in HiVT code, but has the visualization code shown on the github page not been shared? Can you share it ?
Thank U!

@ZikangZhou
Copy link
Owner

Hi @moonseokha,

Sorry for the late reply.

def plot_single_vehicle(
    avm: ArgoverseMap, 
    sample_past_trajectory: np.ndarray,  # (20, 2)
    sample_groundtruth: np.ndarray,  # (20, 2) 
    sample_forecasted_trajectories: List[np.ndarray],  # List[(30, 2)]
    sample_city_name: str, 
    ls: str):

    sample_groundtruth = np.concatenate((np.expand_dims(sample_past_trajectory[-1], axis=0), sample_groundtruth), axis=0)
    for sample_forecasted_trajectory in sample_forecasted_trajectories:
        sample_forecasted_trajectory = np.concatenate((np.expand_dims(sample_past_trajectory[-1], axis=0), sample_forecasted_trajectory), axis=0)

    ## Plot history
    obs_len = sample_past_trajectory.shape[0]
    pred_len = sample_groundtruth.shape[0]
    plt.plot(
        sample_past_trajectory[:, 0],
        sample_past_trajectory[:, 1],
        color="#ECA154",
        label="Past Trajectory",
        alpha=1,
        linewidth=3,
        zorder=15,
        ls = ls
    )

    ## Plot future
    plt.plot(
        sample_groundtruth[:, 0],
        sample_groundtruth[:, 1],
        color="#d33e4c",
        label="Ground Truth",
        alpha=1,
        linewidth=3.0,
        zorder=20,
        ls = "--"
    )

    ## Plot prediction
    for j in range(len(sample_forecasted_trajectories)):
        plt.plot(
            sample_forecasted_trajectories[j][:, 0],
            sample_forecasted_trajectories[j][:, 1],
            color="#007672",
            label="Forecasted Trajectory",
            alpha=1,
            linewidth=3.2,
            zorder=15,
            ls = "--"
        )
        
        # Plot the end marker for forcasted trajectories
        plt.arrow(
            sample_forecasted_trajectories[j][-2, 0], 
            sample_forecasted_trajectories[j][-2, 1],
            sample_forecasted_trajectories[j][-1, 0] - sample_forecasted_trajectories[j][-2, 0],
            sample_forecasted_trajectories[j][-1, 1] - sample_forecasted_trajectories[j][-2, 1],
            color="#007672",
            label="Forecasted Trajectory",
            alpha=1,
            linewidth=3.2,
            zorder=15,
            head_width=1.1,
        )
    
    ## Plot the end marker for history
    plt.arrow(
            sample_past_trajectory[-2, 0], 
            sample_past_trajectory[-2, 1],
            sample_past_trajectory[-1, 0] - sample_past_trajectory[-2, 0],
            sample_past_trajectory[-1, 1] - sample_past_trajectory[-2, 1],
            color="#ECA154",
            label="Past Trajectory",
            alpha=1,
            linewidth=3,
            zorder=25,
            head_width=1.0,
        )

    ## Plot the end marker for future
    plt.arrow(
            sample_groundtruth[-2, 0], 
            sample_groundtruth[-2, 1],
            sample_groundtruth[-1, 0] - sample_groundtruth[-2, 0],
            sample_groundtruth[-1, 1] - sample_groundtruth[-2, 1],
            color="#d33e4c",
            label="Ground Truth",
            alpha=1,
            linewidth=3.0,
            zorder=25,
            head_width=1.0,
        )

    ## Plot history context
    for j in range(obs_len):
        lane_ids = avm.get_lane_ids_in_xy_bbox(
            sample_past_trajectory[j, 0],
            sample_past_trajectory[j, 1],
            sample_city_name,
            query_search_range_manhattan=65,
        )
        [avm.draw_lane(lane_id, sample_city_name) for lane_id in lane_ids]

    ## Plot future context
    for j in range(pred_len):
        lane_ids = avm.get_lane_ids_in_xy_bbox(
            sample_groundtruth[j, 0],
            sample_groundtruth[j, 1],
            sample_city_name,
            query_search_range_manhattan=65,
        )
        [avm.draw_lane(lane_id, sample_city_name) for lane_id in lane_ids]

@moonseokha
Copy link
Author

Thank you for reply and good code. :)

@xinfu607
Copy link

xinfu607 commented Mar 2, 2023

Thank you for reply and good code. :)
Hi,
Could you please release the complete visualization code? Thanks a lot.

@Joonki0111
Copy link

Hi, i've seen the code and i want to know how to get those samples in the code below

def plot_single_vehicle(
avm: ArgoverseMap,
sample_past_trajectory: np.ndarray, # (20, 2)
sample_groundtruth: np.ndarray, # (20, 2)
sample_forecasted_trajectories: List[np.ndarray], # List[(30, 2)]
sample_city_name: str,
ls: str):

there is no code generating sample_past_trajectory, sample_groundtruth, sample_forecasted_trajectories
in HiVT repository so i cant run that code.

any help and suggestions will be helping my project alot.
Thanks :)

@MPCheng-ZW
Copy link

Hi, have you solved this problem? Thank you!
@Joonki0111 @xinfu607 @moonseokha @ZikangZhou

Hi, i've seen the code and i want to know how to get those samples in the code below

def plot_single_vehicle( avm: ArgoverseMap, sample_past_trajectory: np.ndarray, # (20, 2) sample_groundtruth: np.ndarray, # (20, 2) sample_forecasted_trajectories: List[np.ndarray], # List[(30, 2)] sample_city_name: str, ls: str):

there is no code generating sample_past_trajectory, sample_groundtruth, sample_forecasted_trajectories in HiVT repository so i cant run that code.

any help and suggestions will be helping my project alot. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants