SadTalker
SadTalker copied to clipboard
error: (-215:Assertion failed) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function 'cv::Mat::Mat'
is it random. how can we fix this? sometimes errros like this sometimes works ok. is there a fix for this?
I have also encountered the same error. May I ask if you have resolved it? How did you solve it?
the same error
the same error
I solve it by adjusting the source code of paste_pic.py, which is in: src\utils\paste_pic.py at the bottom of the code, change it to:
for crop_frame in tqdm(crop_frames, 'seamlessClone:'): # 调整 ox1, ox2, oy1, oy2 以确保它们定义的区域不超过 full_img 的边界 ox1 = max(ox1, 0) ox2 = min(ox2, frame_w) oy1 = max(oy1, 0) oy2 = min(oy2, frame_h)
p = cv2.resize(crop_frame.astype(np.uint8), (ox2 - ox1, oy2 - oy1))
# 确保 location 在 full_img 内部
location_x = max(min((ox1 + ox2) // 2, frame_w - 1), 0)
location_y = max(min((oy1 + oy2) // 2, frame_h - 1), 0)
location = (location_x, location_y)
# 调整 mask 大小以匹配 p 的大小
mask = 255 * np.ones(p.shape[:2], p.dtype)
# 使用调整后的 location 和 mask 进行无缝克隆
gen_img = cv2.seamlessClone(p, full_img, mask, location, cv2.NORMAL_CLONE)
Oh, thank you very much for your answer. I agree with your solution and I have already fixed the bug.
---Original--- From: @.> Date: Sun, Mar 3, 2024 21:55 PM To: @.>; Cc: @.@.>; Subject: Re: [OpenTalker/SadTalker] error: (-215:Assertion failed) 0 <= roi.x&& 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <=roi.height && roi.y + roi.height <= m.rows in function 'cv::Mat::Mat' (Issue#623)
I solve it by adjusting the source code of paste_pic.py, which is in: src\utils\paste_pic.py at the bottom of the code, change it to:
for crop_frame in tqdm(crop_frames, 'seamlessClone:'):
调整 ox1, ox2, oy1, oy2 以确保它们定义的区域不超过 full_img 的边界
ox1 = max(ox1, 0)
ox2 = min(ox2, frame_w)
oy1 = max(oy1, 0)
oy2 = min(oy2, frame_h)
p = cv2.resize(crop_frame.astype(np.uint8), (ox2 - ox1, oy2 - oy1)) # 确保 location 在 full_img 内部 location_x = max(min((ox1 + ox2) // 2, frame_w - 1), 0) location_y = max(min((oy1 + oy2) // 2, frame_h - 1), 0) location = (location_x, location_y) # 调整 mask 大小以匹配 p 的大小 mask = 255 * np.ones(p.shape[:2], p.dtype) # 使用调整后的 location 和 mask 进行无缝克隆 gen_img = cv2.seamlessClone(p, full_img, mask, location, cv2.NORMAL_CLONE)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: @.***>
I solve it by adjusting the source code of paste_pic.py, which is in: src\utils\paste_pic.py at the bottom of the code, change it to:
for crop_frame in tqdm(crop_frames, 'seamlessClone:'): # 调整 ox1, ox2, oy1, oy2 以确保它们定义的区域不超过 full_img 的边界 ox1 = max(ox1, 0) ox2 = min(ox2, frame_w) oy1 = max(oy1, 0) oy2 = min(oy2, frame_h)
p = cv2.resize(crop_frame.astype(np.uint8), (ox2 - ox1, oy2 - oy1)) # 确保 location 在 full_img 内部 location_x = max(min((ox1 + ox2) // 2, frame_w - 1), 0) location_y = max(min((oy1 + oy2) // 2, frame_h - 1), 0) location = (location_x, location_y) # 调整 mask 大小以匹配 p 的大小 mask = 255 * np.ones(p.shape[:2], p.dtype) # 使用调整后的 location 和 mask 进行无缝克隆 gen_img = cv2.seamlessClone(p, full_img, mask, location, cv2.NORMAL_CLONE)
thank you very much .ooo我的问题得到了解决!