Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chanwutk committed Nov 3, 2023
1 parent 0ae3931 commit f95cb87
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion evaluation/ablation/test-stream-2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
54 changes: 28 additions & 26 deletions longvideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,35 @@ def is_notebook() -> bool:
# In[4]:


NUSCENES_PROCESSED_DATA = "NUSCENES_PROCESSED_DATA"
print(NUSCENES_PROCESSED_DATA in os.environ)
print(os.environ['NUSCENES_PROCESSED_DATA'])
# NUSCENES_PROCESSED_DATA = "NUSCENES_PROCESSED_DATA"
# print(NUSCENES_PROCESSED_DATA in os.environ)
# print(os.environ['NUSCENES_PROCESSED_DATA'])


# In[12]:
# # In[12]:


DATA_DIR = os.environ[NUSCENES_PROCESSED_DATA]
# with open(os.path.join(DATA_DIR, "videos", "frames.pkl"), "rb") as f:
# videos = pickle.load(f)
with open(os.path.join(DATA_DIR, 'videos', 'videos.json'), 'r') as f:
videos = json.load(f)
type(videos)
videos[0]
# DATA_DIR = os.environ[NUSCENES_PROCESSED_DATA]
# # with open(os.path.join(DATA_DIR, "videos", "frames.pkl"), "rb") as f:
# # videos = pickle.load(f)
# with open(os.path.join(DATA_DIR, 'videos', 'videos.json'), 'r') as f:
# videos = json.load(f)
# type(videos)
# videos[0]


# In[10]:


with open('./data/evaluation/video-samples/boston-seaport.txt', 'r') as f:
sampled_scenes = f.read().split('\n')
print(sampled_scenes[0], sampled_scenes[-1], len(sampled_scenes))
# with open('./data/evaluation/video-samples/boston-seaport.txt', 'r') as f:
# sampled_scenes = f.read().split('\n')
# print(sampled_scenes[0], sampled_scenes[-1], len(sampled_scenes))


# In[17]:


with open(os.path.join(DATA_DIR, 'videos', 'boston-seaport-scene-' + sampled_scenes[0] + '-CAM_FRONT.pkl'), 'rb') as f:
with open('/home/chanwutk/data/boston-seaport-scene-0655-CAM_FRONT.pkl', 'rb') as f:
# with open(os.path.join(DATA_DIR, 'videos', 'boston-seaport-scene-' + sampled_scenes[0] + '-CAM_FRONT.pkl'), 'rb') as f:
video = pickle.load(f)
video_filename = video['filename']

Expand All @@ -92,7 +92,7 @@ def is_notebook() -> bool:


frames = []
cap = cv2.VideoCapture(os.path.join(DATA_DIR, 'videos', video_filename))
cap = cv2.VideoCapture(os.path.join('/home/chanwutk/data/', video_filename))
while cap.isOpened():
ret, frame = cap.read()
if not ret:
Expand All @@ -104,15 +104,17 @@ def is_notebook() -> bool:

# In[28]:


result = cv2.VideoWriter('./loop-video.avi',
cv2.VideoWriter_fourcc(*'MJPG'),
12, (1600, 900))
for i in tqdm(range(633)):
for frame in frames:
result.write(frame)
result.release()
cv2.destroyAllWindows()
n = 633

for i in [3]:
result = cv2.VideoWriter(f'./loop-video-{i}0.avi',
cv2.VideoWriter_fourcc(*'MJPG'),
20, (1600, 900))
for i in tqdm(range(n * i)):
for frame in frames:
result.write(frame)
result.release()
cv2.destroyAllWindows()


# In[ ]:
Expand Down

0 comments on commit f95cb87

Please sign in to comment.