Spaces:
Sleeping
Sleeping
Update src/utils/paste_pic.py
Browse files- src/utils/paste_pic.py +4 -9
src/utils/paste_pic.py
CHANGED
@@ -54,16 +54,11 @@ def paste_pic(video_path, pic_path, crop_info, new_audio_path, full_video_path):
|
|
54 |
out_tmp = cv2.VideoWriter(tmp_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (frame_w, frame_h))
|
55 |
for crop_frame in tqdm(crop_frames, 'seamlessClone:'):
|
56 |
p = cv2.resize(crop_frame.astype(np.uint8), (crx-clx, cry - cly))
|
57 |
-
roi = full_img[cly:cry, clx:crx]
|
58 |
-
alpha = 0.5
|
59 |
-
blended = cv2.addWeighted(p, alpha, roi, 1 - alpha, 0)
|
60 |
-
full_img[cly:cry, clx:crx] = blended
|
61 |
-
out_tmp.write(full_img)
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
|
68 |
out_tmp.release()
|
69 |
|
|
|
54 |
out_tmp = cv2.VideoWriter(tmp_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (frame_w, frame_h))
|
55 |
for crop_frame in tqdm(crop_frames, 'seamlessClone:'):
|
56 |
p = cv2.resize(crop_frame.astype(np.uint8), (crx-clx, cry - cly))
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
+
mask = 255*np.ones(p.shape, p.dtype)
|
59 |
+
location = ((ox1+ox2) // 2, (oy1+oy2) // 2)
|
60 |
+
gen_img = cv2.seamlessClone(p, full_img, mask, location, cv2.NORMAL_CLONE)
|
61 |
+
out_tmp.write(gen_img)
|
62 |
|
63 |
out_tmp.release()
|
64 |
|