【发布时间】:2019-11-19 20:33:57
【问题描述】:
CIDepthBlurEffect 通常可以在装有 ios 12.4 的手机上运行,但是当我尝试检查“inputFocusRect”参数时会出现以下错误?当我设置 y : 0; 时也不会产生错误。但是图像未处理。任何的想法?谢谢。
- 无法渲染 12192768 像素,因为 CIKernel 的 ROI 函数不允许平铺。
- 无法渲染部分图像,因为 -1 的内存要求太大。
代码如下:
if let filter = CIFilter(name: "CIDepthBlurEffect", parameters: [kCIInputImageKey : mainImage, kCIInputDisparityImageKey : disparityMap]) {
filter.setValue(0.1, forKey: "inputAperture")
filter.setValue(0.1, forKey: "inputScaleFactor")
filter.setValue(CIVector(x: 0, y: 100, z: 100, w: 100), forKey: "inputFocusRect") // works without this line
let result = filter.outputImage
self.imageView.image = UIImage(ciImage: result!)
}
【问题讨论】:
-
(1) 模糊 占用大量内存。您不能以这种方式模糊大图像。 (2)
self.imageView.image = UIImage(ciImage: result!)不是将CIImage转为UIImage进行展示的正确方式。 -
那么正确的方法是什么?
-
另请注意,当我只模糊背景而不触摸“inputFocusRect”时,它可以工作吗?!
标签: ios swift core-image