首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GPUImage ChromaKeyBlendFilter

GPUImage ChromaKeyBlendFilter
EN

Stack Overflow用户
提问于 2019-02-21 00:30:39
回答 1查看 178关注 0票数 1

我正在使用GPUImageChromaKeyBlendFilter,并得到了不想要的输出。我要么我的相机输入正确,要么我的背景图像混合不是两者。我有一个930x620大小的视图,我的背景图像是1200x800,它在保持宽高比的同时缩放到930x620。

代码语言:javascript
复制
filter = GPUImageChromaKeyBlendFilter()
filter?.setColorToReplaceRed(0.0, green: 1.0, blue: 0.0)
filter?.thresholdSensitivity = CGFloat(effectSlider)
filter?.thresholdSensitivity = 0.40
filter?.smoothing = 0.14

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

代码语言:javascript
复制
filter?.forceProcessing(at: overlayImage.frame.size) (the overlay is again 1200x800/930x620)

我正在使用kGPUImageFillModePreserveAspectRatioAndFill

EN

回答 1

Stack Overflow用户

发布于 2019-03-04 14:42:26

代码语言:javascript
复制
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)")
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54791119

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档