首页 > 解决方案 > 有没有办法用 cv2 分离和克隆图像区域?

问题描述

我知道标题不是很清楚,但它有点复杂的想法,我没有丝毫线索如何解释它。如果你能想到一个更好的标题,请,请,告诉我,我会编辑标题。

我的问题是这样的:我的一位亲密的程序员朋友要求我重新创建这个图像到图像的翻译示例。不过有一些问题。

  1. 我不能使用任何预训练的神经网络
  2. 我必须让它实时运行(使用网络摄像头)

So far I have made it up to having the face swapped but i need to make it go back on to the non webcam image but there is an issue. to do that I have to re-build and warp the whole image around that image including filling the background behind the face that isn't included in the the original source image. I have tried to use impainting but on some occasions it takes part of the hair and neck and merges it into the background just creating a mess of skin and hair colors. I have also tried expanding my mask on the cv2impainting 功能,但这会导致背景色的大方块看起来也很糟糕。我认为最好的解决方案是使用某种分割算法分割头部周围的最大区域,然后克隆该区域的一部分以保留背景纹理,而不是创建一个新的坏纹理并将该克隆区域放置在蒙版内。这一切都必须实时完成。

最后,我需要将人复制到 中img1,然后将其删除(部分我卡住了)。然后从中取出面部地标img2并将这些地标映射到img1克隆的脸上,然后将重新映射的重新添加img1img1背景上。我知道我无法像我在 8 年级那样有资格的人那样清楚地传达这些想法,所以如果需要任何澄清,请询问。

标签: pythonopencvcomputer-visionreal-timecv2

解决方案


推荐阅读