Spaces:
Running
on
Zero
Running
on
Zero
Update src/pixel3dmm/tracking/tracker.py
Browse files
src/pixel3dmm/tracking/tracker.py
CHANGED
@@ -1714,13 +1714,25 @@ class Tracker(object):
|
|
1714 |
batches = {k: torch.cat([x[k] for x in batches], dim=0) for k in batch.keys()}
|
1715 |
selected_frames = torch.from_numpy(np.array(selected_frames)).long().cuda()
|
1716 |
|
1717 |
-
result_rendering = self.render_and_save(batches, visualizations=[[View.
|
1718 |
frame_dst='/joint_initialization', outer_iter=0, timestep=timestep, is_final=True, selected_frames=selected_frames)
|
1719 |
video_frames.append(np.array(result_rendering))
|
1720 |
self.frame += 1
|
1721 |
|
1722 |
-
|
|
|
1723 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1724 |
|
1725 |
# Optionally delete all preoprocessing artifacts, once tracking is done (only keep cropped images)
|
1726 |
if self.config.delete_preprocessing:
|
|
|
1714 |
batches = {k: torch.cat([x[k] for x in batches], dim=0) for k in batch.keys()}
|
1715 |
selected_frames = torch.from_numpy(np.array(selected_frames)).long().cuda()
|
1716 |
|
1717 |
+
result_rendering = self.render_and_save(batches, visualizations=[[View.SHAPE]],
|
1718 |
frame_dst='/joint_initialization', outer_iter=0, timestep=timestep, is_final=True, selected_frames=selected_frames)
|
1719 |
video_frames.append(np.array(result_rendering))
|
1720 |
self.frame += 1
|
1721 |
|
1722 |
+
out_dir = f"{self.save_folder}/{self.config.video_name}/frames"
|
1723 |
+
os.makedirs(out_dir, exist_ok=True)
|
1724 |
|
1725 |
+
for i, frame in enumerate(video_frames):
|
1726 |
+
# If float in [0,1], convert:
|
1727 |
+
if frame.dtype != np.uint8:
|
1728 |
+
frame_uint8 = (frame * 255).astype(np.uint8)
|
1729 |
+
else:
|
1730 |
+
frame_uint8 = frame
|
1731 |
+
# OpenCV expects BGR ordering:
|
1732 |
+
bgr = cv2.cvtColor(frame_uint8, cv2.COLOR_RGB2BGR)
|
1733 |
+
cv2.imwrite(os.path.join(out_dir, f"{i:05d}.jpg"), bgr)
|
1734 |
+
|
1735 |
+
print(f"✅ Saved {len(video_frames)} frames to `{out_dir}`")
|
1736 |
|
1737 |
# Optionally delete all preoprocessing artifacts, once tracking is done (only keep cropped images)
|
1738 |
if self.config.delete_preprocessing:
|