我想修改CIFilter CITemperatureAndTint
的参数。通过查看文档,我感兴趣的两个参数是CIVectors,inputNeutral
和inputTargetNeutral
。我想修改inputNeutral向量,所以我尝试了以下内容。
let point = CIVector(x: 6500,y :0)
//create instance of filter
let filter = CIFilter(name: "CITemperatureAndTint" )
filter!.setValue(6500, forKey: kCIInputNeutralTemperatureKey)
filter!.setValue(0, forKey: kCIInputNeutralTintKey)
filter!.setValue(coreImage, forKey: kCIInputImageKey)
let filteredImageData = filter!.value(forKey: kCIOutputImageKey) as! CIImage
出于某种原因,我得到了两行的NSUnknownKeyException,我设置了过滤器的值,我不知道如何解决它。对于其他参数inputTargetNeutral
,我遇到了同样的错误。我该如何解决?我得到的错误是
2017-06-08 11:25:38.751 ImageProcessing[950:50758]
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<CITemperatureAndTint 0x6000000cce80> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key inputNeutralTemperature.'
答案 0 :(得分:0)
尝试将kCIInputNeutralTemperatureKey
和kCIInputNeutralTintKey
替换为inputNeutral
和inputTargetNeutral
,以便代码的setValue部分看起来像这样:
let inputVector = CIVector(x: 6500, y: 0) // arbitrary values
currentFilter.setValue(inputVector, forKey: "inputNeutral")
let targetVector = CIVector(x: 3000, y: 0) // arbitrary values
currentFilter.setValue(targetVector, forKey: "inputTargetNeutral")