【问题标题】:OpenCV seamlessClone flickeringOpenCV无缝克隆闪烁
【发布时间】: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

Result

但是,我想使用泊松混合:

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


    【解决方案1】:

    我发现 SeamlessClone 在每一帧之后都会反转遮罩。 可以通过对掩码进行深度复制或在每次迭代后反转掩码以使其恢复到原始掩码来修复它。

    【讨论】:

      猜你喜欢
      • 2018-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-21
      • 1970-01-01
      • 1970-01-01
      • 2020-01-11
      • 1970-01-01
      相关资源
      最近更新 更多