MCPcopy Create free account
hub / github.com/ali-vilab/VACE / align_frames

Function align_frames

vace/annotators/utils.py:291–304  ·  view source on GitHub ↗
(first_frame, last_frame)

Source from the content-addressed store, hash-verified

289
290
291def align_frames(first_frame, last_frame):
292 h1, w1 = first_frame.shape[:2]
293 h2, w2 = last_frame.shape[:2]
294 if (h1, w1) == (h2, w2):
295 return last_frame
296 ratio = min(w1 / w2, h1 / h2)
297 new_w = int(w2 * ratio)
298 new_h = int(h2 * ratio)
299 resized = cv2.resize(last_frame, (new_w, new_h), interpolation=cv2.INTER_AREA)
300 aligned = np.ones((h1, w1, 3), dtype=np.uint8) * 255
301 x_offset = (w1 - new_w) // 2
302 y_offset = (h1 - new_h) // 2
303 aligned[y_offset:y_offset + new_h, x_offset:x_offset + new_w] = resized
304 return aligned
305
306
307def save_sam2_video(video_path, video_segments, output_video_path):

Callers 1

forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected