【问题标题】:GPUImage ChromaKeyBlendFilterGPUImage ChromaKeyBlendFilter
【发布时间】:2019-02-20 16:30:38
【问题描述】:

我正在使用GPUImageChromaKeyBlendFilter 并得到不想要的输出。我要么让我的相机输入正确,要么我的背景图像没有混合两者。我有一个尺寸为 930x620 的视图,我的背景图像是 1200x800,在保持纵横比的同时缩放到 930x620。

filter = GPUImageChromaKeyBlendFilter()
filter?.setColorToReplaceRed(0.0, green: 1.0, blue: 0.0)
filter?.thresholdSensitivity = CGFloat(effectSlider)
filter?.thresholdSensitivity = 0.40
filter?.smoothing = 0.14

如果我使用下面的背景图像显示正确,但是,图像的预览被拉伸,如果我删除预览图像是正确的,但背景是倾斜的。

filter?.forceProcessing(at: overlayImage.frame.size) (the overlay is again 1200x800/930x620)

我正在使用kGPUImageFillModePreserveAspectRatioAndFill

【问题讨论】:

  • 请添加所需的 o/p 图像和实际 o/p 以获得更清晰的图像!!
  • @ShivamGaur 最终输出为 1200x800

标签: ios swift gpuimage


【解决方案1】:
func chromaKeyBlendOneVideoWithTexture() {
    // background texture
    let textureImage = UIImage(named: "texture.jpg")!
    let sourceImage = PictureInput(image: textureImage)
    sourceImage.processImage()

    do {
        let movieUrl = Bundle.main.url(forResource: "video", withExtension: "mp4")!
        let movieInput = try MovieInput(url: movieUrl, playAtActualSpeed: true)

        let chromaKeyBlendFilter = ChromaKeyBlend()

        // first add green channel video than background texture.
        movieInput --> chromaKeyBlendFilter --> renderView
        sourceImage --> chromaKeyBlendFilter

        movieInput.start()
    } catch {
        print("Couldn't process movie with error: \(error)")
    }
}

【讨论】:

    猜你喜欢
    • 2015-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-06
    • 2020-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多