我正在使用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。
发布于 2019-03-04 14:42:26
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)")
}
}https://stackoverflow.com/questions/54791119
复制相似问题