【发布时间】:2020-06-24 19:24:05
【问题描述】:
我有一个video,我从中提取第一帧用作静态背景。对于视频的每一帧,我想使用 mask 将其中的一部分遮盖在静态背景之上。
没有混合:
maskedFrame = cv2.bitwise_and(frame, frame, mask = mask)
maskedBackground = cv2.bitwise_and(staticBackground, staticBackground, mask = cv2.bitwise_not(mask))
output = maskedFrame + maskedBackground
但是,我想使用泊松混合:
output = cv2.seamlessClone(frame, staticBackground, center, cv2.NORMAL_CLONE)
中心计算如下:
x,y,w,h = cv2.boundingRect(contours[0])
center = (int(x+w/2), int(y+h/2))
这会产生weird results and flickering, and what looks like a rectangular mask。
我认为可能是蒙版在移动对象周围太紧了,所以我缩放了它的轮廓,但这并没有解决问题。我还尝试了使用 maskedBackground 而不是 staticBackground 的无缝克隆,但不出所料,这也不起作用。
对于这个问题,无缝克隆是一个错误的选择还是我使用不正确?
【问题讨论】:
标签: python opencv computer-vision video-processing