图像大小取为(0,0),即使它不是

时间:2017-07-05 06:58:49

标签: ios swift filter gpuimage

我正在GPUImage使用Swift 3.0并尝试添加图片过滤器,但GPUImage崩溃了。崩溃日志:图像大小应大于0。

我的代码:

let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
let ciImage = CIImage(cvPixelBuffer: pixelBuffer!)
var image = UIImage(ciImage: ciImage)

if image.size.height > 0 && image.size.width > 0 {
    let contrastfilter = GPUImageContrastFilter()
    image = contrastfilter.image(byFilteringImage: image)
}

错误:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Passed image must not be empty - it should be at least 1px tall and wide'

旁注:

我已检查过高度是否大于零并调用该函数,但会返回错误。

0 个答案:

没有答案