我正在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'
旁注:
我已检查过高度是否大于零并调用该函数,但会返回错误。