-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
|
||
import h5py, tqdm | ||
import argparse | ||
import matplotlib.pyplot as plt | ||
import matplotlib.cm as cm | ||
import matplotlib.animation as animation | ||
|
||
if __name__ == "__main__": | ||
|
||
# Specify the path to your HDF5 file | ||
file_path = 'data/episode_46.hdf5' | ||
# Parse command line arguments | ||
parser = argparse.ArgumentParser(description='Trace video from HDF5 trace file') | ||
parser.add_argument('--file_path', type=str, default='data/episode_46.hdf5', help='Path to HDF5 file') | ||
parser.add_argument('--camera_id', type=str, default='observations/images/front', help='Camera ID') | ||
parser.add_argument('--save_file', type=str, default='movie.mp4', help='Path to save the video file') | ||
args = parser.parse_args() | ||
|
||
# Open the HDF5 file | ||
with h5py.File(file_path, 'r') as file: | ||
# Access the specified HDF5 file | ||
with h5py.File(args.file_path, 'r') as file: | ||
|
||
# Access the datasets or attributes in the file | ||
# For example, to access a dataset named 'data': | ||
group_obs_img = file['observations/images/front'] | ||
# Access the datasets or attributes in the file | ||
group_obs_img = file[args.camera_id] | ||
|
||
img = [] # some array of images | ||
frames = [] # for storing the generated images | ||
img = [] # some array of images | ||
frames = [] # for storing the generated images | ||
|
||
# Write each image to the video | ||
fig = plt.figure() | ||
for i in tqdm.tqdm(range(group_obs_img.shape[0]), desc='Writing video'): | ||
frames.append([plt.imshow(group_obs_img[i],animated=True)]) | ||
# Write each image to the video | ||
fig = plt.figure() | ||
for i in tqdm.tqdm(range(group_obs_img.shape[0]), desc='Writing video'): | ||
frames.append([plt.imshow(group_obs_img[i],animated=True)]) | ||
|
||
ani = animation.ArtistAnimation(fig, frames, interval=50, blit=True, | ||
repeat_delay=1000) | ||
ani.save('movie.mp4') | ||
ani = animation.ArtistAnimation(fig, frames, interval=50, blit=True, repeat_delay=1000) | ||
ani.save(args.save_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters