gpt4 book ai didi

ios - GPUImage ChromaKeyBlendFilter

转载 作者:行者123 更新时间:2023-11-28 07:30:46 24 4
gpt4 key购买 nike

我正在使用 GPUImageChromaKeyBlendFilter 并得到不需要的输出。我要么让我的相机输入正确,要么我的背景图像混合在一起。我有一个尺寸为 930x620 的 View ,我的背景图像为 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

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

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

我正在使用 kGPUImageFillModePreserveAspectRatioAndFill

最佳答案

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)")
}
}

关于ios - GPUImage ChromaKeyBlendFilter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54791119/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com